diff -r 749e1a67987f -r 58f696c0f5b3 web/views/cwproperties.py
--- a/web/views/cwproperties.py Thu Sep 22 16:12:28 2011 +0200
+++ b/web/views/cwproperties.py Thu Sep 22 16:12:33 2011 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -113,72 +113,18 @@
self._cw.add_js(('cubicweb.preferences.js',
'cubicweb.edition.js', 'cubicweb.ajax.js'))
self._cw.add_css('cubicweb.preferences.css')
- vreg = self._cw.vreg
values = self.defined_keys
- groupedopts = {}
- mainopts = {}
- # "self.id=='systempropertiesform'" to skip site wide properties on
- # user's preference but not site's configuration
- for key in vreg.user_property_keys(self.__regid__=='systempropertiesform'):
- parts = key.split('.')
- if parts[0] in vreg and len(parts) >= 3:
- # appobject configuration
- reg = parts[0]
- propid = parts[-1]
- oid = '.'.join(parts[1:-1])
- groupedopts.setdefault(reg, {}).setdefault(oid, []).append(key)
- else:
- mainopts.setdefault(parts[0], []).append(key)
- # precompute form to consume error message
- for group, keys in mainopts.items():
- mainopts[group] = self.form(group, keys, False)
-
- for group, objects in groupedopts.items():
- for oid, keys in objects.items():
- groupedopts[group][oid] = self.form(group + '_' + oid, keys, True)
-
- w = self.w
- req = self._cw
- _ = req._
- w(u'
%s
\n' % _(self.title))
+ mainopts, groupedopts = self.group_properties()
+ # precompute all forms first to consume error message
+ mainforms, groupedforms = self.build_forms(mainopts, groupedopts)
+ _ = self._cw._
+ self.w(u'
%s
\n' % _(self.title))
for label, group, form in sorted((_(g), g, f)
- for g, f in mainopts.iteritems()):
- status = css_class(self._group_status(group))
- w(u'
')
-
+ for g, f in mainforms.iteritems()):
+ self.wrap_main_form(group, label, form)
for label, group, objects in sorted((_(g), g, o)
- for g, o in groupedopts.iteritems()):
- status = css_class(self._group_status(group))
- w(u'
' % (group, status))
- # create selection
- sorted_objects = sorted((self._cw.__('%s_%s' % (group, o)), o, f)
- for o, f in objects.iteritems())
- for label, oid, form in sorted_objects:
- w(u'
' % (group, status))
+ sorted_objects = sorted((self._cw.__('%s_%s' % (group, o)), o, f)
+ for o, f in objects.iteritems())
+ for label, oid, form in sorted_objects:
+ self.wrap_object_form(group, oid, label, form)
+ self.w(u'
')
+ w(u'')
+
class CWPropertiesForm(SystemCWPropertiesForm):
"""user's preferences properties edition form"""
@@ -268,7 +280,7 @@
# we have to set for_user explicitly
if not subform.edited_entity.has_eid() and self.user.matching_groups('managers'):
subform.add_hidden('for_user', self.user.eid, eidparam=True, role='subject')
-
+ return subform
# cwproperty form objects ######################################################