adding bulk action assign rowers
This commit is contained in:
@@ -116,7 +116,8 @@ from rowers.forms import (
|
||||
StravaChartForm, FitnessFitForm, PerformanceManagerForm,
|
||||
TrainingPlanBillingForm, InstantPlanSelectForm,
|
||||
TrainingZonesForm, InstrokeForm, InStrokeMultipleCompareForm,
|
||||
ForceCurveMultipleCompareForm, PlanByRscoreForm
|
||||
ForceCurveMultipleCompareForm, PlanByRscoreForm,
|
||||
AssignChoices,
|
||||
)
|
||||
|
||||
from django.urls import reverse, reverse_lazy
|
||||
@@ -267,6 +268,7 @@ from rowers.tasks import (
|
||||
handle_send_email_instantplan_notification,
|
||||
handle_nk_async_workout,
|
||||
check_tp_workout_id,
|
||||
handle_assignworkouts,
|
||||
)
|
||||
|
||||
from scipy.signal import savgol_filter
|
||||
|
||||
@@ -2031,6 +2031,12 @@ def workouts_bulk_actions(request):
|
||||
'Export to {destination} of workout {id} failed'.format(
|
||||
id=encoder.encode_hex(w.id),
|
||||
destination=destination))
|
||||
elif action == 'rower assign':
|
||||
assignchoices = AssignChoices(request.POST)
|
||||
if assignchoices.is_valid():
|
||||
remove_workout = assignchoices.cleaned_data['remove_workout']
|
||||
rowers = assignchoices.cleaned_data['destination']
|
||||
_ = myqueue(queuehigh, handle_assignworkouts, workouts, rowers, remove_workout)
|
||||
url = reverse('workouts_view')
|
||||
return HttpResponseRedirect(url)
|
||||
else: # pragma: no cover
|
||||
@@ -2041,6 +2047,12 @@ def workouts_bulk_actions(request):
|
||||
exportchoice = ExportChoices()
|
||||
actionform = WorkoutBulkActions()
|
||||
actionform.fields["action"].initial = action
|
||||
assignchoices = AssignChoices()
|
||||
teams = Team.objects.filter(manager=request.user)
|
||||
assignchoices.fields["destination"].queryset = Rower.objects.filter(
|
||||
team__in=teams
|
||||
).distinct().order_by("user__last_name", "user__first_name").exclude(rowerplan='freecoach')
|
||||
assignchoices.fields["destination"].initial = []
|
||||
form = WorkoutMultipleCompareForm()
|
||||
form.fields["workouts"].queryset = Workout.objects.filter(id__in=[w.id for w in workouts])
|
||||
form.fields["workouts"].initial = workouts
|
||||
@@ -2049,6 +2061,7 @@ def workouts_bulk_actions(request):
|
||||
{'action':action,
|
||||
'exportchoice':exportchoice,
|
||||
'actionform':actionform,
|
||||
'assignchoices': assignchoices,
|
||||
'form':form,
|
||||
'workouts':workouts})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user