Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When changing a TelechatDate in the admin interface, retain all docum…
…ent associations. Fixes #1349. Commit ready for merge. - Legacy-Id: 13559
- Loading branch information
Showing
3 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
from django.contrib import admin | ||
|
||
from ietf.doc.models import TelechatDocEvent | ||
from ietf.iesg.models import TelechatDate, TelechatAgendaItem | ||
|
||
class TelechatAgendaItemAdmin(admin.ModelAdmin): | ||
pass | ||
admin.site.register(TelechatAgendaItem, TelechatAgendaItemAdmin) | ||
|
||
admin.site.register(TelechatDate) | ||
class TelechatDateAdmin(admin.ModelAdmin): | ||
def save_model(self, request, obj, form, change): | ||
'''If changing a Telechat date, change all related TelechatDocEvents, which is how | ||
documents are related to the Telechat | ||
''' | ||
super(TelechatDateAdmin, self).save_model(request, obj, form, change) | ||
if 'date' in form.changed_data: | ||
old_date = form.initial['date'] | ||
new_date = form.cleaned_data['date'] | ||
TelechatDocEvent.objects.filter(telechat_date=old_date).update(telechat_date=new_date) | ||
|
||
admin.site.register(TelechatDate, TelechatDateAdmin) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters