예제 #1
0
 def _oidlist(self):
     _ = self.request.getText
     form = self._make_form()
     for oid in self.request.user.openids:
         name = "rm-%s" % hash_new('sha1', oid).hexdigest()
         form.append(html.INPUT(type="checkbox", name=name, id=name))
         form.append(html.LABEL(for_=name).append(html.Text(oid)))
         form.append(html.BR())
     self._make_row(_("Current OpenIDs"), [form], valign='top')
     label = _("Remove selected")
     form.append(html.BR())
     form.append(html.INPUT(type="submit", name="remove", value=label))
예제 #2
0
 def _trust_root_list(self):
     _ = self.request.getText
     form = self._make_form()
     for root in self.request.user.openid_trusted_roots:
         display = base64.decodestring(root)
         name = 'rm-%s' % root
         form.append(html.INPUT(type="checkbox", name=name, id=name))
         form.append(html.LABEL(for_=name).append(html.Text(display)))
         form.append(html.BR())
     self._make_row(_("Trusted websites"), [form], valign='top')
     label = _("Remove selected")
     form.append(html.BR())
     form.append(html.INPUT(type="submit", name="remove", value=label))
예제 #3
0
 def _addoidform(self):
     _ = self.request.getText
     form = self._make_form()
     # go back to this page
     form.append(html.INPUT(type="hidden", name="sub", value="oid"))
     label = _("Add OpenID")
     form.append(html.INPUT(type="text", size="32",
                            name="openid_identifier",
                            id="openididentifier"))
     form.append(html.BR())
     form.append(html.INPUT(type="submit", name="add", value=label))
     self._make_row(_('Add OpenID'), [form])
예제 #4
0
    def testCreate(self):
        """widget.html: creating html widgets

        TO DO: add tests for all elements by HTML 4 spec.
        """
        tests = (
            # description, call, expected
            ('Create text', html.Text('<br> &'), '&lt;br&gt; &amp;'),
            ('Create raw html', html.Raw('<br> &amp;'), '<br> &amp;'),
            ('Create br', html.BR(), '<br>'),
            ('Create hr', html.HR(), '<hr>'),
            ('Create p', html.P(), '<p></p>'),
        )

        for description, obj, expected in tests:
            result = unicode(obj)
            assert result == expected
예제 #5
0
파일: userprefs.py 프로젝트: aahlad/soar
def _create_prefs_page(request, sel=None):
    _ = request.getText
    plugins = wikiutil.getPlugins('userprefs', request.cfg)
    ret = html.P()
    ret.append(html.Text(_("Please choose:")))
    ret.append(html.BR())
    items = html.UL()
    ret.append(items)
    for sub in plugins:
        if sub in request.cfg.userprefs_disabled:
            continue
        cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
        obj = cls(request)
        if not obj.allowed():
            continue
        url = request.page.url(request, {'action': 'userprefs', 'sub': sub})
        lnk = html.LI().append(html.A(href=url).append(html.Text(obj.title)))
        items.append(lnk)
    return unicode(ret)
예제 #6
0
    def create_form(self):
        """ Create the complete HTML form code. """
        _ = self._
        request = self.request
        self._form = self.make_form()

        if request.user.valid:
            buttons = [('save', _('Save')), ('cancel', _('Cancel')), ]
            uf_remove = self.cfg.user_form_remove
            uf_disable = self.cfg.user_form_disable
            for attr in request.user.auth_attribs:
                uf_disable.append(attr)
            for key, label, type, length, textafter in self.cfg.user_form_fields:
                default = self.cfg.user_form_defaults[key]
                if not key in uf_remove:
                    if key in uf_disable:
                        self.make_row(_(label),
                                  [html.INPUT(type=type, size=length, name=key, disabled="disabled",
                                   value=getattr(request.user, key)), ' ', _(textafter), ])
                    else:
                        self.make_row(_(label),
                                  [html.INPUT(type=type, size=length, name=key, value=getattr(request.user, key)), ' ', _(textafter), ])

            if not self.cfg.theme_force and not "theme_name" in self.cfg.user_form_remove:
                self.make_row(_('Preferred theme'), [self._theme_select()])

            if not self.cfg.editor_force:
                if not "editor_default" in self.cfg.user_form_remove:
                    self.make_row(_('Editor Preference'), [self._editor_default_select()])
                if not "editor_ui" in self.cfg.user_form_remove:
                    self.make_row(_('Editor shown on UI'), [self._editor_ui_select()])

            if not "tz_offset" in self.cfg.user_form_remove:
                self.make_row(_('Time zone'), [
                    _('Your time is'), ' ',
                    self._tz_select(),
                    html.BR(),
                    _('Server time is'), ' ',
                    time.strftime(self.cfg.datetime_fmt, util.timefuncs.tmtuple()),
                    ' (UTC)',
                ])

            if not "datetime_fmt" in self.cfg.user_form_remove:
                self.make_row(_('Date format'), [self._dtfmt_select()])

            if not "language" in self.cfg.user_form_remove:
                self.make_row(_('Preferred language'), [self._lang_select()])

            # boolean user options
            bool_options = []
            checkbox_fields = self.cfg.user_checkbox_fields
            checkbox_fields.sort(lambda a, b: cmp(a[1](_), b[1](_)))
            for key, label in checkbox_fields:
                if not key in self.cfg.user_checkbox_remove:
                    bool_options.extend([
                        html.INPUT(type="checkbox", name=key, value="1",
                            checked=getattr(request.user, key, 0),
                            disabled=key in self.cfg.user_checkbox_disable and True or None),
                        ' ', label(_), html.BR(),
                    ])
            self.make_row(_('General options'), bool_options, valign="top")

            self.make_row(_('Quick links'), [
                html.TEXTAREA(name="quicklinks", rows="6", cols="50")
                    .append('\n'.join(request.user.getQuickLinks())),
            ], valign="top")

            self._form.append(html.INPUT(type="hidden", name="action", value="userprefs"))
            self._form.append(html.INPUT(type="hidden", name="handler", value="prefs"))

            ticket = wikiutil.createTicket(request)
            self._form.append(html.INPUT(type="hidden", name="ticket", value="%s" % ticket))

        # Add buttons
        button_cell = []
        for name, label in buttons:
            if not name in self.cfg.user_form_remove:
                button_cell.extend([
                    html.INPUT(type="submit", name=name, value=label),
                    ' ',
                ])
        self.make_row('', button_cell)

        return unicode(self._form)