diff --git a/brewman/brewman/models/__init__.py b/brewman/brewman/models/__init__.py index bee99ef8..ed0442e6 100644 --- a/brewman/brewman/models/__init__.py +++ b/brewman/brewman/models/__init__.py @@ -11,7 +11,6 @@ Base = declarative_base() def initialize_sql(engine): DBSession.configure(bind=engine) Base.metadata.bind = engine - Base.metadata.create_all(engine) diff --git a/brewman/brewman/models/auth.py b/brewman/brewman/models/auth.py index 2da76140..21d8eb2f 100644 --- a/brewman/brewman/models/auth.py +++ b/brewman/brewman/models/auth.py @@ -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) diff --git a/brewman/brewman/models/master.py b/brewman/brewman/models/master.py index 1af01ce0..08f729b3 100644 --- a/brewman/brewman/models/master.py +++ b/brewman/brewman/models/master.py @@ -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): diff --git a/brewman/brewman/models/voucher.py b/brewman/brewman/models/voucher.py index d7c77c67..4c2ba052 100644 --- a/brewman/brewman/models/voucher.py +++ b/brewman/brewman/models/voucher.py @@ -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() diff --git a/brewman/brewman/views/auth/user.py b/brewman/brewman/views/auth/user.py index 7c03302b..2c9a9650 100644 --- a/brewman/brewman/views/auth/user.py +++ b/brewman/brewman/views/auth/user.py @@ -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() -