diff --git a/tailbone/forms/core.py b/tailbone/forms/core.py index e9c33b11..5e079085 100644 --- a/tailbone/forms/core.py +++ b/tailbone/forms/core.py @@ -731,12 +731,26 @@ class Form(object): return True def render_field_readonly(self, field_name, **kwargs): + """ + Render the given field completely, but in read-only fashion. + + Note that this method will generate the wrapper div and label, as well + as the field value. + """ if field_name not in self.fields: return '' + + # TODO: fair bit of duplication here, should merge with deform.mako label = HTML.tag('label', self.get_label(field_name), for_=field_name) field = self.render_field_value(field_name) or '' field_div = HTML.tag('div', class_='field', c=[field]) - return HTML.tag('div', class_='field-wrapper {}'.format(field_name), c=[label, field_div]) + contents = [label, field_div] + + if self.has_helptext(field_name): + contents.append(HTML.tag('span', class_='instructions', + c=[self.render_helptext(field_name)])) + + return HTML.tag('div', class_='field-wrapper {}'.format(field_name), c=contents) def render_field_value(self, field_name): record = self.model_instance diff --git a/tailbone/views/purchasing/batch.py b/tailbone/views/purchasing/batch.py index 746ae4d3..ff7cec6b 100644 --- a/tailbone/views/purchasing/batch.py +++ b/tailbone/views/purchasing/batch.py @@ -628,7 +628,8 @@ class PurchasingBatchView(BatchMasterView): if row.status_code in (row.STATUS_INCOMPLETE, row.STATUS_CASE_QUANTITY_DIFFERS, row.STATUS_ORDERED_RECEIVED_DIFFER, - row.STATUS_TRUCKDUMP_UNCLAIMED): + row.STATUS_TRUCKDUMP_UNCLAIMED, + row.STATUS_TRUCKDUMP_PARTCLAIMED): return 'notice' def configure_row_form(self, f): diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index 664d7b03..4bbf9cc2 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -140,6 +140,7 @@ class ReceivingBatchView(PurchasingBatchView): 'id', 'vendor', 'truck_dump', + 'description', 'department', 'buyer', 'date_ordered', @@ -428,7 +429,7 @@ class ReceivingBatchView(PurchasingBatchView): truck_dump = batch.truck_dump_batch if not truck_dump: return "" - text = six.text_type(truck_dump) + text = "({}) {}".format(truck_dump.id_str, truck_dump.description or '') url = self.request.route_url('receiving.view', uuid=truck_dump.uuid) return tags.link_to(text, url) @@ -445,7 +446,7 @@ class ReceivingBatchView(PurchasingBatchView): if children: items = [] for child in children: - text = six.text_type(child) + text = "({}) {}".format(child.id_str, child.description or '') url = self.request.route_url('receiving.view', uuid=child.uuid) items.append(HTML.tag('li', c=[tags.link_to(text, url)])) contents.append(HTML.tag('ul', c=items)) @@ -704,20 +705,40 @@ class ReceivingBatchView(PurchasingBatchView): # claims if batch.is_truck_dump_parent(): - f.set_renderer('claims', self.render_row_claims) + f.set_renderer('claims', self.render_parent_row_claims) + f.set_helptext('claims', "Parent row is claimed by these child rows.") + elif batch.is_truck_dump_child(): + f.set_renderer('claims', self.render_child_row_claims) + f.set_helptext('claims', "Child row makes claims against these parent rows.") else: f.remove_field('claims') - def render_row_claims(self, row, field): + def render_parent_row_claims(self, row, field): items = [] for claim in row.claims: child_row = claim.claiming_row child_batch = child_row.batch text = child_batch.id_str + if child_batch.description: + text = "{} ({})".format(text, child_batch.description) + text = "{}, row {}".format(text, child_row.sequence) url = self.get_row_action_url('view', child_row) items.append(HTML.tag('li', c=[tags.link_to(text, url)])) return HTML.tag('ul', c=items) + def render_child_row_claims(self, row, field): + items = [] + for claim in row.truck_dump_claims: + parent_row = claim.claimed_row + parent_batch = parent_row.batch + text = parent_batch.id_str + if parent_batch.description: + text = "{} ({})".format(text, parent_batch.description) + text = "{}, row {}".format(text, parent_row.sequence) + url = self.get_row_action_url('view', parent_row) + items.append(HTML.tag('li', c=[tags.link_to(text, url)])) + return HTML.tag('ul', c=items) + def validate_row_form(self, form): # if normal validation fails, stop there