Skip to content

Commit

Permalink
Data persistance if 'email_sent_for_modification' and 'changes_inform…
Browse files Browse the repository at this point in the history
…ation' change
  • Loading branch information
chloend committed Dec 15, 2024
1 parent 70cbadf commit 7989719
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lemarche/tenders/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,17 @@ def get_readonly_fields(self, request, obj=None):
def save_model(self, request, obj: Tender, form, change):
"""
Set Tender author on create
Set 'email_sent_for_modification' and 'changes_information' on update
"""
if not obj.id and not obj.author_id:
obj.author = request.user

if change and obj.email_sent_for_modification:
fields_to_update = ["email_sent_for_modification"]
if obj.changes_information:
fields_to_update.append("changes_information")
obj.save(update_fields=fields_to_update)

obj.save()

def save_formset(self, request, form, formset, change):
Expand Down

0 comments on commit 7989719

Please sign in to comment.