Ejemplo n.º 1
0
    def make_content(self):
        nperm = None
        if self.owner_form:
            nperms = [
                nperms for nperms in self.owner_form.get_nperms()
                if nperms.split('.')[-1] == self.get_nperm()
            ]
            nperm = nperms[0] if nperms else None
        self.content = []
        # add/remove emtpy choice according
        if self.required and self.choices and self.choices[
                0] == self.empty_choice:  # remove empty choice:
            self.choices.pop(0)
        elif not self.required and (not self.choices or
                                    (self.choices and self.choices[0] !=
                                     self.empty_choice)):  # add empty choice:
            self.choices.insert(0, self.empty_choice)

        if self.choices:
            user = cherrypy.session.get('user')
            for value, caption in list(self.choices):
                if user and nperm and user.has_nperm(nperm, value):
                    continue
                if unicode(value) == unicode(self.value):
                    self.add(
                        option(attr(value=value, selected='selected'),
                               caption))
                else:
                    self.add(option(attr(value=value), caption))
Ejemplo n.º 2
0
 def make_content(self):
     self.content = []
     if self.choices:
         for value, caption in self.choices:
             if unicode(value) in self.value:
                 self.add(option(attr(value=value, selected='selected'), caption))
             else:
                 self.add(option(attr(value=value), caption))
Ejemplo n.º 3
0
 def make_content(self):
     self.content = []
     if self.choices:
         for value, caption in self.choices:
             if unicode(value) in self.value:
                 self.add(
                     option(attr(value=value, selected='selected'),
                            caption))
             else:
                 self.add(option(attr(value=value), caption))
Ejemplo n.º 4
0
 def make_content(self):
     self.content = []
     if self.tag == u'select':
         self.add(attr(multiple=u"multiple"))
     if self.choices:
         for value, caption in self.choices:
             if unicode(value) in self.value:
                 self.add(
                     option(attr(value=value, selected='selected'),
                            caption))
             else:
                 self.add(option(attr(value=value), caption))
Ejemplo n.º 5
0
    def make_content(self):
        nperm = None
        if self.owner_form:
            nperms = [
                nperms for nperms in self.owner_form.get_nperms()
                if nperms.split('.')[-1] == self.get_nperm()
            ]
            nperm = nperms[0] if nperms else None
        self.content = []
        # add/remove empty choice according
        if self.required and self.choices and self.choices[
                0] == self.empty_choice:  # remove empty choice:
            self.choices.pop(0)
        elif not self.required and (not self.choices or
                                    (self.choices and self.choices[0] !=
                                     self.empty_choice)):  # add empty choice:
            self.choices.insert(0, self.empty_choice)

        if self.choices:
            user = cherrypy.session.get('user')
            for value, caption in list(self.choices):
                if user and nperm and user.has_nperm(nperm, value):
                    continue
                if self.as_radio_buttons:
                    item = label(
                        input(attr(type='radio', name=self.name, value=value),
                              tagid('radio_input')), caption)
                else:
                    item = option(attr(value=value), caption)
                if unicode(value) == unicode(self.value):
                    if self.as_radio_buttons:
                        item.radio_input.checked = 'checked'
                    else:
                        item.selected = 'selected'
                self.add(item)
Ejemplo n.º 6
0
 def make_content(self):
     nperm = None
     if self.owner_form:
         nperms = [nperms for nperms in self.owner_form.get_nperms() if 
             nperms.split('.')[-1] == self.get_nperm()]
         nperm = nperms[0] if nperms else None
     self.content = []
     # add/remove emtpy choice according 
     if self.required and self.choices and self.choices[0] == self.empty_choice: # remove empty choice:
         self.choices.pop(0)
     elif not self.required and (not self.choices or (self.choices and self.choices[0] != self.empty_choice)): # add empty choice:
         self.choices.insert(0, self.empty_choice)
         
     if self.choices:
         user = cherrypy.session.get('user')
         for value, caption in list(self.choices):
             if user and nperm and user.has_nperm(nperm, value):
                 continue
             if unicode(value) == unicode(self.value):
                 self.add(option(attr(value=value, selected='selected'), caption))
             else:
                 self.add(option(attr(value=value), caption))