diff --git a/rowers/forms.py b/rowers/forms.py index d6dc0cdd..c73770fc 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -1,6 +1,9 @@ from django import forms from django.contrib.admin.widgets import FilteredSelectMultiple -from rowers.models import Workout,Rower,Team,PlannedSession,GeoCourse +from rowers.models import ( + Workout,Rower,Team,PlannedSession,GeoCourse, + VirtualRace,VirtualRaceResult,IndoorVirtualRaceResult + ) from rowers.rows import validate_file_extension,must_be_csv,validate_image_extension,validate_kml from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User @@ -16,6 +19,7 @@ from utils import landingpages from metrics import axes + # login form class LoginForm(forms.Form): username = forms.CharField() @@ -254,6 +258,10 @@ class UploadOptionsForm(forms.Form): makeprivate = forms.BooleanField(initial=False,required=False, label='Make Workout Private') + submitrace = forms.ModelChoiceField(queryset=VirtualRace.objects.all(), + label='Submit as Race Result', + required=False) + landingpage = forms.ChoiceField(choices=nextpages, initial='workout_edit_view', label='After Upload, go to') @@ -261,6 +269,28 @@ class UploadOptionsForm(forms.Form): class Meta: fields = ['make_plot','plottype','upload_toc2','makeprivate'] + def __init__(self, *args, **kwargs): + self.request = kwargs.pop('request',None) + super(UploadOptionsForm, self).__init__(*args, **kwargs) + r = Rower.objects.get(user=self.request.user) + races = VirtualRace.objects.filter( + registration_closure__gt=timezone.now(), + sessiontype='indoorrace') + registrations = IndoorVirtualRaceResult.objects.filter( + race__in = races, + userid = r.id) + + raceids = [r.race.id for r in registrations] + + races = VirtualRace.objects.filter( + id__in=raceids + ) + + if races: + self.fields['submitrace'].queryset = races + else: + del self.fields['submitrace'] + # The form to indicate additional actions to be performed immediately # after a successful upload. This version allows the Team manager to select # a team member diff --git a/rowers/models.py b/rowers/models.py index 10b84581..09a61c8b 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -2422,6 +2422,8 @@ class VirtualRaceResult(models.Model): verbose_name='Gender') age = models.IntegerField(null=True) + emailnotifications = models.BooleanField(default=True, + verbose_name = 'Receive race notifications by email') def __unicode__(self): rr = Rower.objects.get(id=self.userid) @@ -2472,6 +2474,8 @@ class IndoorVirtualRaceResult(models.Model): verbose_name='Gender') age = models.IntegerField(null=True) + emailnotifications = models.BooleanField(default=True, + verbose_name = 'Receive race notifications by email') def __unicode__(self): rr = Rower.objects.get(id=self.userid) @@ -2686,7 +2690,7 @@ class WorkoutForm(ModelForm): startdate__lte=workout.date, enddate__gte=workout.date, ).order_by("preferreddate","startdate","enddate").exclude( - sessiontype='race') + sessiontype__in=['race','indoorrace']) if not sps: del self.fields['plannedsession'] diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index c9b9232f..c152305c 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -20,7 +20,7 @@ from rowers.models import ( Rower, Workout,Team, GeoCourse, TrainingMicroCycle,TrainingMesoCycle,TrainingMacroCycle, TrainingPlan,PlannedSession,VirtualRaceResult,CourseTestResult, - get_course_timezone, IndoorVirtualRaceResult + get_course_timezone, IndoorVirtualRaceResult,VirtualRace ) from rowers.courses import get_time_course @@ -33,6 +33,41 @@ import iso8601 from iso8601 import ParseError from rowers.tasks import handle_check_race_course +def get_indoorraces(workout): + races1 = VirtualRace.objects.filter( + registration_closure__gt=timezone.now(), + sessiontype='indoorrace', + startdate__lte=workout.date, + enddate__gte=workout.date, + sessionmode='distance', + sessionvalue=workout.distance) + + + if workout.duration.second != 0 and workout.duration.microsecond != 0: + duration = 60*workout.duration.hour+workout.duration.minute + + + races2 = VirtualRace.objects.filter( + registration_closure__gt=timezone.now(), + sessiontype='indoorrace', + startdate__lte=workout.date, + enddate__gte=workout.date, + sessionmode='time', + sessionvalue=duration) + + races = races1 | races2 + else: + races = races1 + + registrations = IndoorVirtualRaceResult.objects.filter( + race__in = races, + userid=workout.user.id) + + races = [r.race for r in registrations] + + + return races + def get_todays_micro(plan,thedate=date.today()): thismicro = None @@ -729,10 +764,11 @@ def race_can_submit(r,race): if is_complete == False: return True else: - return False + return True else: return False + print 'pop' return False def race_can_resubmit(r,race): @@ -970,6 +1006,7 @@ def add_workout_indoorrace(ws,race,r,recordid=0): record.duration = ws[0].duration + if ws[0].weightcategory != record.weightcategory: errors.append('Your workout weight category did not match the weight category you registered') return 0,comments, errors,0 @@ -993,7 +1030,7 @@ def add_workout_indoorrace(ws,race,r,recordid=0): record.coursecompleted = True record.workoutid = ws[0].id record.save() - + add_workouts_plannedsession(ws,race,r) diff --git a/rowers/tasks.py b/rowers/tasks.py index 374cd509..d1f6855e 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -740,6 +740,66 @@ def handle_updatedps(useremail, workoutids, debug=False,**kwargs): # send email when a breakthrough workout is uploaded +@app.task +def handle_sendemail_raceregistration( + useremail, username, registeredname, racename, raceid, **kwargs): + + if 'debug' in kwargs: + debug = kwargs['debug'] + else: + debug = True + + subject = "A new competitor has registered for virtual race {n}".format( + n = racename + ) + + from_email = 'Rowsandall ' + + d = { + 'username':username, + 'registeredname':registeredname, + 'siteurl':siteurl, + 'racename':racename, + 'raceid':raceid, + } + + res = send_template_email(from_email,[useremail], + subject, + 'raceregisteredemail.html', + d,**kwargs) + + return 1 + +@app.task +def handle_sendemail_racesubmission( + useremail, username, registeredname, racename, raceid, **kwargs): + + if 'debug' in kwargs: + debug = kwargs['debug'] + else: + debug = True + + subject = "A new result has been submitted for virtual race {n}".format( + n = racename + ) + + from_email = 'Rowsandall ' + + d = { + 'username':username, + 'siteurl':siteurl, + 'registeredname':registeredname, + 'racename':racename, + 'raceid':raceid, + } + + res = send_template_email(from_email,[useremail], + subject, + 'racesubmissionemail.html', + d,**kwargs) + + return 1 + @app.task def handle_send_disqualification_email( useremail,username,reason,message, racename, **kwargs): @@ -758,6 +818,7 @@ def handle_send_disqualification_email( d = { 'username':username, 'reason':reason, + 'siteurl':siteurl, 'message': strip_tags(message), 'racename':racename, } diff --git a/rowers/templates/disqualificationemail.html b/rowers/templates/disqualificationemail.html index 1c7dca91..c72af9fc 100644 --- a/rowers/templates/disqualificationemail.html +++ b/rowers/templates/disqualificationemail.html @@ -4,7 +4,8 @@

Unfortunately, the result that you have submitted - for the virtual race {{ racename }} + for the virtual race + {{ racename }} has been rejected by the race organizer.

diff --git a/rowers/templates/menu_racing.html b/rowers/templates/menu_racing.html index 4a06ef2d..62c7c54f 100644 --- a/rowers/templates/menu_racing.html +++ b/rowers/templates/menu_racing.html @@ -15,15 +15,82 @@  New Indoor Race + {% if race %} + {% if reguest.user.is_anonymous %} +
  • + {% if race.sessiontype == 'race' %} + +  Register + {% else %} + +  Register + {% endif %} +
  • + {% endif %} + {% for button in buttons %} + {% if button == 'registerbutton' %} +
  • + {% if race.sessiontype == 'race' %} + +  Register + {% else %} + +  Register + {% endif %} +
  • + {% endif %} + {% if button == 'submitbutton' %} +
  • + +  Submit Workout +
  • +
  • + +  Upload your race result + +
  • +
  • + +  Enter Result + +
  • + {% endif %} + {% if button == 'resubmitbutton' %} +
  • + Submit New Result +
  • + {% endif %} + {% if button == 'withdrawbutton' %} + +  Withdraw + {% endif %} + {% if button == 'adddisciplinebutton' %} + +  Register New Boat + + {% endif %} + {% if button == 'editbutton' %} +
  • + {% if race.sessiontype == 'race' %} +  Edit Race + + {% else %} +  Edit Race + + {% endif %} +
  • + {% endif %} + {% endfor %} + {% endif %}
  • -  Courses +  Courses
  • {% if course %}
  • - +
    • diff --git a/rowers/templates/racelist.html b/rowers/templates/racelist.html index a0f96927..02e999a0 100644 --- a/rowers/templates/racelist.html +++ b/rowers/templates/racelist.html @@ -37,10 +37,10 @@ {% if rower %} {% if race|can_register:rower %}   - {% elif race|can_submit:rower %} -   {% elif race|race_complete:rower %}   + {% elif race|can_submit:rower %} +   {% elif race|future_registered:rower %}   {% elif race|past_not_registered:rower %} diff --git a/rowers/templates/raceregisteredemail.html b/rowers/templates/raceregisteredemail.html new file mode 100644 index 00000000..a06cf100 --- /dev/null +++ b/rowers/templates/raceregisteredemail.html @@ -0,0 +1,25 @@ +{% extends "emailbase.html" %} +{% block body %} +

      Dear {{ username }},

      + +

      + A new competitor has registered for the race {{ racename }}: {{ registeredname }} +

      + + +

      + You can check race participants and results on the race page on Rowsandall: + {{ racename }} +

      + +

      + You are receiving this email because you are on the start list for this race. + If you do not wish to receive these notifications, you can switch them off + throught the link above. +

      + +

      + Best Regards, the Rowsandall Team +

      +{% endblock %} + diff --git a/rowers/templates/racesubmissionemail.html b/rowers/templates/racesubmissionemail.html new file mode 100644 index 00000000..2337bbd1 --- /dev/null +++ b/rowers/templates/racesubmissionemail.html @@ -0,0 +1,25 @@ +{% extends "emailbase.html" %} +{% block body %} +

      Dear {{ username }},

      + +

      + One of your competitors, {{ registeredname }}, has submitted a result for {{ racename }} +

      + + +

      + Check out the results on the race page! + {{ racename }} +

      + +

      + You are receiving this email because you are on the start list for this race. + If you do not wish to receive these notifications, you can switch them off + throught the link above. +

      + +

      + Best Regards, the Rowsandall Team +

      +{% endblock %} + diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index 97e94b79..430aa7e7 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -39,8 +39,12 @@

      + data-url="{{ request.build_absolute_uri }}" + {% if race.sessiontype == 'race' %} + data-text="@rowsandall #rowingdata Participate in virtual race '{{ race.name }}'">Tweet +{% else %} +data-text="@rowsandall #rowingdata Participate in Indoor Rowing virtual race '{{ race.name }}'">Tweet +{% endif %}

      @@ -151,7 +155,37 @@

      {% endif %} {% if button == 'submitbutton' %} - Submit Result + + + + + + + + + + {% if race.sessiontype == 'indoorrace' %} + + + + + {% endif %} +
      + Submit Workout + + Submit a workout that is already on the site as your race result +
      + Upload your race result + + Upload a new workout to the site and submit it as a result. You + need a workout data file. +
      + Enter your race result manually + + If you don't have a data file, enter the results + manually. If you have a photo of the monitor with the + result, it is recommended to add this to the workout. +
      {% endif %} {% if button == 'resubmitbutton' %}

      @@ -283,7 +317,7 @@ {% csrf_token %} - +

    • {% endif %} @@ -327,6 +361,31 @@ {% endif %} + {% for record in records %} + {% if record.userid == request.user.rower.id %} + {% if race.sessiontype == 'race' %} + {% if record.emailnotifications %} + + Unsubscribe from race notifications by email + + {% else %} + + Subscribe to race notifications by email + + {% endif %} + {% else %} + {% if record.emailnotifications %} + + Unsubscribe from race notifications by email + + {% else %} + + Subscribe to race notifications by email + + {% endif %} + {% endif %} + {% endif %} + {% endfor %}
    • diff --git a/rowers/templates/workout_form.html b/rowers/templates/workout_form.html index ce0e29e6..986878ec 100644 --- a/rowers/templates/workout_form.html +++ b/rowers/templates/workout_form.html @@ -118,6 +118,16 @@ $('#id_workouttype').change();

    • + {% if indoorraces %} +
    • +

      Racing

      + {% for race in indoorraces %} +

      + Submit this to Indoor Race {{ race.name }} +

      + {% endfor %} +
    • + {% endif %} {% if mapdiv %}
    • diff --git a/rowers/urls.py b/rowers/urls.py index 4948b2b4..76ffa360 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -144,6 +144,10 @@ urlpatterns = [ url(r'^virtualevents$',views.virtualevents_view), url(r'^virtualevent/create$',views.virtualevent_create_view), url(r'^virtualevent/createindoor$',views.indoorvirtualevent_create_view), + url(r'^raceregistration/togglenotification/(?P\d+)/$', + views.virtualevent_toggle_email_view), + url(r'^indoorraceregistration/togglenotification/(?P\d+)/$', + views.indoorvirtualevent_toggle_email_view), url(r'^virtualevent/(?P\d+)$',views.virtualevent_view), url(r'^virtualevent/(?P\d+)/edit$',views.virtualevent_edit_view), url(r'^virtualevent/(?P\d+)/editindoor$',views.indoorvirtualevent_edit_view), diff --git a/rowers/views.py b/rowers/views.py index 8088b67d..9030caba 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -168,6 +168,8 @@ from rowers.tasks import ( handle_update_empower, handle_sendemailics, handle_sendemail_userdeleted, + handle_sendemail_raceregistration, + handle_sendemail_racesubmission, ) from scipy.signal import savgol_filter @@ -3458,6 +3460,12 @@ def addmanual_view(request): add_workouts_plannedsession([w],ps,w.user) messages.info(request,'New workout created') + + url = reverse( + workout_edit_view, + kwargs={'id':id} + ) + return HttpResponseRedirect(url) else: return render(request,'manualadd.html', {'form':form, @@ -9977,6 +9985,8 @@ def workout_edit_view(request,id=0,message="",successmessage=""): row = get_workout(id) + indoorraces = get_indoorraces(row) + if (checkworkoutuser(request.user,row)==False): raise PermissionDenied("Access denied") @@ -10169,6 +10179,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""): 'graphs':g, 'breadcrumbs':breadcrumbs, 'rower':r, + 'indoorraces':indoorraces, 'active':'nav-workouts', 'mapscript':mapscript, 'mapdiv':mapdiv, @@ -11451,7 +11462,7 @@ def workout_upload_view(request, response = {} if request.method == 'POST': form = DocumentsForm(request.POST,request.FILES) - optionsform = UploadOptionsForm(request.POST) + optionsform = UploadOptionsForm(request.POST,request=request) if form.is_valid(): # f = request.FILES['file'] @@ -11480,6 +11491,7 @@ def workout_upload_view(request, notes = form.cleaned_data['notes'] offline = form.cleaned_data['offline'] + race = None if optionsform.is_valid(): make_plot = optionsform.cleaned_data['make_plot'] plottype = optionsform.cleaned_data['plottype'] @@ -11492,6 +11504,11 @@ def workout_upload_view(request, makeprivate = optionsform.cleaned_data['makeprivate'] landingpage = optionsform.cleaned_data['landingpage'] + try: + race = optionsform.cleaned_data['submitrace'] + except KeyError: + race = None + uploadoptions = { 'makeprivate':makeprivate, 'make_plot':make_plot, @@ -11677,6 +11694,28 @@ def workout_upload_view(request, else: messages.error(request,message) + if race and race_can_submit(r,race): + records = IndoorVirtualRaceResult.objects.filter( + race=race, + userid=r.id + ) + + if records: + + result,comments,errors,jobid = add_workout_indoorrace( + [w],race,r,recordid=records[0].id + ) + + if result: + messages.info( + request, + "We have submitted your workout to the race") + + for c in comments: + messages.info(request,c) + for er in errors: + messages.error(request,er) + if landingpage != 'workout_upload_view': url = reverse(landingpage, @@ -11725,7 +11764,8 @@ def workout_upload_view(request, uploadoptions['upload_to_MapMyFitness'] = True form = DocumentsForm(initial=docformoptions) - optionsform = UploadOptionsForm(initial=uploadoptions) + optionsform = UploadOptionsForm(initial=uploadoptions, + request=request) return render(request, 'document_form.html', {'form':form, 'active':'nav-workouts', @@ -16111,11 +16151,32 @@ def virtualevent_disqualify_view(request,raceid=0,recordid=0): }, ] + buttons = [] + + if not request.user.is_anonymous(): + if race_can_register(r,race): + buttons += ['registerbutton'] + + if race_can_adddiscipline(r,race): + buttons += ['adddisciplinebutton'] + + if race_can_submit(r,race): + buttons += ['submitbutton'] + + if race_can_resubmit(r,race): + buttons += ['resubmitbutton'] + + if race_can_withdraw(r,race): + buttons += ['withdrawbutton'] + + if race_can_edit(r,race): + buttons += ['editbutton'] return render(request,"disqualification_view.html", {'workout':workout, 'active':'nav-racing', 'graphs':g, + 'buttons':buttons, 'interactiveplot':script, 'the_div':div, 'mapscript':mapscript, @@ -16453,10 +16514,31 @@ def virtualevent_addboat_view(request,id=0): ] + buttons = [] + + if not request.user.is_anonymous(): + if race_can_register(r,race): + buttons += ['registerbutton'] + + if race_can_adddiscipline(r,race): + buttons += ['adddisciplinebutton'] + + if race_can_submit(r,race): + buttons += ['submitbutton'] + + if race_can_resubmit(r,race): + buttons += ['resubmitbutton'] + + if race_can_withdraw(r,race): + buttons += ['withdrawbutton'] + + if race_can_edit(r,race): + buttons += ['editbutton'] return render(request,'virtualeventregister.html', { 'form':form, + 'buttons':buttons, 'breadcrumbs':breadcrumbs, 'race':race, 'userid':r.user.id, @@ -16526,6 +16608,22 @@ def virtualevent_register_view(request,id=0): add_rower_race(r,race) + otherrecords = IndoorVirtualRaceResult.objects.filter( + race = race).exclude(userid = r.id) + + for otherrecord in otherrecords: + otheruser = Rower.objects.get(id=otherrecord.userid) + othername = otheruser.user.first_name+' '+otheruser.user.last_name + registeredname = r.user.first_name+' '+r.user.last_name + if otherrecord.emailnotifications: + job = myqueue( + queue, + handle_sendemail_raceregistration, + otheruser.user.email, othername, + registeredname, + race.name, + race.id + ) messages.info( @@ -16566,15 +16664,80 @@ def virtualevent_register_view(request,id=0): 'name': 'Register' } ] + + buttons = [] + + if not request.user.is_anonymous(): + if race_can_register(r,race): + buttons += ['registerbutton'] + + if race_can_adddiscipline(r,race): + buttons += ['adddisciplinebutton'] + + if race_can_submit(r,race): + buttons += ['submitbutton'] + + if race_can_resubmit(r,race): + buttons += ['resubmitbutton'] + + if race_can_withdraw(r,race): + buttons += ['withdrawbutton'] + + if race_can_edit(r,race): + buttons += ['editbutton'] + return render(request,'virtualeventregister.html', { 'form':form, + 'buttons':buttons, 'breadcrumbs':breadcrumbs, 'race':race, 'userid':r.user.id, }) +@login_required() +def virtualevent_toggle_email_view(request,id=0): + r = getrower(request.user) + race = VirtualRace.objects.get(id=id) + records = VirtualRaceResult.objects.filter(userid=r.id,race=race) + + if True in [record.emailnotifications for record in records]: + newsetting = False + else: + newsetting = True + + for record in records: + record.emailnotifications = newsetting + record.save() + + url = reverse(virtualevent_view, + kwargs={'id':record.race.id}) + + return HttpResponseRedirect(url) + +@login_required() +def indoorvirtualevent_toggle_email_view(request,id=0): + r = getrower(request.user) + race = VirtualRace.objects.get(id=id) + + records = IndoorVirtualRaceResult.objects.filter(userid=r.id, + race=race) + + if True in [record.emailnotifications for record in records]: + newsetting = False + else: + newsetting = True + + for record in records: + record.emailnotifications = newsetting + record.save() + + url = reverse(virtualevent_view, + kwargs={'id':record.race.id}) + + return HttpResponseRedirect(url) + @login_required() def indoorvirtualevent_register_view(request,id=0): r = getrower(request.user) @@ -16633,6 +16796,22 @@ def indoorvirtualevent_register_view(request,id=0): add_rower_race(r,race) + otherrecords = IndoorVirtualRaceResult.objects.filter( + race = race).exclude(userid = r.id) + + for otherrecord in otherrecords: + otheruser = Rower.objects.get(id=otherrecord.userid) + othername = otheruser.user.first_name+' '+otheruser.user.last_name + registeredname = r.user.first_name+' '+r.user.last_name + if otherrecord.emailnotifications: + job = myqueue( + queue, + handle_sendemail_raceregistration, + otheruser.user.email, othername, + registeredname, + race.name, + race.id + ) messages.info( @@ -16674,9 +16853,31 @@ def indoorvirtualevent_register_view(request,id=0): } ] + buttons = [] + + if not request.user.is_anonymous(): + if race_can_register(r,race): + buttons += ['registerbutton'] + + if race_can_adddiscipline(r,race): + buttons += ['adddisciplinebutton'] + + if race_can_submit(r,race): + buttons += ['submitbutton'] + + if race_can_resubmit(r,race): + buttons += ['resubmitbutton'] + + if race_can_withdraw(r,race): + buttons += ['withdrawbutton'] + + if race_can_edit(r,race): + buttons += ['editbutton'] + return render(request,'virtualeventregister.html', { 'form':form, + 'buttons':buttons, 'race':race, 'breadcrumbs':breadcrumbs, 'userid':r.user.id, @@ -17024,10 +17225,32 @@ def virtualevent_edit_view(request,id=0): } ] + buttons = [] + + if not request.user.is_anonymous(): + if race_can_register(r,race): + buttons += ['registerbutton'] + + if race_can_adddiscipline(r,race): + buttons += ['adddisciplinebutton'] + + if race_can_submit(r,race): + buttons += ['submitbutton'] + + if race_can_resubmit(r,race): + buttons += ['resubmitbutton'] + + if race_can_withdraw(r,race): + buttons += ['withdrawbutton'] + + if race_can_edit(r,race): + buttons += ['editbutton'] + return render(request,'virtualeventedit.html', { 'form':racecreateform, 'breadcrumbs':breadcrumbs, + 'buttons':buttons, 'rower':r, 'race':race, @@ -17100,9 +17323,33 @@ def indoorvirtualevent_edit_view(request,id=0): 'name': 'Edit' } ] + + buttons = [] + + if not request.user.is_anonymous(): + if race_can_register(r,race): + buttons += ['registerbutton'] + + if race_can_adddiscipline(r,race): + buttons += ['adddisciplinebutton'] + + if race_can_submit(r,race): + buttons += ['submitbutton'] + + if race_can_resubmit(r,race): + buttons += ['resubmitbutton'] + + if race_can_withdraw(r,race): + buttons += ['withdrawbutton'] + + if race_can_edit(r,race): + buttons += ['editbutton'] + + return render(request,'virtualeventedit.html', { 'form':racecreateform, + 'buttons':buttons, 'breadcrumbs':breadcrumbs, 'rower':r, 'race':race, @@ -17142,6 +17389,7 @@ def virtualevent_submit_result_view(request,id=0): race=race ) + entrychoices = [] for record in records: @@ -17234,6 +17482,25 @@ def virtualevent_submit_result_view(request,id=0): request.session['async_tasks'] = [(jobid,'submit_race')] messages.info(request,"We are evaluating your result. The page will reload when we're done. Your result will show up if you adhered to the course") + + if result: + otherrecords = resultobj.objects.filter( + race = race).exclude(userid = r.id) + + for otherrecord in otherrecords: + otheruser = Rower.objects.get(id=otherrecord.userid) + othername = otheruser.user.first_name+' '+otheruser.user.last_name + registeredname = r.user.first_name+' '+r.user.last_name + if otherrecord.emailnotifications: + job = myqueue( + queue, + handle_sendemail_racesubmission, + otheruser.user.email, othername, + registeredname, + race.name, + race.id + ) + # redirect to race page url = reverse(virtualevent_view, @@ -17264,9 +17531,33 @@ def virtualevent_submit_result_view(request,id=0): 'name': 'Submit Result' } ] + + buttons = [] + + if not request.user.is_anonymous(): + if race_can_register(r,race): + buttons += ['registerbutton'] + + if race_can_adddiscipline(r,race): + buttons += ['adddisciplinebutton'] + + if race_can_submit(r,race): + buttons += ['submitbutton'] + + if race_can_resubmit(r,race): + buttons += ['resubmitbutton'] + + if race_can_withdraw(r,race): + buttons += ['withdrawbutton'] + + if race_can_edit(r,race): + buttons += ['editbutton'] + + return render(request,'race_submit.html', { 'race':race, + 'buttons':buttons, 'workouts':ws, 'breadcrumbs':breadcrumbs, 'active':'nav-racing',