removed database trasfer code.
This commit is contained in:
parent
77e3945f1e
commit
eaa32d9c3a
@ -11,7 +11,6 @@ Base = declarative_base()
|
||||
def initialize_sql(engine):
|
||||
DBSession.configure(bind=engine)
|
||||
Base.metadata.bind = engine
|
||||
Base.metadata.create_all(engine)
|
||||
|
||||
|
||||
|
||||
|
@ -134,7 +134,7 @@ class User(Base):
|
||||
def filtered_list(cls, name):
|
||||
query = DBSession.query(cls)
|
||||
for item in name.split():
|
||||
query = query.filter(cls.name.like('%' + item + '%'))
|
||||
query = query.filter(cls.name.ilike('%' + item + '%'))
|
||||
return query.order_by(cls.name)
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ class Product(Base):
|
||||
def list(cls, name):
|
||||
query = DBSession.query(cls)
|
||||
for item in name.split():
|
||||
query = query.filter(cls.name.like('%' + item + '%'))
|
||||
query = query.filter(cls.name.ilike('%' + item + '%'))
|
||||
return query.order_by(cls.name)
|
||||
|
||||
@classmethod
|
||||
@ -193,7 +193,7 @@ class LedgerBase(Base):
|
||||
query = query.filter(cls.type == type)
|
||||
if name != None:
|
||||
for item in name.split():
|
||||
query = query.filter(cls.name.like('%' + item + '%'))
|
||||
query = query.filter(cls.name.ilike('%' + item + '%'))
|
||||
return query.order_by(cls.name)
|
||||
|
||||
def create(self):
|
||||
|
@ -245,7 +245,7 @@ class Batch(Base):
|
||||
if not include_nil:
|
||||
query = query.filter(cls.quantity_remaining > 0)
|
||||
for item in name.split():
|
||||
query = query.filter(Product.name.like('%' + item + '%'))
|
||||
query = query.filter(Product.name.ilike('%' + item + '%'))
|
||||
return query.order_by(Product.name).all()
|
||||
|
||||
|
||||
|
@ -1,18 +1,13 @@
|
||||
import os
|
||||
import re
|
||||
import uuid
|
||||
from pyramid.response import Response
|
||||
|
||||
from pyramid.view import view_config
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
import transaction
|
||||
from brewman.models import DBSession
|
||||
from brewman.models.auth import User, Group, Role, Client, user_group, role_group
|
||||
from brewman.models.master import ProductGroup, CostCenter, Ledger, Employee, Product
|
||||
from brewman.models.auth import User, Group
|
||||
|
||||
from brewman.models.validation_exception import TryCatchFunction
|
||||
from brewman.models.voucher import Inventory, Voucher, Journal, Attendance, Batch, SalaryDeduction
|
||||
|
||||
|
||||
@view_config(route_name='user_list', renderer='brewman:templates/angular_base.mako', permission='Users')
|
||||
@ -94,7 +89,6 @@ def show_blank(request):
|
||||
# for import
|
||||
@view_config(request_method='GET', route_name='api_user', renderer='json', request_param='list')
|
||||
def show_list(request):
|
||||
populate_from_old()
|
||||
list = User.list()
|
||||
users = []
|
||||
for item in list:
|
||||
@ -121,32 +115,3 @@ def user_info(id):
|
||||
account['Groups'].append(
|
||||
{'GroupID': item.id, 'Name': item.name, 'Enabled': True if item in user.groups else False})
|
||||
return account
|
||||
|
||||
|
||||
def make_session(connection_string):
|
||||
engine = create_engine(connection_string, echo=False, convert_unicode=True)
|
||||
Session = sessionmaker(bind=engine)
|
||||
return Session(), engine
|
||||
|
||||
def copy(source, destination, table):
|
||||
for i in source.query(table).all():
|
||||
destination.merge(i)
|
||||
destination.commit()
|
||||
|
||||
def populate_from_old():
|
||||
""" Populate initial data and table structure
|
||||
"""
|
||||
source, sengine = make_session('sqlite:///' + os.getcwd() + '/database/brewman1.db')
|
||||
destination, dengine = make_session('postgresql://postgres:123456@localhost:5432/brewman')
|
||||
|
||||
for i in [Group, ProductGroup, CostCenter, Role, Client, User, Voucher, Ledger, Employee, Journal,
|
||||
Product, Attendance, SalaryDeduction, Batch, Inventory]:
|
||||
copy(source, destination, i)
|
||||
|
||||
# for i in source.query(user_group).all():
|
||||
# destination.merge(i)
|
||||
# destination.commit()
|
||||
# for i in source.query(role_group).all():
|
||||
# destination.merge(i)
|
||||
# destination.commit()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user