From 1c82b29f49789cff66c133d0a3b71121083d663e Mon Sep 17 00:00:00 2001 From: hancush Date: Mon, 3 Aug 2020 15:41:09 -0500 Subject: [PATCH 1/3] Handle private bills during event packet build Closes https://github.com/datamade/la-metro-dashboard/issues/46 --- lametro/models.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lametro/models.py b/lametro/models.py index 5b48b878e..e75b55c44 100644 --- a/lametro/models.py +++ b/lametro/models.py @@ -740,8 +740,15 @@ def related_files(self): for item in agenda_items: for entity in item.related_entities.filter(bill__isnull=False): - bill_packet = BillPacket(bill=entity.bill) - related.extend(bill_packet.related_files) + try: + related_bill = entity.bill + except LAMetroBill.DoesNotExist: + # If this exception occurs, the related bill is private. + # Skip it. + continue + else: + bill_packet = BillPacket(bill=related_bill) + related.extend(bill_packet.related_files) return related From 78c9bf90716e11d3e7e7c39f828bee75833366b8 Mon Sep 17 00:00:00 2001 From: hancush Date: Tue, 4 Aug 2020 11:34:41 -0500 Subject: [PATCH 2/3] Expand error handling comment --- lametro/models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lametro/models.py b/lametro/models.py index e75b55c44..56e14de83 100644 --- a/lametro/models.py +++ b/lametro/models.py @@ -743,8 +743,14 @@ def related_files(self): try: related_bill = entity.bill except LAMetroBill.DoesNotExist: - # If this exception occurs, the related bill is private. - # Skip it. + # We configure event agenda items to return LAMetroBill + # objects. Sometimes, agendas items concern bills that do + # not meet criteria for display, e.g., the bill is private + # or it does not appear on a published agenda. (See the + # LAMetroBill manager for an exhaustive list of display + # criteria.) In this case, trying to access the bill via + # the event related entity will raise this exception. Skip + # adding those documents to the event packet. continue else: bill_packet = BillPacket(bill=related_bill) From e8104c511173e8043c14ea0b8e840699e8651b4c Mon Sep 17 00:00:00 2001 From: hancush Date: Tue, 4 Aug 2020 11:36:44 -0500 Subject: [PATCH 3/3] Language is hard, wowo --- lametro/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lametro/models.py b/lametro/models.py index 56e14de83..51155dbeb 100644 --- a/lametro/models.py +++ b/lametro/models.py @@ -744,12 +744,12 @@ def related_files(self): related_bill = entity.bill except LAMetroBill.DoesNotExist: # We configure event agenda items to return LAMetroBill - # objects. Sometimes, agendas items concern bills that do + # objects. Sometimes, agenda items concern bills that do # not meet criteria for display, e.g., the bill is private # or it does not appear on a published agenda. (See the # LAMetroBill manager for an exhaustive list of display # criteria.) In this case, trying to access the bill via - # the event related entity will raise this exception. Skip + # the event agenda item will raise this exception. Skip # adding those documents to the event packet. continue else: