Private
Public Access
1
0

reducing queryset should be using exclude

This commit is contained in:
Sander Roosendaal
2018-11-12 09:08:56 +01:00
parent a6222054f8
commit 04a988430b
2 changed files with 12 additions and 5 deletions

View File

@@ -650,9 +650,15 @@ class CourseSelectForm(forms.Form):
course = forms.ModelChoiceField(queryset=GeoCourse.objects.all()) course = forms.ModelChoiceField(queryset=GeoCourse.objects.all())
class WorkoutMultipleCompareForm(forms.Form): class WorkoutMultipleCompareForm(forms.Form):
workouts = forms.ModelMultipleChoiceField(queryset=Workout.objects.all(), workouts = forms.ModelMultipleChoiceField(
widget=forms.CheckboxSelectMultiple()) queryset=Workout.objects.filter(),
widget=forms.CheckboxSelectMultiple())
def __init__(self, *args, **kwargs):
super(WorkoutMultipleCompareForm,self).__init__(*args,**kwargs)
self.fields['workouts'].queryset = Workout.objects.filter()
class PlannedSessionMultipleCloneForm(forms.Form): class PlannedSessionMultipleCloneForm(forms.Form):
plannedsessions = forms.ModelMultipleChoiceField( plannedsessions = forms.ModelMultipleChoiceField(
queryset=PlannedSession.objects.all(), queryset=PlannedSession.objects.all(),

View File

@@ -5405,7 +5405,7 @@ def team_comparison_select(request,
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes) workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
if rankingonly: if rankingonly:
workouts = [w for w in workouts if w.rankingpiece] workouts = workouts.exclude(rankingpiece=False)
query = request.GET.get('q') query = request.GET.get('q')
if query: if query:
@@ -6361,7 +6361,7 @@ def user_boxplot_select(request,
# workouttypes = [w for w in workouttypes if w not in mytypes.otwtypes] # workouttypes = [w for w in workouttypes if w not in mytypes.otwtypes]
if rankingonly: if rankingonly:
workouts = [w for w in workouts if w.rankingpiece] workouts = workouts.exclude(rankingpiece=False)
query = request.GET.get('q') query = request.GET.get('q')
if query: if query:
@@ -6775,7 +6775,8 @@ def workouts_view(request,message='',successmessage='',
startdatetime__lte=activity_enddate).order_by("-startdatetime") startdatetime__lte=activity_enddate).order_by("-startdatetime")
if rankingonly: if rankingonly:
workouts = [w for w in workouts if w.rankingpiece] workouts = workouts.exclude(rankingpiece=False)
query = request.GET.get('q') query = request.GET.get('q')
if query: if query: