diff --git a/rowers/models.py b/rowers/models.py index 722e087c..991889c2 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -1329,6 +1329,7 @@ class VirtualRaceResult(models.Model): user = models.ForeignKey(Rower) username = models.CharField(max_length=150) workout = models.ForeignKey(Workout) + weightcategory = models.CharField(default="hwt",max_length=10) race = models.ForeignKey(VirtualRace) duration = models.TimeField(default=3600) boattype = models.CharField(choices=boattypes,max_length=40, diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index ce3ba8d5..cf3c36d3 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -493,6 +493,23 @@ def race_rower_status(r,race): return is_complete,has_registered +def race_can_edit(r,race): + if r.user != race.manager: + return False + else: + start_time = race.start_time + start_date = race.startdate + startdatetime = datetime.combine(start_date,start_time) + startdatetime = pytz.timezone(race.timezone).localize( + startdatetime + ) + if timezone.now(){{ race.name }} - {% if request.user == race.manager %} -
-

- Edit -

- {% endif %}
@@ -78,11 +72,14 @@ Submit Result {% endif %} {% if button == 'resubmitbutton' %} - Submit New Result + Submit New Result {% endif %} {% if button == 'withdrawbutton' %} Withdraw {% endif %} + {% if button == 'editbutton' %} + Edit Race + {% endif %} {% endfor %}

{% endif %} @@ -90,7 +87,41 @@

Results

+ {% if results %} + + + + + + + + + + + + + + + + + {% for result in results %} + + + + + + + + + + {% endfor %} + +
 Name   BoatRaw TimeIn ClassCorrected TimeCorrected Place
{{ forloop.counter }} + + {{ result.username }}{{ result.age }}{{ result.sex }}{{ result.weightcategory }}{{ result.boattype }}{{ result.duration |durationprint:"%H:%M:%S.%f" }}
+ {% else %} No results yet + {% endif %}

diff --git a/rowers/views.py b/rowers/views.py index 5c27dd0f..182f0640 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -13402,7 +13402,13 @@ def virtualevent_view(request,id=0): if race_can_withdraw(r,race): buttons += ['withdrawbutton'] - + + if race_can_edit(r,race): + buttons += ['editbutton'] + + results = VirtualRaceResult.objects.filter( + race=race + ).order_by("duration") return render(request,'virtualevent.html', { @@ -13410,6 +13416,7 @@ def virtualevent_view(request,id=0): 'coursediv':div, 'race':race, 'rower':r, + 'results':results, 'buttons':buttons, }) @@ -13550,6 +13557,20 @@ def virtualevent_edit_view(request,id=0): except VirtualRace.DoesNotExist: raise Http404("Virtual Race does not exist") + start_time = race.start_time + start_date = race.startdate + startdatetime = datetime.datetime.combine(start_date,start_time) + startdatetime = pytz.timezone(race.timezone).localize( + startdatetime + ) + + if timezone.now() > startdatetime: + messages.error(request,"You cannot edit a race after the start of the race window") + url = reverse(virtualevent_view, + kwargs={ + 'id':race.id, + }) + if request.method == 'POST': racecreateform = VirtualRaceForm(request.POST,instance=race) if racecreateform.is_valid(): @@ -13664,8 +13685,14 @@ def virtualevent_submit_result_view(request,id=0): for er in errors: messages.error(request,er) - # redirect to race page + url = reverse(virtualevent_view, + kwargs = { + 'id':race.id + }) + + return HttpResponseRedirect(url) + else: w_form = WorkoutRaceSelectForm(workoutdata=workoutdata)