Fix batch links when viewing purchase object
This commit is contained in:
parent
0171f3ebba
commit
3820891277
|
@ -45,6 +45,11 @@ class BatchesFieldRenderer(fa.FieldRenderer):
|
||||||
|
|
||||||
enum = self.request.rattail_config.get_enum()
|
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):
|
def render(batch):
|
||||||
if batch.executed:
|
if batch.executed:
|
||||||
actor = batch.executed_by
|
actor = batch.executed_by
|
||||||
|
@ -55,7 +60,7 @@ class BatchesFieldRenderer(fa.FieldRenderer):
|
||||||
display = '{} ({} by {}){}'.format(batch.id_str,
|
display = '{} ({} by {}){}'.format(batch.id_str,
|
||||||
enum.PURCHASE_BATCH_MODE[batch.mode],
|
enum.PURCHASE_BATCH_MODE[batch.mode],
|
||||||
actor, pending)
|
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]
|
items = [HTML.tag('li', c=render(batch)) for batch in batches]
|
||||||
return HTML.tag('ul', c=items)
|
return HTML.tag('ul', c=items)
|
||||||
|
|
Loading…
Reference in a new issue