def _process_POST(self):
     if 'radioitems' in self._fieldData:
         radioitems = self._fieldData['radioitems']
         radioitems = [item for item in radioitems if not 'remove' in item]
         self._fieldData['radioitems'] = map(self.parseJsonItem, radioitems)
     # For compatibility reason the client side uses yesno
     if (self._fieldData['input'] == 'yesno'):
         self._fieldData['input'] = 'yes/no'
     field = GeneralField(self._section, data=self._fieldData)
     pos = next((i for i, f in enumerate(self._section.getSortedFields()) if f.isDisabled()), None)
     self._section.addToSortedFields(field, i=pos)
     return json.dumps(field.fossilize())
示例#2
0
 def _process_POST(self):
     if 'radioitems' in self._fieldData:
         radioitems = self._fieldData['radioitems']
         radioitems = [item for item in radioitems if not 'remove' in item]
         self._fieldData['radioitems'] = map(self.parseJsonItem, radioitems)
     # For compatibility reason the client side uses yesno
     if (self._fieldData['input'] == 'yesno'):
         self._fieldData['input'] = 'yes/no'
     field = GeneralField(self._section, data=self._fieldData)
     pos = next((i for i, f in enumerate(self._section.getSortedFields())
                 if f.isDisabled()), None)
     self._section.addToSortedFields(field, i=pos)
     return json.dumps(field.fossilize())
示例#3
0
 def _process(self):
     if not self._cancel:
         # setup the server variable with the values for the section field
         tmpSectionField = self._getSession().getVar("tmpSectionField")
         if tmpSectionField == None:
             tmpSectionField = _TmpSectionField(self._getRequestParams(),
                                                None)
         else:
             tmpSectionField.map(self._getRequestParams())
         self._getSession().setVar("tmpSectionField", tmpSectionField)
         #-----
         if self._save:
             #############
             #Change to support sorting fields...
             #self._generalSectionForm.addField(GeneralField(self._generalSectionForm, tmpSectionField.getValues()))
             #
             self._generalSectionForm.addToSortedFields(
                 GeneralField(self._generalSectionForm,
                              tmpSectionField.getValues()))
             self._getSession().removeVar("tmpSectionField")
         else:
             urlfield = urlHandlers.UHConfModifRegFormGeneralSectionFieldAdd.getURL(
                 self._generalSectionForm)
             urlfield.addParam("firstTime", 'no')
             self._redirect(urlfield)
             return
     else:
         self._getSession().removeVar("tmpSectionField")
     self._redirect(
         urlHandlers.UHConfModifRegFormGeneralSection.getURL(
             self._generalSectionForm))
示例#4
0
    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()