standards_view and standard_view
This commit is contained in:
@@ -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