web/views/cwproperties.py
changeset 6545 5cea387a5667
parent 6543 66145280a7e6
child 7805 7111bb64b58f
equal deleted inserted replaced
6544:e0d20fb46389 6545:5cea387a5667
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    14 # details.
    14 # details.
    15 #
    15 #
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 """Specific views for CWProperty
    18 """Specific views for CWProperty (eg site/user preferences"""
    19 
    19 
    20 """
       
    21 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    22 _ = unicode
    21 _ = unicode
    23 
    22 
    24 from logilab.mtconverter import xml_escape
    23 from logilab.mtconverter import xml_escape
    25 
    24 
    64 _('category')
    63 _('category')
    65 
    64 
    66 
    65 
    67 def make_togglable_link(nodeid, label):
    66 def make_togglable_link(nodeid, label):
    68     """builds a HTML link that switches the visibility & remembers it"""
    67     """builds a HTML link that switches the visibility & remembers it"""
    69     action = u"javascript: togglePrefVisibility('%s')" % nodeid
    68     return u'<a href="javascript: togglePrefVisibility(\'%s\')">%s</a>' % (
    70     return u'<a href="%s">%s</a>' % (action, label)
    69         nodeid, label)
    71 
    70 
    72 def css_class(someclass):
    71 def css_class(someclass):
    73     return someclass and 'class="%s"' % someclass or ''
    72     return someclass and 'class="%s"' % someclass or ''
    74 
    73 
    75 
    74 
   109         else:
   108         else:
   110             status = cookie.value
   109             status = cookie.value
   111         return status
   110         return status
   112 
   111 
   113     def call(self, **kwargs):
   112     def call(self, **kwargs):
   114         self._cw.add_js(('cubicweb.edition.js', 'cubicweb.preferences.js', 'cubicweb.ajax.js'))
   113         self._cw.add_js(('cubicweb.preferences.js',
       
   114                          'cubicweb.edition.js', 'cubicweb.ajax.js'))
   115         self._cw.add_css('cubicweb.preferences.css')
   115         self._cw.add_css('cubicweb.preferences.css')
   116         vreg = self._cw.vreg
   116         vreg = self._cw.vreg
   117         values = self.defined_keys
   117         values = self.defined_keys
   118         groupedopts = {}
   118         groupedopts = {}
   119         mainopts = {}
   119         mainopts = {}
   133         for group, keys in mainopts.items():
   133         for group, keys in mainopts.items():
   134             mainopts[group] = self.form(group, keys, False)
   134             mainopts[group] = self.form(group, keys, False)
   135 
   135 
   136         for group, objects in groupedopts.items():
   136         for group, objects in groupedopts.items():
   137             for oid, keys in objects.items():
   137             for oid, keys in objects.items():
   138                 groupedopts[group][oid] = self.form(group + '-' + oid, keys, True)
   138                 groupedopts[group][oid] = self.form(group + '_' + oid, keys, True)
   139 
   139 
   140         w = self.w
   140         w = self.w
   141         req = self._cw
   141         req = self._cw
   142         _ = req._
   142         _ = req._
   143         w(u'<h1>%s</h1>\n' % _(self.title))
   143         w(u'<h1>%s</h1>\n' % _(self.title))