Skip to content

Commit

Permalink
Also hide message content on expire cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanw committed Mar 29, 2021
1 parent edf1ba8 commit df91534
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions froide_food/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ def depublish_old_reports():
from .models import FoodSafetyReport

old_reports = FoodSafetyReport.objects.get_expired_reports()

need_cleanup = old_reports.filter(attachment__can_approve=True)

for report in need_cleanup:
Expand All @@ -395,11 +394,17 @@ def depublish_old_reports():
report.attachment.approved = False
report.attachment.save()

FoiEvent.objects.create_event(
FoiEvent.EVENTS.ATTACHMENT_DEPUBLISHED,
report.message.request,
message=report.message,
user=None,
**{'reason': 'Automatically depublished after 5 years.'}
)
report.message.tags.add('food-depublished')
if report.message is None:
continue

report.message.tags.add('food-depublished')
report.message.content_hidden = True
report.message.save()

FoiEvent.objects.create_event(
FoiEvent.EVENTS.ATTACHMENT_DEPUBLISHED,
report.message.request,
message=report.message,
user=None,
**{'reason': 'Automatically depublished after 5 years.'}
)

0 comments on commit df91534

Please sign in to comment.