Added TryCatch to get_grid as it may generate errors.

This commit is contained in:
Tanshu 2012-12-18 17:55:57 +05:30
parent f9bd95733b
commit d28029672f

View File

@ -6,17 +6,20 @@ import uuid
from pyramid.view import view_config from pyramid.view import view_config
from brewman.models import DBSession from brewman.models import DBSession
from brewman.models.validation_exception import TryCatchFunction
from brewman.models.voucher import Voucher, Journal, VoucherType from brewman.models.voucher import Voucher, Journal, VoucherType
@view_config(route_name='api_issues_grid', request_param='Source', renderer='json', permission='Issue') @view_config(route_name='api_issues_grid', request_param='Source', renderer='json', permission='Issue')
@TryCatchFunction
def grid_date(request): def grid_date(request):
date = datetime.datetime.strptime(request.matchdict['date'], '%d-%b-%Y') date = datetime.datetime.strptime(request.matchdict['date'], '%d-%b-%Y')
return get_grid(date, uuid.UUID(request.GET['Source']), uuid.UUID(request.GET['Destination'])) return get_grid(date, uuid.UUID(request.GET['Source']), uuid.UUID(request.GET['Destination']))
@view_config(route_name='api_issues_grid', renderer='json', permission='Issue') @view_config(route_name='api_issues_grid', renderer='json', permission='Issue')
@TryCatchFunction
def grid_voucher(request): def grid_voucher(request):
voucher = Voucher.by_id(uuid.UUID(request.matchdict['date'])) voucher = Voucher.by_id(uuid.UUID(request.matchdict['date']))
source = [j.cost_center_id for j in voucher.journals if j.debit == -1] source = [j.cost_center_id for j in voucher.journals if j.debit == -1]