backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Sat, 07 May 2011 10:51:47 +0200
changeset 7332 c3ae97c0066b
parent 7326 6c603d0fb2c7 (current diff)
parent 7331 7fcc4f22f3e4 (diff)
child 7336 0c8c386d653b
backport stable
devtools/testlib.py
web/data/cubicweb.ajax.js
--- a/devtools/testlib.py	Fri May 06 11:44:40 2011 +0200
+++ b/devtools/testlib.py	Sat May 07 10:51:47 2011 +0200
@@ -360,7 +360,7 @@
         """create and return a new user entity"""
         if isinstance(req, basestring):
             warn('[3.12] create_user arguments are now (req, login[, groups, password, commit, **kwargs])',
-                 DeprecationWarning, stacklevel=1)
+                 DeprecationWarning, stacklevel=2)
             if not isinstance(groups, (tuple, list)):
                 password = groups
                 groups = login
@@ -391,7 +391,7 @@
         """
         if not isinstance(session, Session):
             warn('[3.12] grant_permission arguments are now (session, entity, group, pname[, plabel])',
-                 DeprecationWarning, stacklevel=1)
+                 DeprecationWarning, stacklevel=2)
             plabel = pname
             pname = group
             group = entity
@@ -400,7 +400,7 @@
             session = self.session
         pname = unicode(pname)
         plabel = plabel and unicode(plabel) or unicode(group)
-        e = entity.eid
+        e = getattr(entity, 'eid', entity)
         with security_enabled(session, False, False):
             peid = session.execute(
             'INSERT CWPermission X: X name %(pname)s, X label %(plabel)s,'
--- a/server/session.py	Fri May 06 11:44:40 2011 +0200
+++ b/server/session.py	Sat May 07 10:51:47 2011 +0200
@@ -33,12 +33,14 @@
 from yams import BASE_TYPES
 
 from cubicweb import Binary, UnknownEid, QueryError, schema
+from cubicweb.selectors import objectify_selector
 from cubicweb.req import RequestSessionBase
 from cubicweb.dbapi import ConnectionProperties
 from cubicweb.utils import make_uid, RepeatList
 from cubicweb.rqlrewrite import RQLRewriter
 from cubicweb.server.edition import EditedEntity
 
+
 ETYPE_PYOBJ_MAP[Binary] = 'Bytes'
 
 NO_UNDO_TYPES = schema.SCHEMA_TYPES.copy()
@@ -58,6 +60,20 @@
         description.append(term.get_type(solution, args))
     return description
 
+@objectify_selector
+def is_user_session(cls, req, **kwargs):
+    """repository side only selector returning 1 if the session is a regular
+    user session and not an internal session
+    """
+    return not req.is_internal_session
+
+@objectify_selector
+def is_internal_session(cls, req, **kwargs):
+    """repository side only selector returning 1 if the session is not a regular
+    user session but an internal session
+    """
+    return req.is_internal_session
+
 
 class hooks_control(object):
     """context manager to control activated hooks categories.
--- a/web/data/cubicweb.ajax.js	Fri May 06 11:44:40 2011 +0200
+++ b/web/data/cubicweb.ajax.js	Sat May 07 10:51:47 2011 +0200
@@ -643,7 +643,7 @@
     var ajaxArgs = ['render', formparams, registry, compid];
     ajaxArgs = ajaxArgs.concat(cw.utils.sliceList(arguments, 4));
     var params = ajaxFuncArgs.apply(null, ajaxArgs);
-    $('#'+domid).loadxhtml('json', params, null, 'swap');
+    return $('#'+domid).loadxhtml('json', params, null, 'swap');
 }
 
 /* ajax tabs ******************************************************************/
--- a/web/views/cwuser.py	Fri May 06 11:44:40 2011 +0200
+++ b/web/views/cwuser.py	Sat May 07 10:51:47 2011 +0200
@@ -24,6 +24,7 @@
 
 from logilab.mtconverter import xml_escape
 
+from cubicweb import tags
 from cubicweb.schema import display_name
 from cubicweb.selectors import one_line_rset, is_instance, match_user_groups
 from cubicweb.view import EntityView, StartupView
@@ -202,7 +203,8 @@
                    display_name(self._cw, 'CWSource'))
         super(CWUserTable, self).call(
             paginate=True, displayfilter=True,
-            cellvids={4: 'cw.user-table.group-cell'},
+            cellvids={0: 'cw.user.login',
+                      4: 'cw.user-table.group-cell'},
             headers=headers, **kwargs)
 
 
@@ -213,3 +215,11 @@
     def cell_call(self, row, col, **kwargs):
         entity = self.cw_rset.get_entity(row, col)
         self.w(entity.view('reledit', rtype='in_group', role='subject'))
+
+class CWUserLoginCell(EntityView):
+    __regid__ = 'cw.user.login'
+    __select__ = is_instance('CWUser')
+
+    def cell_call(self, row, col, **kwargs):
+        entity = self.cw_rset.get_entity(row, col)
+        self.w(tags.a(entity.login, href=entity.absolute_url()))