From 7931a964605de67d5fedd64d84e8f4c4fb1c3064 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sat, 14 Oct 2017 12:08:22 +0000 Subject: [PATCH] Changed the telechat date admin to use the 'initial-date' field value instead of the now nonfunctional form.initial dictionary. This may need revisiting under Django 1.11, which has an official api to grab a form's initial values. This fixes a server 500 error on trying to save a non-default telechat date. - Legacy-Id: 14210 --- ietf/iesg/admin.py | 4 +++- ietf/iesg/tests.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ietf/iesg/admin.py b/ietf/iesg/admin.py index bdace1b36..9ffb352c4 100644 --- a/ietf/iesg/admin.py +++ b/ietf/iesg/admin.py @@ -1,5 +1,7 @@ from django.contrib import admin +import debug # pyflakes:ignore + from ietf.doc.models import TelechatDocEvent from ietf.iesg.models import TelechatDate, TelechatAgendaItem @@ -14,7 +16,7 @@ class TelechatDateAdmin(admin.ModelAdmin): ''' super(TelechatDateAdmin, self).save_model(request, obj, form, change) if 'date' in form.changed_data: - old_date = form.initial['date'] + old_date = form.data['initial-date'] new_date = form.cleaned_data['date'] TelechatDocEvent.objects.filter(telechat_date=old_date).update(telechat_date=new_date) diff --git a/ietf/iesg/tests.py b/ietf/iesg/tests.py index fe7a320ce..006c75e84 100644 --- a/ietf/iesg/tests.py +++ b/ietf/iesg/tests.py @@ -415,7 +415,7 @@ class IESGAgendaTests(TestCase): telechat_date = TelechatDate.objects.get(date=draft.telechat_date()) url = urlreverse('admin:iesg_telechatdate_change', args=(telechat_date.id,)) self.client.login(username="secretary", password="secretary+password") - r = self.client.post(url, {'date':today.strftime('%Y-%m-%d')}) + r = self.client.post(url, {'initial-date': telechat_date.date.strftime('%Y-%m-%d'), 'date':today.strftime('%Y-%m-%d')}) self.assertRedirects(r, urlreverse('admin:iesg_telechatdate_changelist')) self.assertEqual(draft.telechat_date(),today)