Prevent submitting two talks with the same title on a cfp
authorMagnus Hagander <magnus@hagander.net>
Mon, 11 Aug 2025 14:26:17 +0000 (16:26 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 11 Aug 2025 14:26:17 +0000 (16:26 +0200)
Submissions *by the same speaker* should have different titles. A common
case for these duplicates are flaky networks where one hits submit more
than once, and then we really want just one of the two entries to go
through.

postgresqleu/confreg/views.py

index 431cbd265567182ef4d213d8f9e3f887760ec0db..ff47bd78e0cbba11f6686fe9db971448aba29d80 100644 (file)
@@ -1969,10 +1969,14 @@ def callforpapers_edit(request, confname, sessionid):
         # Save it!
         form = CallForPapersForm(speaker, data=request.POST, instance=session, initial=initial)
         if form.is_valid():
-            form.save()
+            with transaction.atomic():
+                if ConferenceSession.objects.filter(conference=conference, speaker=speaker, title=form.cleaned_data['title']).exists():
+                    form.add_error('title', "You have already submitted a session with title '{}' to this conference.".format(session.title))
+                else:
+                    form.save()
+                    messages.info(request, "Your session '%s' has been saved!" % session.title)
 
-            messages.info(request, "Your session '%s' has been saved!" % session.title)
-            return HttpResponseRedirect("../")
+                    return HttpResponseRedirect("../")
     else:
         # GET --> render empty form
         form = CallForPapersForm(speaker, instance=session, initial=initial)