diff --git a/lametro/models.py b/lametro/models.py index 5b48b878e..51155dbeb 100644 --- a/lametro/models.py +++ b/lametro/models.py @@ -740,8 +740,21 @@ 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: + # We configure event agenda items to return LAMetroBill + # 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 agenda item will raise this exception. Skip + # adding those documents to the event packet. + continue + else: + bill_packet = BillPacket(bill=related_bill) + related.extend(bill_packet.related_files) return related