Private
Public Access
1
0
This commit is contained in:
2024-05-22 11:02:24 +02:00
parent 38b2a71e25
commit c1a027db6b
5 changed files with 65 additions and 43 deletions

View File

@@ -329,20 +329,27 @@ def rower_favoritecharts_view(request, userid=0):
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)
if 'defaults_workoutname' in request.POST:
r.workoutnametemplate = ['date','name','distance','ownerfirst','ownerlast','duration','boattype','workouttype']
r.save()
else:
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")
newworkoutnametemplate = [i for i in newworkoutnametemplate if i is not None]
r.workoutnametemplate = newworkoutnametemplate
try:
r.save()
except IntegrityError:
messages.error("Something went wrong")
workoutnametemplate_data = [{'element': element} for element in r.workoutnametemplate]
workoutnametemplate_formset = WorkoutNameTemplateFormSet(initial=workoutnametemplate_data, prefix='workoutname')
if request.method == 'POST' and 'staticgrids' in request.POST: # pragma: no cover
staticchartform = StaticChartRowerForm(request.POST, instance=r)