Private
Public Access
1
0

improved UI on regattas

This commit is contained in:
Sander Roosendaal
2018-04-30 15:41:07 +02:00
parent 772bb41ecf
commit 5f1328ab73
6 changed files with 19 additions and 175 deletions

View File

@@ -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'

View File

@@ -8,7 +8,7 @@
<th>Event</th>
<th>Country</th>
<th>Course</th>
<th>Action</th>
<th>Click for Details</th>
</tr>
</thead>
<tbody>

View File

@@ -99,10 +99,8 @@
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>Boat</th>
<th>Raw Time</th>
<th>In Class</th>
<th>Corrected Time</th>
<th>Corrected Place</th>
<th>Time</th>
<th>Details</th>
</tr>
</thead>
<tbody>
@@ -112,12 +110,15 @@
<td>
<a href="/rowers/workout/{{ result.workoutid }}">
{{ result.username }}</a></td>
<td>{{ result.teamname }}</th>
<td>{{ result.teamname }}</td>
<td>{{ result.age }}</td>
<td>{{ result.sex }}</td>
<td>{{ result.weightcategory }}</td>
<td>{{ result.boattype }}</td>
<td>{{ result.duration |durationprint:"%H:%M:%S.%f" }}</td>
<td>
<a href="/rowers/workout/{{ result.workoutid }}">
Details</a></td>
</tr>
{% endfor %}
{% for result in dns %}

View File

@@ -85,6 +85,10 @@
</div>
<div class="grid_12 alpha" id="racelist">
<p>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.
</p>
{% include 'racelist.html' %}
</div>

View File

@@ -254,7 +254,6 @@ urlpatterns = [
url(r'^workout/compare/(?P<id>\d+)/(?P<startdatestring>\d+-\d+-\d+)/(?P<enddatestring>\w+.*)$',views.workout_comparison_list),
url(r'^workout/(?P<id>\d+)/edit$',views.workout_edit_view,
name='workout_edit_view'),
url(r'^workout/(?P<id>\d+)/navionics$',views.workout_edit_view_navionics),
url(r'^workout/(?P<id>\d+)/map$',views.workout_map_view),
url(r'^workout/(?P<id>\d+)/setprivate$',views.workout_setprivate_view),
url(r'^workout/(?P<id>\d+)/updatecp$',views.workout_update_cp_view),

View File

@@ -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()