Fix batch links when viewing purchase object

This commit is contained in:
Lance Edgar 2017-08-01 14:48:22 -05:00
parent 0171f3ebba
commit 3820891277

View file

@ -45,6 +45,11 @@ class BatchesFieldRenderer(fa.FieldRenderer):
enum = self.request.rattail_config.get_enum()
routes = {
enum.PURCHASE_BATCH_MODE_ORDERING: 'ordering.view',
enum.PURCHASE_BATCH_MODE_RECEIVING: 'receiving.view',
}
def render(batch):
if batch.executed:
actor = batch.executed_by
@ -55,7 +60,7 @@ class BatchesFieldRenderer(fa.FieldRenderer):
display = '{} ({} by {}){}'.format(batch.id_str,
enum.PURCHASE_BATCH_MODE[batch.mode],
actor, pending)
return tags.link_to(display, self.request.route_url('purchases.batch.view', uuid=batch.uuid))
return tags.link_to(display, self.request.route_url(routes[batch.mode], uuid=batch.uuid))
items = [HTML.tag('li', c=render(batch)) for batch in batches]
return HTML.tag('ul', c=items)