# HG changeset patch # User Aurelien Campeas # Date 1234377256 -3600 # Node ID 47f2ee781d6d032b52de4e2b1acec96e91d7e390 # Parent 40c7c2cf07974ccdde962b2e221e9cfd8f91d828 [preferences] de-uglify a bit, remove useless parameter diff -r 40c7c2cf0797 -r 47f2ee781d6d web/views/management.py --- a/web/views/management.py Wed Feb 11 19:11:55 2009 +0100 +++ b/web/views/management.py Wed Feb 11 19:34:16 2009 +0100 @@ -284,12 +284,15 @@ _('contentnavigation') -def make_togglable_link(nodeid, label, cookiename, cookievalue): +def make_togglable_link(nodeid, label, cookiename): """builds a HTML link that switches the visibility & remembers it""" - action = u"javascript: toggle_and_remember_visibility('%s', '%s', '%s')" % \ - (nodeid, cookiename, cookievalue) + action = u"javascript: toggle_and_remember_visibility('%s', '%s')" % \ + (nodeid, cookiename) return u'%s' % (action, label) +def css_class(someclass): + return someclass and 'class="%s"' % someclass or '' + class SystemEpropertiesForm(FormMixIn, StartupView): controller = 'edit' id = 'systemepropertiesform' @@ -304,12 +307,12 @@ """return the url associated with this view. We can omit rql here""" return self.build_url('view', vid=self.id) - def _cookie_name_from_group(self, group): - return str('%s_property_%s' % (self.config.appid, group)) + def _cookie_name(self, somestr): + return str('%s_property_%s' % (self.config.appid, somestr)) def _group_status(self, group, default=u'hidden'): cookies = self.req.get_cookie() - cookiename = self._cookie_name_from_group(group) + cookiename = self._cookie_name(group) cookie = cookies.get(cookiename) if cookie is None: cookies[cookiename] = default @@ -351,23 +354,21 @@ w(self.error_message()) for label, group, form in sorted((_(g), g, f) for g, f in mainopts.iteritems()): - status = self._group_status(group) #hidden, or not ? + status = css_class(self._group_status(group)) #'hidden' (collapsed), or '' (open) ? w(u'

%s

\n' % (make_togglable_link('fieldset_' + group, label, - self._cookie_name_from_group(group), status))) - statusclass = status and 'class="%s"' % status or '' - w(u'
' % (group, statusclass)) + self._cookie_name(group)))) + w(u'
' % (group, status)) w(u'
') w(form) w(u'
') for label, group, objects in sorted((_(g), g, o) for g, o in groupedopts.iteritems()): - status = self._group_status(group) + status = css_class(self._group_status(group)) w(u'

%s

\n' % (make_togglable_link('fieldset_' + group, label, - self._cookie_name_from_group(group), status))) - statusclass = status and 'class="%s"' % status or '' - w(u'
' % (group, statusclass)) + self._cookie_name(group)))) + w(u'
' % (group, status)) for label, oid, form in sorted((self.req.__('%s_%s' % (group, o)), o, f) for o, f in objects.iteritems()): w(u'
')