Skip to content

Commit a9fe7da

Browse files
Merge pull request #2519 from IFRCGo/fix/dref-final-report-active
Set dref to active for unpublished dref final reports from admin panel
2 parents 464d3a6 + 6d21670 commit a9fe7da

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

dref/admin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ def get_queryset(self, request):
228228
)
229229
)
230230

231+
# NOTE: If the Dref Final report is unpublished, set Dref related to it as active
232+
def save_model(self, request, obj, form, change):
233+
if not obj.is_published and obj.dref:
234+
obj.dref.is_active = True
235+
obj.dref.save(update_fields=["is_active"])
236+
super().save_model(request, obj, form, change)
237+
231238

232239
@admin.register(ProposedAction)
233240
class ProposedActionAdmin(ReadOnlyMixin, admin.ModelAdmin):

0 commit comments

Comments
 (0)