Private
Public Access
1
0

workflow config form working

This commit is contained in:
Sander Roosendaal
2017-10-18 15:44:51 +02:00
parent 3bec917456
commit 13dee6305d
4 changed files with 108 additions and 45 deletions

View File

@@ -1,4 +1,5 @@
from django import forms
from django.contrib.admin.widgets import FilteredSelectMultiple
from rowers.models import Workout
from rowers.rows import validate_file_extension,must_be_csv
from django.contrib.auth.forms import UserCreationForm
@@ -58,37 +59,72 @@ class DocumentsForm(forms.Form):
fields = ['title','file','workouttype','fileformat']
from utils import workflowleftpanel,workflowmiddlepanel
defaultleft = [p[0] for p in workflowleftpanel]
defaultmiddle = [p[0] for p in workflowmiddlepanel]
# Form to change Workflow page layout
class WorkFlowLeftPanelForm(forms.Form):
panels = ['panel_editbuttons.html','panel_stats.html','panel_staticchart.html']
leftpanel = forms.MultipleChoiceField(label='Left Panel',
choices=workflowleftpanel,
initial=panels)
panels = defaultleft
leftpanel = forms.MultipleChoiceField(
label='',
choices=workflowleftpanel,
initial=panels,
widget=FilteredSelectMultiple(
('elements'),
False
)
)
class Media:
css = {
'all':['admin/css/widgets.css',]
# 'css/uid-manage-form.css'],
}
js = ['/admin/jsi18n/']
def __init__(self, *args, **kwargs):
if 'instance' in kwargs:
r = kwargs.pop('instance')
panels = r.workflowleftpanel
self.base_fields['leftpanel'].initial=panels
else:
panels = ['panel_editbuttons.html','panel_stats.html','panel_staticchart.html']
panels = defaultleft
super(WorkFlowLeftPanelForm,self).__init__(*args, **kwargs)
class WorkFlowMiddlePanelForm(forms.Form):
panels = ['panel_statcharts.html',
'flexthumbnails.html',
'panel_summary.html']
panels = defaultmiddle
middlepanel = forms.MultipleChoiceField(
label='',
choices=workflowmiddlepanel,
initial=panels,
widget=FilteredSelectMultiple(
('elements'),
False
)
)
class Media:
css = {
'all':['admin/css/widgets.css',]
# 'css/uid-manage-form.css'],
}
js = ['/admin/jsi18n/']
middlepanel = forms.MultipleChoiceField(label='Middle Panel',
choices=workflowmiddlepanel,
initial=panels)
def __init__(self, *args, **kwargs):
if 'instance' in kwargs:
r = kwargs.pop('instance')
panels = r.workflowleftpanel
panels = r.workflowmiddlepanel
self.base_fields['middlepanel'].initial=panels
else:
panels = ['panel_editbuttons.html','panel_stats.html','panel_staticchart.html']
panels = defaultmiddle
super(WorkFlowMiddlePanelForm,self).__init__(*args, **kwargs)