diff --git a/brewman/brewman/__init__.py b/brewman/brewman/__init__.py index fd936d63..8911c3a1 100644 --- a/brewman/brewman/__init__.py +++ b/brewman/brewman/__init__.py @@ -61,6 +61,10 @@ def main(global_config, **settings): config.add_route('account', '/Account') config.add_route('account_list', '/Accounts') + config.add_route('user_id', '/User/{id}') + config.add_route('user', '/User') + config.add_route('user_list', '/Users') + config.add_route('product_id', '/Product/{id}') config.add_route('product', '/Product') config.add_route('product_list', '/Products') @@ -109,10 +113,6 @@ def main(global_config, **settings): config.add_route('profit_loss', '/Reports/ProfitLoss') config.add_route('trial_balance', '/Reports/TrialBalance') - config.add_route('user_groups_id', '/Admin/UserGroups/{id}') - config.add_route('user_groups', '/Admin/UserGroups') - config.add_route('save_user_groups', '/Admin/UserGroupsSave') - config.add_route('group_roles_id', '/Admin/GroupRoles/{id}') config.add_route('group_roles', '/Admin/GroupRoles') config.add_route('save_group_roles', '/Admin/GroupRolesSave') diff --git a/brewman/brewman/models/auth.py b/brewman/brewman/models/auth.py index ff85a584..bcccdde2 100644 --- a/brewman/brewman/models/auth.py +++ b/brewman/brewman/models/auth.py @@ -73,6 +73,7 @@ class User(Base): self.name = name if self.password != password: self.password = encrypt(password) + self.locked_out = locked_out @classmethod def get_by_name(cls, name): diff --git a/brewman/brewman/static/partial/journal.html b/brewman/brewman/static/partial/journal.html new file mode 100644 index 00000000..4f471d12 --- /dev/null +++ b/brewman/brewman/static/partial/journal.html @@ -0,0 +1,89 @@ +
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+ + +
+ + +
+ +
+ +
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + +
DebitNameAmountDelete
{{journal.Debit | debit}}{{journal.Ledger.Name}}{{journal.Amount}} + +
+
+
+
+ + +
+ +
+
+
+ + + + +
+
+ Created on {{voucher.CreationDate}} and Last Edited on {{voucher.LastEditDate}} by {{voucher.User}}. Posted + by {{voucher.Poster}} +
+
diff --git a/brewman/brewman/static/partial/user-detail.html b/brewman/brewman/static/partial/user-detail.html new file mode 100644 index 00000000..2fd06dce --- /dev/null +++ b/brewman/brewman/static/partial/user-detail.html @@ -0,0 +1,49 @@ +
+ User Detail +
+ + +
+ +
+
+ +
+ + +
+ + +
+
+ +
+
+ +
+
+ +
+ + +
+
    +
  • + +
  • + +
+ +
+
+
+ +
+ +
+
+
diff --git a/brewman/brewman/static/partial/user-list.html b/brewman/brewman/static/partial/user-list.html new file mode 100644 index 00000000..955e8ba2 --- /dev/null +++ b/brewman/brewman/static/partial/user-list.html @@ -0,0 +1,21 @@ +Accounts + + + + + + + + + + + + + + + +
NameLocked OutGroups
{{item.Name}}{{item.LockedOut}} +
    +
  • {{group}}
  • +
+
diff --git a/brewman/brewman/static/scripts/angular_service.js b/brewman/brewman/static/scripts/angular_service.js index 84aaf022..1db9e564 100644 --- a/brewman/brewman/static/scripts/angular_service.js +++ b/brewman/brewman/static/scripts/angular_service.js @@ -108,3 +108,11 @@ overlord_service.factory('AccountType', ['$resource', function ($resource) { return $resource('/AccountTypes'); }]); +// TODO: Replace hardcoded url with route_url +overlord_service.factory('User', ['$resource', function ($resource) { + return $resource('/User/:id', + {id:'@UserID'}, { + query:{method:'GET', params:{list:true}, isArray:true} + }); +}]); + diff --git a/brewman/brewman/static/scripts/autocomplete.js b/brewman/brewman/static/scripts/autocomplete.js index 3b715de4..f62db7b8 100644 --- a/brewman/brewman/static/scripts/autocomplete.js +++ b/brewman/brewman/static/scripts/autocomplete.js @@ -1,8 +1,14 @@ var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filter', 'overlord.service']). config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { $routeProvider. + when('/Journal', {templateUrl: '/partial/journal.html', controller: JournalCtrl}). + when('/Journal/:id', {templateUrl: '/partial/journal.html', controller: JournalCtrl}). + when('/Accounts', {templateUrl: '/partial/account-list.html', controller: AccountListCtrl}). - when('/Account/:id', {templateUrl: '/partial/account-detail.html', controller: AccountCtrl}); + when('/Account/:id', {templateUrl: '/partial/account-detail.html', controller: AccountCtrl}). + + when('/Users', {templateUrl: '/partial/user-list.html', controller: UserListCtrl}). + when('/User/:id', {templateUrl: '/partial/user-detail.html', controller: UserCtrl}); // .otherwise({redirectTo: '/phones'}); $locationProvider.html5Mode(true); }]); @@ -32,12 +38,7 @@ function AutoComplete(matchFieldName, lookupURL) { function BaseCtrl($scope, Permission) { - $scope.auth = { - perms:Permission.query(), - isUserInRole:function (role) { - return $scope.auth.perms.indexOf(role) !== -1; - } - }; + $scope.perms = Permission.get(); $scope.toasts = []; $scope.clearToast = function(item) { diff --git a/brewman/brewman/static/scripts/journal.js b/brewman/brewman/static/scripts/journal.js index 4d6df122..7b7f0666 100644 --- a/brewman/brewman/static/scripts/journal.js +++ b/brewman/brewman/static/scripts/journal.js @@ -1,5 +1,13 @@ -function JournalCtrl($scope, Voucher) { - $scope.voucher = new Voucher(voucher); +function JournalCtrl($scope, $routeParams, $location, Voucher) { + console.log('loading') + + if (typeof $routeParams.id === 'undefined'){ + $scope.voucher = Voucher.get({type:'Journal'}); + } else { + console.log('getting voucher' + $routeParams.id) + $scope.voucher = Voucher.get({id:$routeParams.id}); + } + $scope.name = ''; $scope.debit = 1; $scope.addJournal = function () { @@ -32,8 +40,10 @@ $scope.$watch('voucher.Journals', function (journals, oldValue) { var amount = 0; - for (var i = 0, l = journals.length; i < l; i++) { - amount += (journals[i].Amount * journals[i].Debit); + if (typeof journals !== 'undefined') { + for (var i = 0, l = journals.length; i < l; i++) { + amount += (journals[i].Amount * journals[i].Debit); + } } $scope.amount = Math.abs(amount); }, true); @@ -49,6 +59,7 @@ $scope.save = function () { $scope.voucher.$save(function (u, putResponseHeaders) { $scope.toasts.push({Type:'Success', Message:u.Code}); + $location.path('/Journal/' + u.VoucherID) }, function (data, status) { $scope.toasts.push({Type:'Error', Message:data.data}); }); @@ -57,6 +68,8 @@ $scope.delete = function () { $scope.voucher.$delete(function (u, putResponseHeaders) { $scope.toasts.push({Type:'Success', Message:''}); + $location.path('/Journal') + }, function (data, status) { $scope.toasts.push({Type:'Error', Message:data.data}); }); diff --git a/brewman/brewman/static/scripts/user.js b/brewman/brewman/static/scripts/user.js new file mode 100644 index 00000000..6a531152 --- /dev/null +++ b/brewman/brewman/static/scripts/user.js @@ -0,0 +1,25 @@ +function UserListCtrl($scope, User) { + $scope.info = User.query(); +} + +function UserCtrl($scope, $routeParams, User) { + $scope.user = User.get({id: $routeParams.id}); + + $scope.save = function () { + $scope.user.$save(function (u, putResponseHeaders) { + $scope.toasts.push({Type:'Success', Message:u.Code}); + }, function (data, status) { + $scope.toasts.push({Type:'Error', Message:data.data}); + }); + }; + + $scope.delete = function () { + $scope.user.$delete(function (u, putResponseHeaders) { + $scope.toasts.push({Type:'Success', Message:''}); + }, function (data, status) { + $scope.toasts.push({Type:'Error', Message:data.data}); + }); + }; + $('#txtName').focus(); + +} diff --git a/brewman/brewman/templates/angular_base.mako b/brewman/brewman/templates/angular_base.mako index f44aa5ee..ebfcffe3 100644 --- a/brewman/brewman/templates/angular_base.mako +++ b/brewman/brewman/templates/angular_base.mako @@ -36,7 +36,11 @@ ${h.ScriptLink(request, 'angular_filter.js')} ${h.ScriptLink(request, 'angular_service.js')} ${h.ScriptLink(request, 'session.js')} + + ${h.ScriptLink(request, 'journal.js')} + ${h.ScriptLink(request, 'account.js')} + ${h.ScriptLink(request, 'user.js')} diff --git a/brewman/brewman/templates/auth/user_groups.pt b/brewman/brewman/templates/auth/user_groups.pt deleted file mode 100644 index 7a1e776a..00000000 --- a/brewman/brewman/templates/auth/user_groups.pt +++ /dev/null @@ -1,57 +0,0 @@ - - - ${h.JsLink(request, 'voucher.js')} - ${h.JsLink(request, 'user_groups.js')} - -
-
-

User Roles

-
- ${h.CsrfToken(request.session)} -

- ${user} -

-

- - - - - - - - - ${body} - - - ${footer} - -
Date
-

-

- ${h.SubmitButton('btnSave', 'Save', 'save')} -

- ${h.EndForm()} -
-
-
- \ No newline at end of file diff --git a/brewman/brewman/templates/base.mako b/brewman/brewman/templates/base.mako index 009f6de6..c1563aa9 100644 --- a/brewman/brewman/templates/base.mako +++ b/brewman/brewman/templates/base.mako @@ -35,6 +35,8 @@ ${h.ScriptLink(request, 'angular_filter.js')} ${h.ScriptLink(request, 'angular_service.js')} ${h.ScriptLink(request, 'session.js')} + ${h.ScriptLink(request, 'account.js')} + ${h.ScriptLink(request, 'user.js')} <%block name="header" /> diff --git a/brewman/brewman/templates/nav_bar/login.pt b/brewman/brewman/templates/nav_bar/login.pt index 31648a1b..bbbf29c7 100644 --- a/brewman/brewman/templates/nav_bar/login.pt +++ b/brewman/brewman/templates/nav_bar/login.pt @@ -3,10 +3,8 @@ @@ -15,10 +13,8 @@ @@ -28,7 +24,6 @@