Merge branch 'release/v6.81'
This commit is contained in:
+15
-2
@@ -6,7 +6,7 @@ from .models import (
|
||||
Rower, Workout,GraphImage,FavoriteChart,SiteAnnouncement,
|
||||
Team,TeamInvite,TeamRequest,
|
||||
WorkoutComment,C2WorldClassAgePerformance,PlannedSession,
|
||||
GeoCourse,GeoPolygon,GeoPoint,VirtualRace,
|
||||
GeoCourse,GeoPolygon,GeoPoint,VirtualRace,VirtualRaceResult,
|
||||
)
|
||||
|
||||
# Register your models here so you can use them in the Admin module
|
||||
@@ -18,8 +18,14 @@ class RowerInline(admin.StackedInline):
|
||||
verbose_name_plural = 'rower'
|
||||
filter_horizontal = ('team','friends')
|
||||
|
||||
class UserAdmin(UserAdmin):
|
||||
#class UserAdmin(UserAdmin):
|
||||
class UserAdmin(admin.ModelAdmin):
|
||||
inlines = (RowerInline,)
|
||||
list_display = ('username','email','first_name','last_name','rowerplan')
|
||||
search_fields = ["username","first_name","last_name","email"]
|
||||
|
||||
def rowerplan(self, obj):
|
||||
return obj.rower.rowerplan
|
||||
|
||||
class WorkoutAdmin(admin.ModelAdmin):
|
||||
list_display = ('date','user','name','workouttype','boattype')
|
||||
@@ -58,10 +64,16 @@ class GeoPolygonInline(admin.StackedInline):
|
||||
class GeoCourseAdmin(admin.ModelAdmin):
|
||||
list_display = ('manager','name')
|
||||
inlines = (GeoPolygonInline,)
|
||||
search_fields = ['name']
|
||||
|
||||
|
||||
class VirtualRaceAdmin(admin.ModelAdmin):
|
||||
list_display = ('manager','name','startdate','country')
|
||||
search_fields = ['name','country']
|
||||
|
||||
class VirtualRaceResultAdmin(admin.ModelAdmin):
|
||||
list_display = ('race','userid','username','boattype','age','weightcategory')
|
||||
search_fields = ['race__name','username']
|
||||
|
||||
admin.site.unregister(User)
|
||||
admin.site.register(User,UserAdmin)
|
||||
@@ -78,3 +90,4 @@ admin.site.register(C2WorldClassAgePerformance,
|
||||
admin.site.register(PlannedSession,PlannedSessionAdmin)
|
||||
admin.site.register(GeoCourse, GeoCourseAdmin)
|
||||
admin.site.register(VirtualRace, VirtualRaceAdmin)
|
||||
admin.site.register(VirtualRaceResult, VirtualRaceResultAdmin)
|
||||
|
||||
+37
-1
@@ -702,7 +702,43 @@ class WorkoutSessionSelectForm(forms.Form):
|
||||
initial=workoutdata['initial'],
|
||||
widget = forms.CheckboxSelectMultiple,
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
class RaceResultFilterForm(forms.Form):
|
||||
sexchoices = (
|
||||
('female','Female'),
|
||||
('male','Male'),
|
||||
('mixed','Mixed'),
|
||||
)
|
||||
|
||||
weightcategories = (
|
||||
('hwt','heavy-weight'),
|
||||
('lwt','light-weight'),
|
||||
)
|
||||
|
||||
|
||||
sex = forms.MultipleChoiceField(
|
||||
choices=sexchoices,
|
||||
initial=['male','female','mixed'],
|
||||
label='Gender',
|
||||
widget=forms.CheckboxSelectMultiple())
|
||||
|
||||
boattype = forms.MultipleChoiceField(
|
||||
choices=boattypes,
|
||||
label='Boat Type',
|
||||
initial=['1x','2x','2-','4x','4-','8+'],
|
||||
widget=forms.CheckboxSelectMultiple())
|
||||
|
||||
age_min = forms.IntegerField(label='Min Age',initial=16)
|
||||
age_max = forms.IntegerField(label='Max Age',initial=100)
|
||||
|
||||
weightcategory = forms.MultipleChoiceField(
|
||||
choices=weightcategories,
|
||||
label='Weight Category',
|
||||
initial=['hwt','lwt'],
|
||||
widget=forms.CheckboxSelectMultiple())
|
||||
|
||||
class WorkoutRaceSelectForm(forms.Form):
|
||||
# evaluate_after = forms.TimeField(
|
||||
# input_formats=['%H:%M:%S.%f',
|
||||
|
||||
@@ -1645,6 +1645,10 @@ class VirtualRaceResultForm(ModelForm):
|
||||
|
||||
if boattypes:
|
||||
self.fields['boattype'].choices = boattypes
|
||||
|
||||
self.fields['mix'] = forms.BooleanField(initial=False,
|
||||
required=False,
|
||||
label='Mixed Gender')
|
||||
|
||||
from rowers.metrics import rowingmetrics
|
||||
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
<th>Team Name</th>
|
||||
<th>Boat</th>
|
||||
<th>Age</th>
|
||||
<th>Gender</th>
|
||||
<th>Weight Category</th>
|
||||
</tr>
|
||||
<tbody>
|
||||
@@ -169,6 +170,7 @@
|
||||
<td>{{ record.teamname }}</td>
|
||||
<td>{{ record.boattype }}</td>
|
||||
<td>{{ record.age }}</td>
|
||||
<td>{{ record.sex }}</td>
|
||||
<td>{{ record.weightcategory }}</td>
|
||||
{% if record.userid == rower.id and 'withdrawbutton' in buttons %}
|
||||
<td>
|
||||
@@ -228,10 +230,24 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_4 omega">
|
||||
<p>
|
||||
<h2>Course</h2>
|
||||
{{ coursediv|safe }}
|
||||
|
||||
{{ coursescript|safe }}
|
||||
|
||||
</p>
|
||||
<p>
|
||||
<h2>Filter Results</h2>
|
||||
|
||||
<form id="result_filter_form", method="post">
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
|
||||
{% csrf_token %}
|
||||
<input class="button green" type="submit" value="Submit">
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -31,6 +31,13 @@
|
||||
value from your user settings. For other boat types, please fill out
|
||||
crew weight class and average age.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You will register as a crew with the gender of your user settings. If
|
||||
your user settings have gender "not specified", you will be registered
|
||||
as a Male crew. Check the "Mixed gender" check box to register as a
|
||||
mixed gender crew (except for 1x where this check box does nothing).
|
||||
</p>
|
||||
<div class="grid_6 alpha">
|
||||
<table width="100%">
|
||||
{{ form.as_table }}
|
||||
|
||||
+69
-16
@@ -36,6 +36,7 @@ from rowers.forms import (
|
||||
LandingPageForm,PlannedSessionSelectForm,WorkoutSessionSelectForm,
|
||||
PlannedSessionTeamForm,PlannedSessionTeamMemberForm,
|
||||
VirtualRaceSelectForm,WorkoutRaceSelectForm,CourseSelectForm,
|
||||
RaceResultFilterForm,
|
||||
)
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.exceptions import PermissionDenied
|
||||
@@ -6164,7 +6165,6 @@ def user_boxplot_select(request,
|
||||
'waterboattype':waterboattype,
|
||||
}
|
||||
request.session['options'] = options
|
||||
print options
|
||||
|
||||
|
||||
startdate = datetime.datetime.combine(startdate,datetime.time())
|
||||
@@ -9085,7 +9085,6 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
startdatetime
|
||||
)
|
||||
|
||||
print startdatetime
|
||||
try:
|
||||
# aware object can be in any timezone
|
||||
out = startdatetime.astimezone(pytz.utc)
|
||||
@@ -12873,9 +12872,6 @@ def plannedsessions_view(request,timeperiod='thisweek',rowerid=0):
|
||||
|
||||
sps = get_sessions(r,startdate=startdate,enddate=enddate)
|
||||
|
||||
for ps in sps:
|
||||
print ps.name,ps.sessiontype
|
||||
|
||||
completeness = {}
|
||||
actualvalue = {}
|
||||
completiondate = {}
|
||||
@@ -13439,6 +13435,7 @@ def virtualevent_view(request,id=0):
|
||||
else:
|
||||
r = None
|
||||
|
||||
|
||||
try:
|
||||
race = VirtualRace.objects.get(id=id)
|
||||
except VirtualRace.DoesNotExist:
|
||||
@@ -13467,17 +13464,52 @@ def virtualevent_view(request,id=0):
|
||||
if race_can_edit(r,race):
|
||||
buttons += ['editbutton']
|
||||
|
||||
results = VirtualRaceResult.objects.filter(
|
||||
race=race,
|
||||
workoutid__isnull=False,
|
||||
).order_by("duration")
|
||||
if request.method == 'POST':
|
||||
form = RaceResultFilterForm(request.POST)
|
||||
if form.is_valid():
|
||||
cd = form.cleaned_data
|
||||
sex = cd['sex']
|
||||
boattype = cd['boattype']
|
||||
age_min = cd['age_min']
|
||||
age_max = cd['age_max']
|
||||
weightcategory = cd['weightcategory']
|
||||
|
||||
# to-do - add DNS
|
||||
dns = []
|
||||
if timezone.now() > race.evaluation_closure:
|
||||
dns = VirtualRaceResult.objects.filter(
|
||||
results = VirtualRaceResult.objects.filter(
|
||||
race=race,
|
||||
workoutid__isnull=False,
|
||||
boattype__in=boattype,
|
||||
sex__in=sex,
|
||||
weightcategory__in=weightcategory,
|
||||
age__gte=age_min,
|
||||
age__lte=age_max
|
||||
).order_by("duration")
|
||||
|
||||
# to-do - add DNS
|
||||
dns = []
|
||||
if timezone.now() > race.evaluation_closure:
|
||||
dns = VirtualRaceResult.objects.filter(
|
||||
race=race,
|
||||
workoutid__isnull=True,
|
||||
boattype__in=boattype,
|
||||
sex__in=sex,
|
||||
weightcategory__in=weightcategory,
|
||||
age__gte=age_min,
|
||||
age__lte=age_max
|
||||
)
|
||||
else:
|
||||
form = RaceResultFilterForm()
|
||||
|
||||
results = VirtualRaceResult.objects.filter(
|
||||
race=race,
|
||||
workoutid__isnull=True,
|
||||
workoutid__isnull=False,
|
||||
).order_by("duration")
|
||||
|
||||
# to-do - add DNS
|
||||
dns = []
|
||||
if timezone.now() > race.evaluation_closure:
|
||||
dns = VirtualRaceResult.objects.filter(
|
||||
race=race,
|
||||
workoutid__isnull=True,
|
||||
)
|
||||
|
||||
|
||||
@@ -13497,6 +13529,7 @@ def virtualevent_view(request,id=0):
|
||||
'buttons':buttons,
|
||||
'dns':dns,
|
||||
'records':records,
|
||||
'form':form,
|
||||
})
|
||||
|
||||
@login_required()
|
||||
@@ -13558,9 +13591,19 @@ def virtualevent_addboat_view(request,id=0):
|
||||
boattype = cd['boattype']
|
||||
weightcategory = cd['weightcategory']
|
||||
age = cd['age']
|
||||
mix = cd['mix']
|
||||
|
||||
sex = r.sex
|
||||
if mix:
|
||||
sex = 'mixed'
|
||||
|
||||
if boattype == '1x' and r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
sex = r.sex
|
||||
|
||||
if sex == 'not specified':
|
||||
sex = 'male'
|
||||
|
||||
if boattype in boattypes:
|
||||
messages.error(request,"You have already registered in that boat type")
|
||||
url = reverse(virtualevent_view,
|
||||
@@ -13583,7 +13626,7 @@ def virtualevent_addboat_view(request,id=0):
|
||||
duration=datetime.time(0,0),
|
||||
boattype=boattype,
|
||||
coursecompleted=False,
|
||||
sex=r.sex,
|
||||
sex=sex,
|
||||
age=age
|
||||
)
|
||||
|
||||
@@ -13649,8 +13692,18 @@ def virtualevent_register_view(request,id=0):
|
||||
boattype = cd['boattype']
|
||||
weightcategory = cd['weightcategory']
|
||||
age = cd['age']
|
||||
mix = cd['mix']
|
||||
|
||||
sex = r.sex
|
||||
if mix:
|
||||
sex = 'mixed'
|
||||
|
||||
if boattype == '1x' and r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
sex = r.sex
|
||||
|
||||
if sex == 'not specified':
|
||||
sex = 'male'
|
||||
|
||||
record = VirtualRaceResult(
|
||||
userid=r.id,
|
||||
@@ -13664,7 +13717,7 @@ def virtualevent_register_view(request,id=0):
|
||||
duration=datetime.time(0,0),
|
||||
boattype=boattype,
|
||||
coursecompleted=False,
|
||||
sex=r.sex,
|
||||
sex=sex,
|
||||
age=age
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user