web/views/cwproperties.py
changeset 2476 1294a6bdf3bf
parent 2458 4d114865098f
child 2583 b8d39602a640
equal deleted inserted replaced
2475:b6753521129d 2476:1294a6bdf3bf
    62     __select__ = implements('CWProperty')
    62     __select__ = implements('CWProperty')
    63     skip_none = False
    63     skip_none = False
    64 
    64 
    65 
    65 
    66 class SystemCWPropertiesForm(FormViewMixIn, StartupView):
    66 class SystemCWPropertiesForm(FormViewMixIn, StartupView):
       
    67     """site-wide properties edition form"""
    67     id = 'systempropertiesform'
    68     id = 'systempropertiesform'
    68     __select__ = none_rset() & match_user_groups('managers')
    69     __select__ = none_rset() & match_user_groups('managers')
    69 
    70 
    70     title = _('site configuration')
    71     title = _('site configuration')
    71     category = 'startupview'
    72     category = 'startupview'
    92         else:
    93         else:
    93             status = cookie.value
    94             status = cookie.value
    94         return status
    95         return status
    95 
    96 
    96     def call(self, **kwargs):
    97     def call(self, **kwargs):
    97         """The default view representing the application's index"""
       
    98         self.req.add_js(('cubicweb.edition.js', 'cubicweb.preferences.js', 'cubicweb.ajax.js'))
    98         self.req.add_js(('cubicweb.edition.js', 'cubicweb.preferences.js', 'cubicweb.ajax.js'))
    99         self.req.add_css('cubicweb.preferences.css')
    99         self.req.add_css('cubicweb.preferences.css')
   100         vreg = self.vreg
   100         vreg = self.vreg
   101         values = self.defined_keys
   101         values = self.defined_keys
   102         groupedopts = {}
   102         groupedopts = {}
   224 def is_user_prefs(cls, req, rset=None, row=None, col=0, **kwargs):
   224 def is_user_prefs(cls, req, rset=None, row=None, col=0, **kwargs):
   225     return req.user.eid == rset[row or 0][col]
   225     return req.user.eid == rset[row or 0][col]
   226 
   226 
   227 
   227 
   228 class CWPropertiesForm(SystemCWPropertiesForm):
   228 class CWPropertiesForm(SystemCWPropertiesForm):
       
   229     """user's preferences properties edition form"""
   229     id = 'propertiesform'
   230     id = 'propertiesform'
   230     __select__ = (
   231     __select__ = (
   231         (none_rset() & match_user_groups('users','managers'))
   232         (none_rset() & match_user_groups('users','managers'))
   232         | (one_line_rset() & match_user_groups('users') & is_user_prefs())
   233         | (one_line_rset() & match_user_groups('users') & is_user_prefs())
   233         | (one_line_rset() & match_user_groups('managers') & implements('CWUser'))
   234         | (one_line_rset() & match_user_groups('managers') & implements('CWUser'))