From 31627c3e86c416688cbb8e9c7fb2e504c257a4ef Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 12 Jun 2018 12:21:53 +0200 Subject: [PATCH] can now register in one boat class/type with M/F and mixed --- rowers/views.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/rowers/views.py b/rowers/views.py index 4c94ef91..acf450f5 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -13888,14 +13888,25 @@ def virtualevent_addboat_view(request,id=0): sex = 'male' if boattype in boattypes and boatclass in boatclasses: - messages.error(request,"You have already registered in that boat class/type") - url = reverse(virtualevent_view, - kwargs = { - 'id': race.id + # check if different sexes + therecords = records.filter( + boattype=boattype, + boatclass=boatclass) + + thesexes = [record.sex for record in therecords] + if sex in thesexes: + + messages.error( + request, + "You have already registered in that boat class/type" + ) + url = reverse(virtualevent_view, + kwargs = { + 'id': race.id } ) - return HttpResponseRedirect(url) + return HttpResponseRedirect(url) record = VirtualRaceResult( userid=r.id,