standards_view and standard_view
This commit is contained in:
@@ -2197,6 +2197,7 @@ from django.core.validators import RegexValidator,validate_email
|
||||
class StandardCollection(models.Model):
|
||||
name = models.CharField(max_length=150)
|
||||
manager = models.ForeignKey(User, null=True,on_delete=models.CASCADE)
|
||||
notes = models.CharField(blank=True,null=True,max_length=1000)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -2204,6 +2205,7 @@ class StandardCollection(models.Model):
|
||||
class CourseStandard(models.Model):
|
||||
name = models.CharField(max_length=150)
|
||||
coursedistance = models.IntegerField()
|
||||
coursetime = models.CharField(max_length=100,default="")
|
||||
coursestandard = models.FloatField() # average boat speed
|
||||
agemin = models.IntegerField(default=0)
|
||||
agemax = models.IntegerField(default=120)
|
||||
|
||||
@@ -4,9 +4,9 @@ import pandas as pd
|
||||
import arrow
|
||||
import datetime
|
||||
|
||||
def save_scoring(name,user,filename,id=0):
|
||||
def save_scoring(name,user,filename,id=0,notes=""):
|
||||
if id==0:
|
||||
collection = StandardCollection(name=name,manager=user)
|
||||
collection = StandardCollection(name=name,manager=user,notes=notes)
|
||||
collection.save()
|
||||
standards = CourseStandard.objects.filter(standardcollection=collection)
|
||||
for standard in standards:
|
||||
@@ -15,6 +15,7 @@ def save_scoring(name,user,filename,id=0):
|
||||
try:
|
||||
collection = StandardCollection.objects.get(id=id)
|
||||
collection.name = name
|
||||
collection.notes = notes
|
||||
collection.save()
|
||||
|
||||
except StandardCollection.DoesNotExist:
|
||||
@@ -88,6 +89,7 @@ def save_scoring(name,user,filename,id=0):
|
||||
name=name,
|
||||
coursedistance=coursedistance,
|
||||
coursestandard=coursestandard,
|
||||
coursetime=coursetime,
|
||||
agemin=agemin,
|
||||
agemax=agemax,
|
||||
boatclass=boatclass,
|
||||
|
||||
84
rowers/templates/list_standards.html
Normal file
84
rowers/templates/list_standards.html
Normal file
@@ -0,0 +1,84 @@
|
||||
{% extends "newbase.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}Rowsandall Course Standards List{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<style>
|
||||
#mypointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<h1>Standards Collections</h1>
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_3">
|
||||
{% if standards %}
|
||||
<p>
|
||||
<table width="100%" class="listtable shortpadded">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> Name</th>
|
||||
<th> Maintainer</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for standard in standards %}
|
||||
<tr>
|
||||
<td>{{ standard.name }} </td>
|
||||
<td>{{ standard.manager.first_name }} {{ standard.manager.last_name }}</td>
|
||||
<td>
|
||||
{% if standard.manager == user %}
|
||||
<a href="/rowers/standards/{{ standard.id }}/">{{ standard.name }}</a>
|
||||
{% else %}
|
||||
<a href="/rowers/standards/{{ standard.id }}/">{{ standard.name }}</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</p>
|
||||
{% else %}
|
||||
<p> No standards found </p>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
<form id="searchform" action="/rowers/list-standards/"
|
||||
method="get" accept-charset="utf-8">
|
||||
{{ searchform }}
|
||||
<input type="submit" value="GO"></input>
|
||||
</form>
|
||||
</p>
|
||||
<p>
|
||||
<a href="/rowers/standards/upload/">Add Standards</a>
|
||||
</p>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="grid_4">
|
||||
<h2>How-to</h2>
|
||||
<p>
|
||||
A set of Course Standard Times allows you to calculate a score for
|
||||
each participant on how well they have done against the course
|
||||
standard time for their category. This allows for comparison
|
||||
and competition between the different categories.
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_racing.html' %}
|
||||
{% endblock %}
|
||||
@@ -131,6 +131,11 @@
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li id="standards">
|
||||
<a href="/rowers/list-standards/">
|
||||
<i class="fas fa-award fa-fw"></i> Course Time Standards
|
||||
</a>
|
||||
</li>
|
||||
</ul> <!-- cd-accordion-menu -->
|
||||
|
||||
{% include 'menuscript.html' %}
|
||||
|
||||
72
rowers/templates/standard_view.html
Normal file
72
rowers/templates/standard_view.html
Normal file
@@ -0,0 +1,72 @@
|
||||
{% extends "newbase.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
{% load leaflet_tags %}
|
||||
|
||||
{% block meta %}
|
||||
{% leaflet_js %}
|
||||
{% leaflet_css %}
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{{ standard.name }} {% endblock %}
|
||||
{% block og_title %}{{ standard.name }} {% endblock %}
|
||||
{% block main %}
|
||||
|
||||
<h1>{{ standard.name }}</h1>
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_2">
|
||||
<table class="listtable shortpadded" width="100%">
|
||||
<tr>
|
||||
<th>Name</th><td>{{ collection.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Manager</th><td>{{ collection.manager.first_name }} {{ collection.manager.last_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Notes</th><td>{{ collection.notes|linebreaks }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
<li class="grid_4">
|
||||
<h2>Standard Times</h2>
|
||||
<table class="listtable shortpadded" width="100%"?
|
||||
<tr>
|
||||
<th>Name<a href="?order_by=name">▲</a><a href="?order_by=-name">▼</a></th>
|
||||
<th>Distance<a href="?order_by=coursedistance">▲</a><a href="?order_by=-coursedistance">▼</a></th>
|
||||
<th>Standard Time<a href="?order_by=coursetime">▲</a><a href="?order_by=-coursetime">▼</a></th>
|
||||
<th>Boat Class<a href="?order_by=boatclass">▲</a><a href="?order_by=-boatclass">▼</a></th>
|
||||
<th>Boat Type<a href="?order_by=boattype">▲</a><a href="?order_by=-boattype">▼</a></th>
|
||||
<th>Gender<a href="?order_by=sex">▲</a><a href="?order_by=-sex">▼</a></th>
|
||||
<th>Weight Class<a href="?order_by=weightclass">▲</a><a href="?order_by=-weightclass">▼</a></th>
|
||||
<th>Adaptive Class<a href="?order_by=adaptiveclass">▲</a><a href="?order_by=-adaptiveclass">▼</a></th>
|
||||
<th>Skill Class<a href="?order_by=skillclass">▲</a><a href="?order_by=-skillclass">▼</a></th>
|
||||
<th>Minimum<a href="?order_by=agemin">▲</a><a href="?order_by=-agemin">▼</a>/Maximum Age<a href="?order_by=agemax">▲</a><a href="?order_by=-agemax">▼</a></th>
|
||||
</tr>
|
||||
{% for standard in standards %}
|
||||
<tr>
|
||||
<td>{{ standard.name }}</td>
|
||||
<td>{{ standard.coursedistance }}</td>
|
||||
<td>{{ standard.coursetime }}</td>
|
||||
<td>{{ standard.boatclass }}</td>
|
||||
<td>{{ standard.boattype }}</td>
|
||||
<td>{{ standard.sex }}</td>
|
||||
<td>{{ standard.weightclass }}</td>
|
||||
<td>{{ standard.adaptiveclass }}</td>
|
||||
<td>{{ standard.skillclass }}</td>
|
||||
<td>{{ standard.agemin }}/{{ standard.agemax }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_racing.html' %}
|
||||
{% endblock %}
|
||||
@@ -201,6 +201,7 @@ urlpatterns = [
|
||||
views.virtualevent_results_download_view,name='virtualevent_results_download_view'),
|
||||
re_path(r'^list-workouts/$',views.workouts_view,name='workouts_view'),
|
||||
re_path(r'^list-courses/$',views.courses_view,name='courses_view'),
|
||||
re_path(r'^list-standards/$',views.standards_view,name='standards_view'),
|
||||
re_path(r'^courses/upload/$',views.course_upload_view,name='course_upload_view'),
|
||||
re_path(r'^workout/addmanual/(?P<raceid>\d+)$',views.addmanual_view,name='addmanual_view'),
|
||||
re_path(r'^workout/addmanual/$',views.addmanual_view,name='addmanual_view'),
|
||||
@@ -752,6 +753,7 @@ urlpatterns = [
|
||||
re_path(r'^courses/(?P<id>\d+)/replace/$',views.course_replace_view,
|
||||
name='course_replace_view'),
|
||||
re_path(r'^courses/(?P<id>\d+)/$',views.course_view,name='course_view'),
|
||||
re_path(r'^standards/(?P<id>\d+)/$',views.standard_view,name='standard_view'),
|
||||
re_path(r'^courses/(?P<id>\d+)/map/$',views.course_map_view,name='course_map_view'),
|
||||
# URLS to be created
|
||||
re_path(r'^help/$',TemplateView.as_view(template_name='help.html'), name='help'),
|
||||
|
||||
@@ -35,6 +35,39 @@ def courses_view(request):
|
||||
'rower':r,
|
||||
})
|
||||
|
||||
# List Courses
|
||||
def standards_view(request):
|
||||
r = getrower(request.user)
|
||||
|
||||
standards = StandardCollection.objects.all().order_by("name")
|
||||
print(standards)
|
||||
|
||||
# add search processing
|
||||
query = request.GET.get('q')
|
||||
if query:
|
||||
query_list = query.split()
|
||||
standards = StandardCollection.objects.filter(
|
||||
reduce(operator.and_,
|
||||
(Q(name__icontains=q) for q in query_list)) |
|
||||
reduce(operator.and_,
|
||||
(Q(country__icontains=q) for q in query_list)) |
|
||||
reduce(operator.and_,
|
||||
(Q(notes__icontains=q) for q in query_list))
|
||||
)
|
||||
searchform = SearchForm(initial={'q':query})
|
||||
else:
|
||||
searchform = SearchForm()
|
||||
|
||||
print(standards)
|
||||
|
||||
return render(request,'list_standards.html',
|
||||
{'standards':standards,
|
||||
'active':'nav-racing',
|
||||
'searchform':searchform,
|
||||
'rower':r,
|
||||
})
|
||||
|
||||
|
||||
|
||||
# for ajax calls
|
||||
def course_map_view(request,id=0):
|
||||
@@ -249,6 +282,50 @@ def course_view(request,id=0):
|
||||
}
|
||||
)
|
||||
|
||||
def standard_view(request,id=0):
|
||||
try:
|
||||
collection = StandardCollection.objects.get(id=id)
|
||||
except StandardCollection.DoesNotExist:
|
||||
return Http404("Standard Collection does not exist")
|
||||
|
||||
r = getrower(request.user)
|
||||
|
||||
orderby = request.GET.get('order_by')
|
||||
|
||||
if orderby is not None:
|
||||
standards = CourseStandard.objects.filter(
|
||||
standardcollection=collection
|
||||
).order_by(orderby,"-coursestandard","agemax","agemin","sex","name")
|
||||
else:
|
||||
standards = CourseStandard.objects.filter(
|
||||
standardcollection=collection
|
||||
).order_by("-coursestandard","agemax","agemin","sex","name")
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url': reverse('virtualevents_view'),
|
||||
'name': 'Challenges'
|
||||
},
|
||||
{
|
||||
'url': reverse(standards_view),
|
||||
'name': 'Standards'
|
||||
},
|
||||
{
|
||||
'url': reverse(standard_view,kwargs={'id':collection.id}),
|
||||
'name': collection.name
|
||||
},
|
||||
]
|
||||
|
||||
return render(request, 'standard_view.html',
|
||||
{
|
||||
'active':'nav-racing',
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'collection':collection,
|
||||
'standards':standards,
|
||||
'rower':r,
|
||||
}
|
||||
)
|
||||
|
||||
@login_required()
|
||||
@permission_required('racelogo.delete_logo',fn=get_logo_by_pk,raise_exception=True)
|
||||
def logo_delete_view(request,id=0):
|
||||
|
||||
@@ -113,7 +113,7 @@ from rowers.models import (
|
||||
RaceLogo,RowerBillingAddressForm,PaidPlan,
|
||||
AlertEditForm, ConditionEditForm,
|
||||
PlannedSessionComment,CoachRequest,CoachOffer,
|
||||
VideoAnalysis,ShareKey,
|
||||
VideoAnalysis,ShareKey,StandardCollection,CourseStandard,
|
||||
)
|
||||
from rowers.models import (
|
||||
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
|
||||
|
||||
Reference in New Issue
Block a user