diff --git a/rowers/models.py b/rowers/models.py index 14b5fc86..b8c70042 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -1233,7 +1233,7 @@ class Workout(models.Model): max_length=100) distance = models.IntegerField(default=0,blank=True) duration = models.TimeField(default=1,blank=True) - weightcategory = models.CharField(default="hwt",max_length=10) + weightcategory = models.CharField(default="hwt",max_length=10,choices=weightcategories) weightvalue = models.FloatField(default=80.0,blank=True,verbose_name = 'Average Crew Weight (kg)') csvfilename = models.CharField(blank=True,max_length=150) uploadedtoc2 = models.IntegerField(default=0) @@ -1478,10 +1478,10 @@ def auto_delete_image_on_delete(sender,instance, **kwargs): # Form to update Workout data class WorkoutForm(ModelForm): - duration = forms.TimeInput(format='%H:%M:%S.%f') +# duration = forms.TimeInput(format='%H:%M:%S.%f') class Meta: model = Workout - fields = ['name','date','starttime','timezone','duration','distance','workouttype','notes','privacy','rankingpiece','boattype'] + fields = ['name','date','starttime','timezone','duration','distance','workouttype','weightcategory','notes','privacy','rankingpiece','boattype'] widgets = { 'date': AdminDateWidget(), 'notes': forms.Textarea, @@ -1492,11 +1492,6 @@ class WorkoutForm(ModelForm): super(WorkoutForm, self).__init__(*args, **kwargs) # this line to be removed del self.fields['privacy'] -# self.fields['timezone'] = forms.ChoiceField(choices=[ -# (x,x) for x in pytz.common_timezones -# ], -# initial='UTC', -# label='Time Zone') if self.instance.workouttype != 'water': del self.fields['boattype'] @@ -1509,6 +1504,7 @@ class WorkoutForm(ModelForm): 'duration', 'distance', 'workouttype', + 'weightcategory', 'notes', 'rankingpiece', 'boattype' diff --git a/rowers/templates/racelist.html b/rowers/templates/racelist.html index 898d8a17..b2f391b1 100644 --- a/rowers/templates/racelist.html +++ b/rowers/templates/racelist.html @@ -8,7 +8,7 @@ Event Country Course - Action + Click for Details diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index 04610edf..dc5b7a25 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -99,10 +99,8 @@     Boat - Raw Time - In Class - Corrected Time - Corrected Place + Time + Details @@ -112,12 +110,15 @@ {{ result.username }} - {{ result.teamname }} + {{ result.teamname }} {{ result.age }} {{ result.sex }} {{ result.weightcategory }} {{ result.boattype }} {{ result.duration |durationprint:"%H:%M:%S.%f" }} + + + Details {% endfor %} {% for result in dns %} diff --git a/rowers/templates/virtualevents.html b/rowers/templates/virtualevents.html index a83a396f..5f7c92f7 100644 --- a/rowers/templates/virtualevents.html +++ b/rowers/templates/virtualevents.html @@ -85,6 +85,10 @@
+

Click on the event name or on the Details button to see the event + details (and manage your participation and results). Click on the + course name to see the course details. +

{% include 'racelist.html' %}
diff --git a/rowers/urls.py b/rowers/urls.py index a5000cd0..d37bf26b 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -254,7 +254,6 @@ urlpatterns = [ url(r'^workout/compare/(?P\d+)/(?P\d+-\d+-\d+)/(?P\w+.*)$',views.workout_comparison_list), url(r'^workout/(?P\d+)/edit$',views.workout_edit_view, name='workout_edit_view'), - url(r'^workout/(?P\d+)/navionics$',views.workout_edit_view_navionics), url(r'^workout/(?P\d+)/map$',views.workout_map_view), url(r'^workout/(?P\d+)/setprivate$',views.workout_setprivate_view), url(r'^workout/(?P\d+)/updatecp$',views.workout_update_cp_view), diff --git a/rowers/views.py b/rowers/views.py index a944b2a8..87602e00 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -3431,6 +3431,7 @@ def addmanual_view(request): starttime = form.cleaned_data['starttime'] workouttype = form.cleaned_data['workouttype'] duration = form.cleaned_data['duration'] + weightcategory = form.cleaned_data['weightcategory'] distance = form.cleaned_data['distance'] notes = form.cleaned_data['notes'] thetimezone = form.cleaned_data['timezone'] @@ -3458,6 +3459,7 @@ def addmanual_view(request): id,message = dataprep.create_row_df(r, distance, + weightcategory, duration,startdatetime, title = name, notes=notes, @@ -9011,6 +9013,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""): date = form.cleaned_data['date'] starttime = form.cleaned_data['starttime'] workouttype = form.cleaned_data['workouttype'] + weightcategory = form.cleaned_data['weightcategory'] duration = form.cleaned_data['duration'] distance = form.cleaned_data['distance'] notes = form.cleaned_data['notes'] @@ -9049,6 +9052,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""): row.starttime = starttime row.startdatetime = startdatetime row.workouttype = workouttype + row.weightcategory = weightcategory row.notes = notes row.duration = duration row.distance = distance @@ -9223,166 +9227,6 @@ def workout_map_view(request,id=0): 'mayedit':mayedit, }) -# The basic edit page -@login_required() -def workout_edit_view_navionics(request,id=0,message="",successmessage=""): - request.session[translation.LANGUAGE_SESSION_KEY] = USER_LANGUAGE - request.session['referer'] = absolute(request)['PATH'] - - row = get_workout(id) - form = WorkoutForm(instance=row) - - if request.method == 'POST': - # Form was submitted - form = WorkoutForm(request.POST) - if form.is_valid(): - # Get values from form - name = form.cleaned_data['name'] - date = form.cleaned_data['date'] - starttime = form.cleaned_data['starttime'] - workouttype = form.cleaned_data['workouttype'] - duration = form.cleaned_data['duration'] - distance = form.cleaned_data['distance'] - notes = form.cleaned_data['notes'] - thetimezone = form.cleaned_data['timezone'] - try: - boattype = request.POST['boattype'] - except KeyError: - boattype = Workout.objects.get(id=id).boattype - try: - privacy = request.POST['privacy'] - except KeyError: - privacy = Workout.objects.get(id=id).privacy - try: - rankingpiece = form.cleaned_data['rankingpiece'] - except KeyError: - rankingpiece =- Workout.objects.get(id=id).rankingpiece - - startdatetime = (str(date) + ' ' + str(starttime)) - startdatetime = datetime.datetime.strptime(startdatetime, - "%Y-%m-%d %H:%M:%S") - startdatetime = timezone.make_aware(startdatetime) - startdatetime = startdatetime.astimezone(pytz.timezone(thetimezone)) - - - # check if user is owner of this workout - if checkworkoutuser(request.user,row): - row.name = name - row.date = date - row.starttime = starttime - row.startdatetime = startdatetime - row.workouttype = workouttype - row.notes = notes - row.duration = duration - row.distance = distance - row.boattype = boattype - row.privacy = privacy - row.rankingpiece = rankingpiece - row.timezone = thetimezone - try: - row.save() - except IntegrityError: - pass - # change data in csv file - - r = rdata(row.csvfilename) - if r == 0: - return HttpResponse("Error: CSV Data File Not Found") - r.rowdatetime = startdatetime - r.write_csv(row.csvfilename,gzip=True) - dataprep.update_strokedata(id,r.df) - successmessage = "Changes saved" - messages.info(request,successmessage) - url = reverse(workout_edit_view, - kwargs = { - 'id':str(row.id), - }) - response = HttpResponseRedirect(url) - else: - message = "You are not allowed to change this workout" - messages.error(request,message) - url = reverse(workouts_view) - - response = HttpResponseRedirect(url) - - #else: # form not POSTed - form = WorkoutForm(instance=row) - - row = get_workout(id) - - g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime") - for i in g: - try: - width,height = Image.open(i.filename).size - i.width = width - i.height = height - i.save() - except: - pass - - # check if user is owner of this workout - - comments = WorkoutComment.objects.filter(workout=row) - - aantalcomments = len(comments) - - if (checkworkoutuser(request.user,row)==False): - raise PermissionDenied("Access denied") - - # create interactive plot - f1 = row.csvfilename - u = row.user.user - r = getrower(u) - rowdata = rdata(f1) - hascoordinates = 1 - if rowdata != 0: - try: - latitude = rowdata.df[' latitude'] - if not latitude.std(): - hascoordinates = 0 - except KeyError,AttributeError: - hascoordinates = 0 - - else: - hascoordinates = 0 - - - if hascoordinates: - mapscript,mapdiv = leaflet_chart2(rowdata.df[' latitude'], - rowdata.df[' longitude'], - row.name) - - else: - mapscript = "" - mapdiv = "" - - - # render page - if (len(g)<=3): - return render(request, 'workout_form.html', - {'form':form, - 'workout':row, - 'teams':get_my_teams(request.user), - 'graphs1':g[0:3], - 'mapscript':mapscript, - 'aantalcomments':aantalcomments, - 'mapdiv':mapdiv, - }) - - else: - return render(request, 'workout_form.html', - {'form':form, - 'teams':get_my_teams(request.user), - 'workout':row, - 'graphs1':g[0:3], - 'graphs2':g[3:6], - 'mapscript':mapscript, - 'aantalcomments':aantalcomments, - 'mapdiv':mapdiv, - }) - - - return HttpResponseRedirect(url) # Image upload @login_required()