Private
Public Access
1
0
This commit is contained in:
2024-05-22 09:48:52 +02:00
parent ef208be1d9
commit 9ccb8dc9f4
6 changed files with 93 additions and 1 deletions

View File

@@ -103,6 +103,7 @@ from rowers.forms import (
CourseConfirmForm, ResampleForm,
TeamUploadOptionsForm, WorkFlowLeftPanelForm, WorkFlowMiddlePanelForm,
WorkFlowLeftPanelElement, WorkFlowMiddlePanelElement,
WorkoutNameTemplateElement,
LandingPageForm, PlannedSessionSelectForm, WorkoutSessionSelectForm,
PlannedSessionTeamForm, PlannedSessionTeamMemberForm,
VirtualRaceSelectForm, WorkoutRaceSelectForm, CourseSelectForm,

View File

@@ -322,6 +322,28 @@ def rower_favoritecharts_view(request, userid=0):
FavoriteChartFormSet = formset_factory(
FavoriteForm, formset=BaseFavoriteFormSet, extra=1)
workoutnametemplate = r.workoutnametemplate
WorkoutNameTemplateFormSet = formset_factory(WorkoutNameTemplateElement, extra=1)
workoutnametemplate_data = [{'element': element} for element in r.workoutnametemplate]
workoutnametemplate_formset = WorkoutNameTemplateFormSet(initial=workoutnametemplate_data, prefix='workoutname')
if request.method == 'POST' and 'workoutname-TOTAL_FORMS' in request.POST:
workoutnametemplate_formset = WorkoutNameTemplateFormSet(request.POST, prefix='workoutname')
newworkoutnametemplate = []
if workoutnametemplate_formset.is_valid():
for form in workoutnametemplate_formset:
element = form.cleaned_data.get('element')
if element != 'None':
newworkoutnametemplate.append(element)
newworkoutnametemplate = [i for i in newworkoutnametemplate if i is not None]
r.workoutnametemplate = newworkoutnametemplate
try:
r.save()
except IntegrityError:
messages.error("Something went wrong")
if request.method == 'POST' and 'staticgrids' in request.POST: # pragma: no cover
staticchartform = StaticChartRowerForm(request.POST, instance=r)
if staticchartform.is_valid():
@@ -400,6 +422,7 @@ def rower_favoritecharts_view(request, userid=0):
'rower': r,
'staticchartform': staticchartform,
'datasettingsform': datasettingsform,
'workoutnametemplate_formset': workoutnametemplate_formset,
}
return render(request, 'favoritecharts.html', context)