Fix editing of submitted sessions on cfp
authorMagnus Hagander <magnus@hagander.net>
Tue, 7 Oct 2025 12:03:03 +0000 (14:03 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 7 Oct 2025 12:03:03 +0000 (14:03 +0200)
Commit 1a0b919c added verification that one didn't submit the same
session twice, but as a side-effcect that also prevented editing an
existing session.

Reported by Andrey Borodin

postgresqleu/confreg/views.py

index 6e6f1673efa3ce363aa6fb5f165f60bc904d6cb9..fc510c9a6833f3df43b4c1edf763ad489c0ac8f4 100644 (file)
@@ -1976,7 +1976,10 @@ def callforpapers_edit(request, confname, sessionid):
         form = CallForPapersForm(speaker, data=request.POST, instance=session, initial=initial)
         if form.is_valid():
             with transaction.atomic():
-                if ConferenceSession.objects.filter(conference=conference, speaker=speaker, title=form.cleaned_data['title']).exists():
+                q = ConferenceSession.objects.filter(conference=conference, speaker=speaker, title=form.cleaned_data['title'])
+                if session.pk:
+                    q = q.exclude(pk=session.pk)
+                if q.exists():
                     form.add_error('title', "You have already submitted a session with title '{}' to this conference.".format(session.title))
                 else:
                     form.save()