diff --git a/rowers/templates/fastestvirtualeventcreate.html b/rowers/templates/fastestvirtualeventcreate.html new file mode 100644 index 00000000..fa24b1ec --- /dev/null +++ b/rowers/templates/fastestvirtualeventcreate.html @@ -0,0 +1,117 @@ +{% extends "newbase.html" %} +{% load staticfiles %} +{% load rowerfilters %} + +{% block title %}New Virtual Challenge{% endblock %} + +{% block main %} + +

New On-The-Water Virtual Challenge

+ +
    +
  • +

    With this form, you can create a new virtual challenge. After you submit + the form, the challenge is created and will be visible to all users. From + that moment, only the site admin can delete the challenge + (admin@rowsandall.com). You can still edit the challenge until + the start of the challenge window. +

    +
  • + +
  • +
    + {% if form.errors %} +

    + Please correct the error{{ form.errors|pluralize }} below. +

    + {% endif %} +

    + + {{ form.as_table }} +
    +

    +

    + {% csrf_token %} + +

    +
    +
  • +
  • +

    +

      +

      All times are local times in the time zone you select

      +

      Adding a contact phone number and email is not mandatory, but we + strongly recommend it.

      +

      If your event has a registration closure deadline, participants + have to enter (and can withdraw) before the registration closure time.

      +

      Participants can submit results until the evaluation closure time.

      +

      Until one hour after evaluation closure time, the challenge organizer + can review and reject submitted results ("disqualification"). If + you as the challenge organizer intend to use this functionality, it + is strongly recommended that you fill out a contact email or phone + number. +

      +

      + The participants can row this challenge on any course, and their fastest time + over the challenge distance (respectively the largest distance achieved over the + challenge duration) is automatically extracted from the workout. No + need to program a set piece. +

      +

      + Standard Times are a way to compare results in a race category with + a course record or golden standard for that event. A point score is calculated + which compares the participant's result with the standard. This offers an + engaging way to compete on points across different categories, boat types, and skill + levels. + If you select a Standard Times set from the drop-down list, race categories will + be limited to those in the selected set of Standard Times. +

      +
    +

    +
  • +
+ + +{% endblock %} + +{% block scripts %} + + +{% endblock %} + +{% block sidebar %} +{% include 'menu_racing.html' %} +{% endblock %} diff --git a/rowers/templates/menu_racing.html b/rowers/templates/menu_racing.html index 4ebd5e26..47bcb10d 100644 --- a/rowers/templates/menu_racing.html +++ b/rowers/templates/menu_racing.html @@ -7,10 +7,15 @@
  • -  New Challenge +  New Course Challenge
  • + +  New Any Course Challenge + +
  • +
  •  New Indoor Challenge diff --git a/rowers/templates/racelist.html b/rowers/templates/racelist.html index b74f9e67..86d9dbaf 100644 --- a/rowers/templates/racelist.html +++ b/rowers/templates/racelist.html @@ -27,6 +27,10 @@ {{ race.name }} {% if race.sessiontype == 'race' %} {{ race.course.country }} + {% elif race.sessiontype == 'fastest_distance' %} + Worldwide On-the-water Challenge + {% elif race.sessiontype == 'fastest_time' %} + Worldwide On-the-water Challenge {% else %} Worldwide Indoor Challenge {% endif %} diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index a76e0f54..7bc085de 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -96,6 +96,14 @@ Course{{ race.course }} + {% elif race.sessiontype == 'fastest_time' %} + + Time ChallengeTo be rowed on the water + + {% elif race.sessiontype == 'fastest_distance' %} + + Distance ChallengeTo be rowed on the water + {% else %} Indoor RaceTo be rowed on a Concept2 ergometer @@ -586,6 +594,21 @@ You cannot submit results rowed on other bodies of water.

    + {% elif race.sessiontype == 'fastest_time' %} +

    + This on-the-water challenge asks you to try to get + as far as you can over the + race duration. It automatically finds the fastest interval + of the given duration + in your entire workout. +

    + {% elif race.sessiontype == 'fastest_distance' %} +

    + This on-the-water challenge asks you to try row as hard + as you can over a set distance. + It automatically finds the fastest interval of the given length + in your entire workout. +

    {% else %}

    Indoor challenges are open for all, wherever you live. diff --git a/rowers/urls.py b/rowers/urls.py index 520aeffa..78310079 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -262,6 +262,8 @@ urlpatterns = [ re_path(r'^virtualevents/$',views.virtualevents_view,name='virtualevents_view'), re_path(r'^virtualevent/create/$',views.virtualevent_create_view,name='virtualevent_create_view'), re_path(r'^virtualevent/createindoor/$',views.indoorvirtualevent_create_view,name='indoorvirtualevent_create_view'), + re_path(r'^virtualevent/createfastest/$',views.fastestvirtualevent_create_view, + name='fastestvirtualevent_create_view'), re_path(r'^raceregistration/togglenotification/(?P\d+)/$', views.virtualevent_toggle_email_view,name='virtualevent_toggle_email_view'), re_path(r'^indoorraceregistration/togglenotification/(?P\d+)/$', diff --git a/rowers/views/racesviews.py b/rowers/views/racesviews.py index aed19ff6..57934fe1 100644 --- a/rowers/views/racesviews.py +++ b/rowers/views/racesviews.py @@ -2706,6 +2706,153 @@ def indoorvirtualevent_create_view(request): }) +@login_required() +def fastestvirtualevent_create_view(request): + r = getrower(request.user) + + if request.method == 'POST': + racecreateform = IndoorVirtualRaceForm(request.POST) + if racecreateform.is_valid(): + cd = racecreateform.cleaned_data + startdate = cd['startdate'] + start_time = cd['start_time'] + enddate = cd['enddate'] + end_time = cd['end_time'] + comment = cd['comment'] + sessionunit = cd['sessionunit'] + sessionvalue = cd['sessionvalue'] + name = cd['name'] + registration_form = cd['registration_form'] + registration_closure = cd['registration_closure'] + evaluation_closure = cd['evaluation_closure'] + contact_phone = cd['contact_phone'] + contact_email = cd['contact_email'] + coursestandards = cd['coursestandards'] + + # correct times + + timezone_str = cd['timezone'] + + startdatetime = datetime.datetime.combine(startdate,start_time) + enddatetime = datetime.datetime.combine(enddate,end_time) + + + startdatetime = pytz.timezone(timezone_str).localize( + startdatetime + ) + enddatetime = pytz.timezone(timezone_str).localize( + enddatetime + ) + evaluation_closure = pytz.timezone(timezone_str).localize( + evaluation_closure.replace(tzinfo=None) + ) + + if registration_form == 'manual': + try: + registration_closure = pytz.timezone( + timezone_str + ).localize( + registration_closure.replace(tzinfo=None) + ) + except AttributeError: + registration_closure = startdatetime + elif registration_form == 'windowstart': + registration_closure = startdatetime + elif registration_form == 'windowend': + registration_closure = enddatetime + else: + registration_closure = evaluation_closure + + if sessionunit == 'min': + sessionmode = 'time' + sessiontype = 'fastest_time' + else: + sessionmode = 'distance' + sessiontype = 'fastest_distance' + + + vs = VirtualRace( + name=name, + startdate=startdate, + preferreddate = startdate, + start_time = start_time, + enddate=enddate, + end_time=end_time, + comment=comment, + sessiontype = sessiontype, + sessionunit = sessionunit, + sessionmode = sessionmode, + sessionvalue = sessionvalue, + course=None, + timezone=timezone_str, + coursestandards=coursestandards, + evaluation_closure=evaluation_closure, + registration_closure=registration_closure, + contact_phone=contact_phone, + contact_email=contact_email, + country = 'Indoor', + manager=request.user, + ) + + vs.save() + + # create Site Announcement & Tweet + if settings.DEBUG or settings.TESTING: + dotweet = False + elif 'dev' in settings.SITE_URL: + dotweet = False + else: + dotweet = True + + announcementshort = "New Virtual Challenge on rowsandall.com: {name}".format( + name = name, + ) + + announcement = announcementshort + " {siteurl}/rowers/virtualevent/{raceid}/".format( + siteurl = SITE_URL, + raceid = vs.id + ) + + + if len(announcement)>250: + announcement = announcementshort + + sa = SiteAnnouncement( + announcement = announcement, + dotweet = dotweet + ) + + sa.save() + + url = reverse('virtualevents_view') + return HttpResponseRedirect(url) + else: + + racecreateform = IndoorVirtualRaceForm(timezone=r.defaulttimezone) + + + breadcrumbs = [ + { + 'url':reverse('virtualevents_view'), + 'name': 'Challenges' + }, + { + 'url':reverse('indoorvirtualevent_create_view', + ), + 'name': 'New Indoor Virtual Regatta' + }, + ] + + return render(request,'fastestvirtualeventcreate.html', + { + 'form':racecreateform, + 'breadcrumbs':breadcrumbs, + 'rower':r, + 'active':'nav-racing', + + }) + + @login_required() def virtualevent_create_view(request): r = getrower(request.user)