filling the settings into forms by querrying the layout first
1 parent 65b8ebe commit 7ab7636f7e847f2c0f278a6f1281e6c70a104812
@benste benste authored on 9 Jul 2011
Showing 2 changed files
View
17
forms.py
required = False,
)
def __init__(self,settings,visible_section,visible_option, *args, **kwargs):
super(ListSettings, self).__init__(*args, **kwargs)
#if settings:raise Exception(settings) #debug
if visible_option:
options=[]
for option in self.layout:
options += option[1:]
if visible_section in sections:
for section in self.layout:
if section[0] == visible_section:
self.layout = [section]
 
if settings:
for section in self.layout:
for option in section[1:]:
#raise Exception(settings)
self.fields[option].initial = settings[option]
#raise Exception(self.fields[option].initial)
class Meta:
"""Class to handle the automatic insertion of fieldsets and divs.
To use it: add a list for each wished fieldset. The first item in
View
20
views.py
the_list.update_config(request.POST)
message = "The list has been updated."
#Provide a form with existing values
else:
#raise Exception(the_list.settings)#debug
testdict = {}
#raise Exception(the_list.settings)#debug
#for key,item in dict(the_list.settings).items():#debug
# testdict[key]=item
form = ListSettings(testdict,visible_section,visible_option)#the_list.settings)
#create form to get layout
form = ListSettings(None,visible_section,visible_option)
#create a Dict of all settings which are used in the form
used_settings={}
for section in form.layout:
for option in section[1:]:
used_settings[option] = the_list.settings[option]
#recreate the form using the settings
form = ListSettings(used_settings,visible_section,visible_option)
#TODO
# USE different Forms for each fieldset NO META SETTINGS !!
# querry settings when creating the fields not parsing the whole settings
#