From 1a0b919c3d6e9d3a278105fe5209f6d3d4a70583 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Mon, 11 Aug 2025 16:26:17 +0200 Subject: [PATCH] Prevent submitting two talks with the same title on a cfp 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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/postgresqleu/confreg/views.py b/postgresqleu/confreg/views.py index 431cbd26..ff47bd78 100644 --- a/postgresqleu/confreg/views.py +++ b/postgresqleu/confreg/views.py @@ -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) -- 2.39.5