Added client enable / disable / rename form.
Fixed compile error in Purchase Return
This commit is contained in:
parent
1a4a136058
commit
572a630520
@ -1,6 +1,6 @@
|
||||
CACHE MANIFEST
|
||||
|
||||
# version 2013-05-17.1
|
||||
# version 2013-05-18.1
|
||||
|
||||
CACHE:
|
||||
/partial/404.html
|
||||
@ -8,6 +8,7 @@ CACHE:
|
||||
/partial/account-list.html
|
||||
/partial/attendance.html
|
||||
/partial/cash-flow.html
|
||||
/partial/client-detail.html
|
||||
/partial/client-list.html
|
||||
/partial/closing-stock.html
|
||||
/partial/cost-center-detail.html
|
||||
|
41
brewman/brewman/static/partial/client-detail.html
Normal file
41
brewman/brewman/static/partial/client-detail.html
Normal file
@ -0,0 +1,41 @@
|
||||
<form method="post" class="form-horizontal">
|
||||
<legend>Client Detail</legend>
|
||||
<div class="control-group">
|
||||
<label for="txtCode" class="control-label">Code</label>
|
||||
|
||||
<div class="controls">
|
||||
<input type="text" id="txtCode" class="non-search-box" disabled="disabled" ng-model="client.Code"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label for="txtName" class="control-label">Name</label>
|
||||
|
||||
<div class="controls">
|
||||
<input type="text" id="txtName" ng-model="client.Name"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" ng-model="client.Enabled"> Enabled
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="txtOTP" class="control-label">OTP</label>
|
||||
|
||||
<div class="controls">
|
||||
<input type="text" id="txtOTP" ng-model="client.OTP"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button class="btn btn-primary" ng-click="save()">Save</button>
|
||||
<button class="btn btn-danger" ng-show="client.ClientID" ng-confirm title="Delete Client"
|
||||
action-text="Are you sure? This cannot be undone."
|
||||
action-button-text="Delete" action-function="delete()"> Delete
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
@ -11,7 +11,7 @@
|
||||
<tbody>
|
||||
<tr ng-repeat="item in info">
|
||||
<td>{{item.Code}}</td>
|
||||
<td>{{item.Name}}</td>
|
||||
<td><a href="{{item.Url}}">{{item.Name}}</a></td>
|
||||
<td>{{item.Enabled}}</td>
|
||||
<td>{{item.OTP}}</td>
|
||||
</tr>
|
||||
|
@ -1,10 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
var ClientCtrl = ['$scope', 'clients', function ($scope, clients) {
|
||||
var ClientListCtrl = ['$scope', 'clients', function ($scope, clients) {
|
||||
$scope.info = clients;
|
||||
}]
|
||||
|
||||
ClientCtrl.resolve = {
|
||||
ClientListCtrl.resolve = {
|
||||
clients:['$q', 'Client', function ($q, Client) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
@ -16,3 +16,41 @@ ClientCtrl.resolve = {
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
var ClientCtrl = ['$scope', '$location', 'client', function ($scope, $location, client) {
|
||||
$scope.client = client;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.client.$save(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type:'Success', Message:''});
|
||||
$location.path('/Clients')
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type:'Error', Message:data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.client.$delete(function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type:'Success', Message:''});
|
||||
$location.path('/Clients')
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type:'Error', Message:data.data});
|
||||
});
|
||||
};
|
||||
$('#txtName').focus();
|
||||
|
||||
}]
|
||||
|
||||
ClientCtrl.resolve = {
|
||||
client:['$q', '$route', 'Client', function ($q, $route, Client) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var id = $route.current.params.id;
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
Client.get({id: id}, successCb);
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
@ -86,7 +86,8 @@ var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filte
|
||||
when('/Group', {templateUrl: '/partial/group-detail.html', controller: GroupCtrl, resolve: GroupCtrl.resolve}).
|
||||
when('/Group/:id', {templateUrl: '/partial/group-detail.html', controller: GroupCtrl, resolve: GroupCtrl.resolve}).
|
||||
|
||||
when('/Clients', {templateUrl: '/partial/client-list.html', controller: ClientCtrl, resolve: ClientCtrl.resolve}).
|
||||
when('/Clients', {templateUrl: '/partial/client-list.html', controller: ClientListCtrl, resolve: ClientListCtrl.resolve}).
|
||||
when('/Client/:id', {templateUrl: '/partial/client-detail.html', controller: ClientCtrl, resolve: ClientCtrl.resolve}).
|
||||
|
||||
otherwise({templateUrl: '/partial/404.html'});
|
||||
$locationProvider.html5Mode(true).hashPrefix('!');
|
||||
|
@ -3,9 +3,10 @@ from pyramid.response import Response
|
||||
|
||||
from pyramid.view import view_config
|
||||
import transaction
|
||||
from brewman.models import DBSession
|
||||
from brewman.models.auth import Client
|
||||
|
||||
from brewman.models.validation_exception import ValidationError, TryCatchFunction
|
||||
from brewman.models.validation_exception import TryCatchFunction
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='client_list', renderer='brewman:templates/angular_base.mako',
|
||||
@ -18,7 +19,28 @@ def html(request):
|
||||
@TryCatchFunction
|
||||
def update(request):
|
||||
item = Client.by_id(uuid.UUID(request.matchdict['id']))
|
||||
if item.otp is None:
|
||||
item.enabled = request.json_body['Enabled']
|
||||
item.name = request.json_body['Name']
|
||||
transaction.commit()
|
||||
return {}
|
||||
|
||||
|
||||
@view_config(request_method='DELETE', route_name='api_client_id', renderer='json', permission='Clients')
|
||||
def delete(request):
|
||||
id = request.matchdict.get('id', None)
|
||||
if id is None:
|
||||
response = Response("Client is Null")
|
||||
response.status_int = 500
|
||||
return response
|
||||
|
||||
client = Client.by_id(id)
|
||||
if client.enabled:
|
||||
response = Response("Client is enabled and cannot be deleted")
|
||||
response.status_int = 500
|
||||
return response
|
||||
else:
|
||||
DBSession.delete(client)
|
||||
transaction.commit()
|
||||
return {}
|
||||
|
||||
@ -29,5 +51,14 @@ def show_list(request):
|
||||
clients = []
|
||||
for item in list:
|
||||
clients.append(
|
||||
{'ClientID': item.id, 'Code': item.code, 'Name': item.name, 'Enabled': item.enabled, 'OTP': item.otp})
|
||||
{'ClientID': item.id, 'Code': item.code, 'Name': item.name, 'Enabled': item.enabled, 'OTP': item.otp,
|
||||
'Url': request.route_url('client_id', id=item.id)})
|
||||
return clients
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='api_client_id', renderer='json', permission='Clients')
|
||||
def show_id(request):
|
||||
item = Client.by_id(request.matchdict['id'])
|
||||
return {'ClientID': item.id, 'Code': item.code, 'Name': item.name, 'Enabled': item.enabled, 'OTP': item.otp}
|
||||
|
||||
|
||||
|
@ -115,7 +115,7 @@ def purchase_return_update_journals(voucher, journals):
|
||||
journals[ledger.id].amount += round(item.amount, 2)
|
||||
else:
|
||||
journals[ledger.id] = Journal(debit=-1, cost_center_id=ledger.costcenter_id, ledger_id=ledger.id,
|
||||
amount=round(item.amount), 2)
|
||||
amount=round(item.amount, 2))
|
||||
journals[otherLedger.id] = Journal(debit=1, cost_center_id=otherLedger.costcenter_id, ledger_id=otherLedger.id,
|
||||
amount=amount)
|
||||
for i in range(len(voucher.journals), 0, -1):
|
||||
|
@ -8,6 +8,7 @@ pyramid.debug_routematch = false
|
||||
pyramid.default_locale_name = en
|
||||
# pyramid.includes =
|
||||
# pyramid_debugtoolbar
|
||||
# sqlalchemy.url = postgresql://hops:123456@localhost:8765/hops
|
||||
sqlalchemy.url = sqlite:///%(here)s/database/brewman.db
|
||||
|
||||
[server:main]
|
||||
|
Loading…
x
Reference in New Issue
Block a user