backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 16 Sep 2011 17:30:26 +0200
changeset 7807 f2a5805615f8
parent 7803 02e141e41da2 (current diff)
parent 7806 aa30c665bd06 (diff)
child 7808 d90338624ea0
backport stable
web/views/actions.py
web/views/cwuser.py
--- a/web/action.py	Fri Sep 16 14:01:17 2011 +0200
+++ b/web/action.py	Fri Sep 16 17:30:26 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.
@@ -141,7 +141,7 @@
             ttype = self.target_etype
         entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
         linkto = '%s:%s:%s' % (self.rtype, entity.eid, target(self))
-        return self._cw.build_url('add/%s' % ttype, __linkto=linkto,
-                                  __redirectpath=entity.rest_path(),
+        return self._cw.vreg["etypes"].etype_class(ttype).cw_create_url(self._cw,
+                                  __redirectpath=entity.rest_path(), __linkto=linkto,
                                   __redirectvid=self._cw.form.get('__redirectvid', ''))
 
--- a/web/data/cubicweb.css	Fri Sep 16 14:01:17 2011 +0200
+++ b/web/data/cubicweb.css	Fri Sep 16 17:30:26 2011 +0200
@@ -20,38 +20,30 @@
 /* got rhythm ? beat of 12*1.25 = 15 px */
 .rhythm_bg { background: url("%(baseRhythmBg)s") repeat ! important; }
 
-/* scale 3:5 stranded */
-/* h1 { font-size:2em; } */
-/* h2 { font-size:1.61538em; } */
-/* h3 { font-size:1.23077em; } */
-
-/* scale le corbusier */
-/* h1 { font-size:2.11538em; } */
-/* h2 { font-size:1.61538em; } */
-/* h3 { font-size:1.30769em; } */
-
-/* scale traditional */
-h1,
-.vtitle { font-size: %(h1FontSize)s; }
-h2 { font-size: %(h2FontSize)s; }
-h3 { font-size: %(h3FontSize)s; }
-
-/* paddings */
 h1,
 .vtitle {
+  font-size: %(h1FontSize)s;
   border-bottom: %(h1BorderBottomStyle)s;
   padding: %(h1Padding)s;
   margin: %(h1Margin)s;
   color: %(h1Color)s;
 }
 
+h2 {
+  font-size: %(h2FontSize)s;
+  padding: %(h2Padding)s;
+}
+
+h3 {
+  font-size: %(h3FontSize)s;
+  padding: %(h3Padding)s;
+}
+
 div.tabbedprimary + h1,
 h1.plain {
  border-bottom: none;
 }
 
-h2 { padding: %(h2Padding)s; }
-h3 { padding: %(h3Padding)s; }
 
 html, body {
   background: %(pageBgColor)s;
--- a/web/data/cubicweb.old.css	Fri Sep 16 14:01:17 2011 +0200
+++ b/web/data/cubicweb.old.css	Fri Sep 16 17:30:26 2011 +0200
@@ -24,7 +24,7 @@
 
 h1,
 .vtitle {
-  font-size: 188%;
+  font-size: %(h1FontSize)s;
   margin: 0.2em 0px 0.3em;
   border-bottom: 1px solid #000;
 }
@@ -35,11 +35,11 @@
 }
 
 h2 {
-  font-size: 135%;
+  font-size: %(h2FontSize)s;
 }
 
 h3 {
-  font-size: 130%;
+  font-size: %(h3FontSize)s;
 }
 
 h4 {
--- a/web/data/uiprops.py	Fri Sep 16 14:01:17 2011 +0200
+++ b/web/data/uiprops.py	Fri Sep 16 17:30:26 2011 +0200
@@ -77,6 +77,17 @@
 headerBgColor = '#ff7700'
 headerBg = lazystr('%(headerBgColor)s url("banner.png") repeat-x top left')
 
+
+# scale 3:5 stranded
+# h1 { font-size:2em; }
+# h2 { font-size:1.61538em; }
+# h3 { font-size:1.23077em; }
+#
+# scale le corbusier */
+# h1 { font-size:2.11538em; }
+# h2 { font-size:1.61538em; }
+# h3 { font-size:1.30769em; }
+
 # h
 h1FontSize = '1.5em' # 18px
 h1Padding = '0 0 0.14em 0 '
--- a/web/views/__init__.py	Fri Sep 16 14:01:17 2011 +0200
+++ b/web/views/__init__.py	Fri Sep 16 17:30:26 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.
@@ -22,7 +22,9 @@
 import os
 import sys
 import tempfile
+
 from rql import nodes
+from logilab.mtconverter import xml_escape
 
 
 def need_table_view(rset, schema):
@@ -113,6 +115,16 @@
     return "javascript: selectForAssociation('%s', '%s');" % (triplets, eid)
 
 
+def add_etype_button(req, etype, csscls='addButton right', **urlkwargs):
+    vreg = req.vreg
+    eschema = vreg.schema.eschema(etype)
+    if eschema.has_perm(req, 'add'):
+        url = vreg['etypes'].etype_class(etype).cw_create_url(req, **urlkwargs)
+        return u'<a href="%s" class="%s">%s</a>' % (
+            xml_escape(url), csscls, req.__('New %s' % etype))
+    return u''
+
+
 class TmpFileViewMixin(object):
     binary = True
     content_type = 'application/octet-stream'
--- a/web/views/actions.py	Fri Sep 16 14:01:17 2011 +0200
+++ b/web/views/actions.py	Fri Sep 16 17:30:26 2011 +0200
@@ -239,7 +239,7 @@
         return self._cw.__('add a %s' % self.rsettype) # generated msgid
 
     def url(self):
-        return self._cw.build_url('add/%s' % self.rsettype)
+        return self._cw.vreg["etypes"].etype_class(self.rsettype).cw_create_url(self._cw)
 
 
 class AddRelatedActions(action.Action):
@@ -310,8 +310,9 @@
                         yield rschema, teschema, role
 
     def linkto_url(self, entity, rtype, etype, target, **kwargs):
-        return self._cw.build_url('add/%s' % etype,
-                                  __linkto='%s:%s:%s' % (rtype, entity.eid, target), **kwargs)
+        return self._cw.vreg["etypes"].etype_class(etype).cw_create_url(
+                self._cw, __linkto='%s:%s:%s' % (rtype, entity.eid, target),
+                **kwargs)
 
 
 class ViewSameCWEType(action.Action):
--- a/web/views/cwproperties.py	Fri Sep 16 14:01:17 2011 +0200
+++ b/web/views/cwproperties.py	Fri Sep 16 17:30:26 2011 +0200
@@ -248,7 +248,7 @@
         | (one_line_rset() & match_user_groups('managers') & is_instance('CWUser'))
         )
 
-    title = _('preferences')
+    title = _('user preferences')
 
     @property
     def user(self):
--- a/web/views/cwsources.py	Fri Sep 16 14:01:17 2011 +0200
+++ b/web/views/cwsources.py	Fri Sep 16 17:30:26 2011 +0200
@@ -28,7 +28,7 @@
 from cubicweb.view import EntityView, StartupView
 from cubicweb.schema import META_RTYPES, VIRTUAL_RTYPES, display_name
 from cubicweb.web import uicfg, formwidgets as wdgs
-from cubicweb.web.views import tabs, actions
+from cubicweb.web.views import tabs, actions, add_etype_button
 
 
 _abaa = uicfg.actionbox_appearsin_addmenu
@@ -69,12 +69,9 @@
     def entity_call(self, entity):
         _ = self._cw._
         self.w('<h3>%s</h3>' % _('Entity and relation supported by this source'))
-        eschema = self._cw.vreg.schema.eschema('CWSourceSchemaConfig')
-        if eschema.has_perm(self._cw, 'add'):
-            self.w(u'<a href="%s" class="addButton right">%s</a>' % (
-                self._cw.build_url('add/%s' % eschema),
-                self._cw._('add a CWSourceSchemaConfig')))
-            self.w(u'<div class="clear"></div>')
+        self.w(add_etype_button(self._cw, 'CWSourceSchemaConfig',
+                                __linkto='cw_for_source:%s:subject' % entity.eid))
+        self.w(u'<div class="clear"></div>')
         rset = self._cw.execute(
             'Any X, SCH, XO ORDERBY ET WHERE X options XO, X cw_for_source S, S eid %(s)s, '
             'X cw_schema SCH, SCH is ET', {'s': entity.eid})
@@ -96,11 +93,11 @@
         checker = MAPPING_CHECKERS.get(entity.type, MappingChecker)(entity)
         checker.check()
         if (checker.errors or checker.warnings or checker.infos):
-                self.w('<h2>%s</h2>' % _('Detected problems'))
-                errors = zip(repeat(_('error')), checker.errors)
-                warnings = zip(repeat(_('warning')), checker.warnings)
-                infos = zip(repeat(_('warning')), checker.infos)
-                self.wview('pyvaltable', pyvalue=chain(errors, warnings, infos))
+            self.w('<h2>%s</h2>' % _('Detected problems'))
+            errors = zip(repeat(_('error')), checker.errors)
+            warnings = zip(repeat(_('warning')), checker.warnings)
+            infos = zip(repeat(_('warning')), checker.infos)
+            self.wview('pyvaltable', pyvalue=chain(errors, warnings, infos))
 
 
 class MappingChecker(object):
--- a/web/views/cwuser.py	Fri Sep 16 14:01:17 2011 +0200
+++ b/web/views/cwuser.py	Fri Sep 16 17:30:26 2011 +0200
@@ -29,7 +29,7 @@
 from cubicweb.selectors import one_line_rset, is_instance, match_user_groups
 from cubicweb.view import EntityView, StartupView
 from cubicweb.web import action, uicfg, formwidgets
-from cubicweb.web.views import tabs, tableview, actions
+from cubicweb.web.views import tabs, tableview, actions, add_etype_button
 
 _pvs = uicfg.primaryview_section
 _pvs.tag_attribute(('CWUser', 'login'), 'hidden')
@@ -194,7 +194,7 @@
            'U cw_source UDS, US name UDSN')
 
     def call(self, **kwargs):
-        add_button(self, 'CWUser')
+        self.w(add_etype_button(self._cw, 'CWGroup'))
         self.w(u'<div class="clear"></div>')
         self.wview('cw.users-table', self._cw.execute(self.rql))
 
@@ -209,20 +209,13 @@
     cellvids = {}
 
     def call(self, **kwargs):
-        add_button(self, 'CWGroup')
+        self.w('<h1>%s</h1>' % self._cw._(self.title))
+        self.w(add_etype_button(self._cw, 'CWUser'))
         self.w(u'<div class="clear"></div>')
         self.wview('editable-table', self._cw.execute(self.rql),
                    headers=self.headers, cellvids=self.cellvids)
 
 
-def add_button(self, etype):
-    eschema = self._cw.vreg.schema.eschema(etype)
-    if eschema.has_perm(self._cw, 'add'):
-        self.w(u'<a href="%s" class="addButton right">%s</a>' % (
-                self._cw.build_url('add/%s' % eschema),
-                self._cw.__('New %s' % etype).capitalize()))
-
-
 class CWUsersTable(tableview.EditableTableView):
     __regid__ = 'cw.users-table'
     __select__ = is_instance('CWUser')