improved UI on regattas
This commit is contained in:
@@ -1233,7 +1233,7 @@ class Workout(models.Model):
|
|||||||
max_length=100)
|
max_length=100)
|
||||||
distance = models.IntegerField(default=0,blank=True)
|
distance = models.IntegerField(default=0,blank=True)
|
||||||
duration = models.TimeField(default=1,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)')
|
weightvalue = models.FloatField(default=80.0,blank=True,verbose_name = 'Average Crew Weight (kg)')
|
||||||
csvfilename = models.CharField(blank=True,max_length=150)
|
csvfilename = models.CharField(blank=True,max_length=150)
|
||||||
uploadedtoc2 = models.IntegerField(default=0)
|
uploadedtoc2 = models.IntegerField(default=0)
|
||||||
@@ -1478,10 +1478,10 @@ def auto_delete_image_on_delete(sender,instance, **kwargs):
|
|||||||
|
|
||||||
# Form to update Workout data
|
# Form to update Workout data
|
||||||
class WorkoutForm(ModelForm):
|
class WorkoutForm(ModelForm):
|
||||||
duration = forms.TimeInput(format='%H:%M:%S.%f')
|
# duration = forms.TimeInput(format='%H:%M:%S.%f')
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Workout
|
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 = {
|
widgets = {
|
||||||
'date': AdminDateWidget(),
|
'date': AdminDateWidget(),
|
||||||
'notes': forms.Textarea,
|
'notes': forms.Textarea,
|
||||||
@@ -1492,11 +1492,6 @@ class WorkoutForm(ModelForm):
|
|||||||
super(WorkoutForm, self).__init__(*args, **kwargs)
|
super(WorkoutForm, self).__init__(*args, **kwargs)
|
||||||
# this line to be removed
|
# this line to be removed
|
||||||
del self.fields['privacy']
|
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':
|
if self.instance.workouttype != 'water':
|
||||||
del self.fields['boattype']
|
del self.fields['boattype']
|
||||||
@@ -1509,6 +1504,7 @@ class WorkoutForm(ModelForm):
|
|||||||
'duration',
|
'duration',
|
||||||
'distance',
|
'distance',
|
||||||
'workouttype',
|
'workouttype',
|
||||||
|
'weightcategory',
|
||||||
'notes',
|
'notes',
|
||||||
'rankingpiece',
|
'rankingpiece',
|
||||||
'boattype'
|
'boattype'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<th>Event</th>
|
<th>Event</th>
|
||||||
<th>Country</th>
|
<th>Country</th>
|
||||||
<th>Course</th>
|
<th>Course</th>
|
||||||
<th>Action</th>
|
<th>Click for Details</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
@@ -99,10 +99,8 @@
|
|||||||
<th> </th>
|
<th> </th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th>Boat</th>
|
<th>Boat</th>
|
||||||
<th>Raw Time</th>
|
<th>Time</th>
|
||||||
<th>In Class</th>
|
<th>Details</th>
|
||||||
<th>Corrected Time</th>
|
|
||||||
<th>Corrected Place</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -112,12 +110,15 @@
|
|||||||
<td>
|
<td>
|
||||||
<a href="/rowers/workout/{{ result.workoutid }}">
|
<a href="/rowers/workout/{{ result.workoutid }}">
|
||||||
{{ result.username }}</a></td>
|
{{ result.username }}</a></td>
|
||||||
<td>{{ result.teamname }}</th>
|
<td>{{ result.teamname }}</td>
|
||||||
<td>{{ result.age }}</td>
|
<td>{{ result.age }}</td>
|
||||||
<td>{{ result.sex }}</td>
|
<td>{{ result.sex }}</td>
|
||||||
<td>{{ result.weightcategory }}</td>
|
<td>{{ result.weightcategory }}</td>
|
||||||
<td>{{ result.boattype }}</td>
|
<td>{{ result.boattype }}</td>
|
||||||
<td>{{ result.duration |durationprint:"%H:%M:%S.%f" }}</td>
|
<td>{{ result.duration |durationprint:"%H:%M:%S.%f" }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="/rowers/workout/{{ result.workoutid }}">
|
||||||
|
Details</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for result in dns %}
|
{% for result in dns %}
|
||||||
|
|||||||
@@ -85,6 +85,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid_12 alpha" id="racelist">
|
<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' %}
|
{% include 'racelist.html' %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -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/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,
|
url(r'^workout/(?P<id>\d+)/edit$',views.workout_edit_view,
|
||||||
name='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+)/map$',views.workout_map_view),
|
||||||
url(r'^workout/(?P<id>\d+)/setprivate$',views.workout_setprivate_view),
|
url(r'^workout/(?P<id>\d+)/setprivate$',views.workout_setprivate_view),
|
||||||
url(r'^workout/(?P<id>\d+)/updatecp$',views.workout_update_cp_view),
|
url(r'^workout/(?P<id>\d+)/updatecp$',views.workout_update_cp_view),
|
||||||
|
|||||||
164
rowers/views.py
164
rowers/views.py
@@ -3431,6 +3431,7 @@ def addmanual_view(request):
|
|||||||
starttime = form.cleaned_data['starttime']
|
starttime = form.cleaned_data['starttime']
|
||||||
workouttype = form.cleaned_data['workouttype']
|
workouttype = form.cleaned_data['workouttype']
|
||||||
duration = form.cleaned_data['duration']
|
duration = form.cleaned_data['duration']
|
||||||
|
weightcategory = form.cleaned_data['weightcategory']
|
||||||
distance = form.cleaned_data['distance']
|
distance = form.cleaned_data['distance']
|
||||||
notes = form.cleaned_data['notes']
|
notes = form.cleaned_data['notes']
|
||||||
thetimezone = form.cleaned_data['timezone']
|
thetimezone = form.cleaned_data['timezone']
|
||||||
@@ -3458,6 +3459,7 @@ def addmanual_view(request):
|
|||||||
|
|
||||||
id,message = dataprep.create_row_df(r,
|
id,message = dataprep.create_row_df(r,
|
||||||
distance,
|
distance,
|
||||||
|
weightcategory,
|
||||||
duration,startdatetime,
|
duration,startdatetime,
|
||||||
title = name,
|
title = name,
|
||||||
notes=notes,
|
notes=notes,
|
||||||
@@ -9011,6 +9013,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
date = form.cleaned_data['date']
|
date = form.cleaned_data['date']
|
||||||
starttime = form.cleaned_data['starttime']
|
starttime = form.cleaned_data['starttime']
|
||||||
workouttype = form.cleaned_data['workouttype']
|
workouttype = form.cleaned_data['workouttype']
|
||||||
|
weightcategory = form.cleaned_data['weightcategory']
|
||||||
duration = form.cleaned_data['duration']
|
duration = form.cleaned_data['duration']
|
||||||
distance = form.cleaned_data['distance']
|
distance = form.cleaned_data['distance']
|
||||||
notes = form.cleaned_data['notes']
|
notes = form.cleaned_data['notes']
|
||||||
@@ -9049,6 +9052,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
row.starttime = starttime
|
row.starttime = starttime
|
||||||
row.startdatetime = startdatetime
|
row.startdatetime = startdatetime
|
||||||
row.workouttype = workouttype
|
row.workouttype = workouttype
|
||||||
|
row.weightcategory = weightcategory
|
||||||
row.notes = notes
|
row.notes = notes
|
||||||
row.duration = duration
|
row.duration = duration
|
||||||
row.distance = distance
|
row.distance = distance
|
||||||
@@ -9223,166 +9227,6 @@ def workout_map_view(request,id=0):
|
|||||||
'mayedit':mayedit,
|
'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
|
# Image upload
|
||||||
@login_required()
|
@login_required()
|
||||||
|
|||||||
Reference in New Issue
Block a user