def _process_POST(self): pos = next((i for i, f in enumerate(self._regForm.getSortedForms()) if not f.isEnabled()), None) section = GeneralSectionForm(self._regForm, data=self._sectionHeader) self._regForm.addGeneralSectionForm(section, preserveTitle=True, pos=pos) return json.dumps(section.fossilize())
def perform(self): self._conf.getRegistrationForm().addGeneralSectionForm( GeneralSectionForm(self._conf.getRegistrationForm()))
def conf_created(self,conf,parent): _sectionHeader = {} _sectionHeader["title"] = "Representation" _sectionHeader["description"] = "Description" regForm = conf.getRegistrationForm() pos = next((i for i, f in enumerate(regForm.getSortedForms()) if not f.isEnabled()), None) section = GeneralSectionForm(regForm, data=_sectionHeader) section.directives = "nd-my-section" #to rename nd-representation-section govt = { "radioitems":[ {"id":"isNew","caption":"No"}, {"id":"isNew","caption":"Yes"} ], "input":"radio", "disabled":False, "caption":"Government Representative", "inputType":"dynamic-dropdown", "mandatory": True, "defaultItem": "No" } field = GeneralField(section, data=govt) field._directives = "nd-dynamic-dropdown-field" field.directives = { "ng-model":"representationType.grmodel", "ng-options":"gr for (gr,reptypes) in representationTypes" } pos = next((i for i, f in enumerate(section.getSortedFields()) if f.isDisabled()), None) section.addToSortedFields(field, i=pos) others = { "radioitems":[], "input":"radio", "disabled":False, "inputType":"dynamic-dropdown" } captions = [ ( 'Country Representative', True, { "ng-show": "representationType.grmodel==representationTypes['Yes']", "ng-model":"representationType.ctrymodel", "ng-options":"country for (country,name) in countryList" } ), ( 'Representation Type', True, { "ng-model":"representationType.rtmodel", "ng-options":"reptype for (reptype,repsubtypes) in representationType.grmodel" } ), ( 'Rep. Sub Type', True, { "ng-model":"representationType.rstmodel", "ng-options":"repsubtype for (repsubtype,empty) in representationType.rtmodel" } ), ( 'Contact Type', True, { "ng-model":"representationType.ctmodel", "ng-options":"contact for (contact,empty) in contactTypes" } ), ( 'Organization Representative', False, { "ng-model":"representationType.orgmodel", "ng-options":"organization for (organization,code) in organizationList" } ) ] for caption,mandatory,directives in captions: others["caption"]=caption others["mandatory"]=mandatory field = GeneralField(section, data=others) field.directives = directives pos = next((i for i, f in enumerate(section.getSortedFields()) if f.isDisabled()), None) section.addToSortedFields(field, i=pos) regForm.addGeneralSectionForm(section, preserveTitle=True, ) print "Section ID is %s" % section.getId()