diff --git a/Conversion/SqliteDB.txt b/Conversion/SqliteDB.txt index e79b7ff8..d0198d9c 100644 --- a/Conversion/SqliteDB.txt +++ b/Conversion/SqliteDB.txt @@ -1,3 +1,4 @@ +UPDATE Auth_Roles Set Name = 'Users' WHERE Name = 'CreateUser' --update entities_ledgers set code = code + 60 where type = 13; -- to prevent duplicate code when converting UPDATE entities_ledgers SET type = 11 WHERE type = 13; DROP TABLE Entities_Taxes; diff --git a/brewman/brewman/__init__.py b/brewman/brewman/__init__.py index a0fd606e..57a5e630 100644 --- a/brewman/brewman/__init__.py +++ b/brewman/brewman/__init__.py @@ -54,10 +54,18 @@ def main(global_config, **settings): config.add_route('account', '/Account') config.add_route('account_list', '/Accounts') + config.add_route('employee_id', '/Employee/{id}') + config.add_route('employee', '/Employee') + config.add_route('employee_list', '/Employees') + config.add_route('user_id', '/User/{id}') config.add_route('user', '/User') config.add_route('user_list', '/Users') + config.add_route('group_id', '/Group/{id}') + config.add_route('group', '/Group') + config.add_route('group_list', '/Groups') + config.add_route('product_id', '/Product/{id}') config.add_route('product', '/Product') config.add_route('product_list', '/Products') @@ -66,16 +74,11 @@ def main(global_config, **settings): config.add_route('product_group', '/ProductGroup') config.add_route('product_group_list', '/ProductGroups') - config.add_route('employee_attendance_save', '/Employee/Attendance/Save') config.add_route('employee_attendance', '/Employee/Attendance') - config.add_route('employee_id', '/Employee/{id}') - config.add_route('employee_attendance_id', '/Employee/{id}/Attendance') - config.add_route('employee', '/Employee') - config.add_route('employee_list', '/Employees') config.add_route('attendance_save', '/Attendance/Save') config.add_route('attendance_date', '/Attendance/{date}') config.add_route('attendance', '/Attendance') @@ -115,10 +118,7 @@ def main(global_config, **settings): config.add_route('daybook', '/Daybook') config.add_route('unposted', '/Unposted') config.add_route('profit_loss', '/ProfitLoss') - - config.add_route('group_roles_id', '/Admin/GroupRoles/{id}') - config.add_route('group_roles', '/Admin/GroupRoles') - config.add_route('save_group_roles', '/Admin/GroupRolesSave') + config.add_route('purchase_entries', '/PurchaseEntries') config.add_route('services_session_current_date', '/Services/CurrentDate') config.add_route('services_session_period_start', '/Services/PeriodStart') diff --git a/brewman/brewman/factories.py b/brewman/brewman/factories.py index a732590c..13bad604 100644 --- a/brewman/brewman/factories.py +++ b/brewman/brewman/factories.py @@ -1,77 +1,17 @@ from pyramid.security import Everyone from pyramid.security import Authenticated from pyramid.security import Allow +from brewman.models.auth import Role class RootFactory(object): - __acl__ = [ - (Allow, Everyone, 'view'), - (Allow, Authenticated, 'post'), - (Allow, 'Attendance', 'Attendance'), - (Allow, 'BalanceSheet', 'BalanceSheet'), - (Allow, 'Cash Flow', 'Cash Flow'), - (Allow, 'CostCenter', 'CostCenter'), - (Allow, 'CostCenterCreate', 'CostCenterCreate'), - (Allow, 'CostCenterDelete', 'CostCenterDelete'), - (Allow, 'CostCenterRetrieve', 'CostCenterRetrieve'), - (Allow, 'CostCenterUpdate', 'CostCenterUpdate'), - (Allow, 'CreateUser', 'CreateUser'), - (Allow, 'DayBook', 'DayBook'), - (Allow, 'EditPosted', 'EditPosted'), - (Allow, 'Employees', 'Employees'), - (Allow, 'EmployeesCreate', 'EmployeesCreate'), - (Allow, 'EmployeesDelete', 'EmployeesDelete'), - (Allow, 'EmployeesRetrieve', 'EmployeesRetrieve'), - (Allow, 'EmployeesUpdate', 'EmployeesUpdate'), - (Allow, 'Finger Prints', 'Finger Prints'), - (Allow, 'Issue', 'Issue'), - (Allow, 'Issue Create', 'Issue Create'), - (Allow, 'Issue Delete', 'Issue Delete'), - (Allow, 'Issue Post', 'Issue Post'), - (Allow, 'Issue Update', 'Issue Update'), - (Allow, 'Journal', 'Journal'), - (Allow, 'Journal Create', 'Journal Create'), - (Allow, 'Journal Delete', 'Journal Delete'), - (Allow, 'Journal Post', 'Journal Post'), - (Allow, 'Journal Update', 'Journal Update'), - (Allow, 'Ledgers', 'Ledgers'), - (Allow, 'LedgersCreate', 'LedgersCreate'), - (Allow, 'LedgersDelete', 'LedgersDelete'), - (Allow, 'LedgersRetrieve', 'LedgersRetrieve'), - (Allow, 'LedgersUpdate', 'LedgersUpdate'), - (Allow, 'ManageRoles', 'ManageRoles'), - (Allow, 'OldTransactions', 'OldTransactions'), - (Allow, 'Payment', 'Payment'), - (Allow, 'Payment Create', 'Payment Create'), - (Allow, 'Payment Delete', 'Payment Delete'), - (Allow, 'Payment Post', 'Payment Post'), - (Allow, 'Payment Update', 'Payment Update'), - (Allow, 'PostTransactions', 'PostTransactions'), - (Allow, 'Products', 'Products'), - (Allow, 'ProductsCreate', 'ProductsCreate'), - (Allow, 'ProductsDelete', 'ProductsDelete'), - (Allow, 'ProductsRetrieve', 'ProductsRetrieve'), - (Allow, 'ProductsUpdate', 'ProductsUpdate'), - (Allow, 'ProfitAndLoss', 'ProfitAndLoss'), - (Allow, 'Purchase', 'Purchase'), - (Allow, 'Purchase Create', 'Purchase Create'), - (Allow, 'Purchase Delete', 'Purchase Delete'), - (Allow, 'Purchase Post', 'Purchase Post'), - (Allow, 'Purchase Update', 'Purchase Update'), - (Allow, 'PurchaseReturn', 'PurchaseReturn'), - (Allow, 'PurchaseReturn Create', 'PurchaseReturn Create'), - (Allow, 'PurchaseReturn Delete', 'PurchaseReturn Delete'), - (Allow, 'PurchaseReturn Post', 'PurchaseReturn Post'), - (Allow, 'PurchaseReturn Update', 'PurchaseReturn Update'), - (Allow, 'Receipt', 'Receipt'), - (Allow, 'Receipt Create', 'Receipt Create'), - (Allow, 'Receipt Delete', 'Receipt Delete'), - (Allow, 'Receipt Post', 'Receipt Post'), - (Allow, 'Receipt Update', 'Receipt Update'), - (Allow, 'Verification', 'Verification'), - (Allow, 'Verification Create', 'Verification Create'), - (Allow, 'Verification Delete', 'Verification Delete'), - (Allow, 'Verification Post', 'Verification Post'), - (Allow, 'Verification Update', 'Verification Update') - ] + @property + def __acl__(self): + acl = [ + (Allow, Everyone, 'view'), + (Allow, Authenticated, 'post')] + for permission in Role.list(): + acl.append((Allow, permission.name, permission.name)) + print(acl) + return acl def __init__(self, request): pass \ No newline at end of file diff --git a/brewman/brewman/security.py b/brewman/brewman/security.py index 4d79c26c..1148c044 100644 --- a/brewman/brewman/security.py +++ b/brewman/brewman/security.py @@ -1,6 +1,19 @@ import uuid +from pyramid.security import Allow, ALL_PERMISSIONS from brewman.models.auth import User +class VoucherFactory(object): + __acl__ = [] + + def __init__(self, request): + self.request = request + + def __getitem__(self, key): + user = USERS[key] + user.__parent__ = self + user.__name__ = key + return user + def groupfinder(user_id, request): perms = [] if 'perms' in request.session: @@ -12,6 +25,7 @@ def groupfinder(user_id, request): perms.append(perm.name) perms = f7(perms) request.session['perms'] = perms + print(perms) return perms diff --git a/brewman/brewman/static/partial/account-detail.html b/brewman/brewman/static/partial/account-detail.html index baf3f151..f4fd02b7 100644 --- a/brewman/brewman/static/partial/account-detail.html +++ b/brewman/brewman/static/partial/account-detail.html @@ -1,4 +1,4 @@ -