# HG changeset patch # User Sylvain Thénault # Date 1297271187 -3600 # Node ID 220e32f058bedb7f814c10b1b50d945261b00dfa # Parent 686c59dfc4019315a0fe679553d59d0a07fff888 [management ui] add views to manage sources similarly to users diff -r 686c59dfc401 -r 220e32f058be web/views/cwsources.py --- a/web/views/cwsources.py Wed Feb 09 18:06:25 2011 +0100 +++ b/web/views/cwsources.py Wed Feb 09 18:06:27 2011 +0100 @@ -25,10 +25,12 @@ from itertools import repeat, chain from cubicweb.selectors import is_instance, score_entity, match_user_groups -from cubicweb.view import EntityView +from cubicweb.view import EntityView, StartupView from cubicweb.schema import META_RTYPES, VIRTUAL_RTYPES, display_name from cubicweb.web import uicfg -from cubicweb.web.views import tabs +from cubicweb.web.views import tabs, actions + +# source primary views ######################################################### _pvs = uicfg.primaryview_section _pvs.tag_object_of(('*', 'cw_for_source', 'CWSource'), 'hidden') @@ -56,6 +58,12 @@ def entity_call(self, entity): _ = self._cw._ self.w('

%s

' % _('Entity and relation supported by this source')) + eschema = self._cw.vreg.schema.eschema('CWSourceSchemaConfig') + if eschema.has_perm(self._cw, 'add'): + self.w(u'%s' % ( + self._cw.build_url('add/%s' % eschema), + self._cw._('add a CWSourceSchemaConfig'))) + self.w(u'
') 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}) @@ -197,3 +205,25 @@ MAPPING_CHECKERS = { 'pyrorql': PyroRQLMappingChecker, } + +# sources management view ###################################################### + +class ManageSourcesAction(actions.ManagersAction): + __regid__ = 'cwsource' + title = _('data sources') + category = 'manage' + +class CWSourceManagementView(StartupView): + __regid__ = 'cw.source-management' + rql = ('Any S, ST, SN ORDERBY SN WHERE S is CWSource, S name SN, S type ST') + title = _('data sources management') + + def call(self, **kwargs): + self.w('

%s

' % self._cw._(self.title)) + eschema = self._cw.vreg.schema.eschema('CWSource') + if eschema.has_perm(self._cw, 'add'): + self.w(u'%s' % ( + self._cw.build_url('add/%s' % eschema), + self._cw._('add a CWSource'))) + self.w(u'
') + self.wview('table', self._cw.execute(self.rql), displaycols=range(2)) diff -r 686c59dfc401 -r 220e32f058be web/views/startup.py --- a/web/views/startup.py Wed Feb 09 18:06:25 2011 +0100 +++ b/web/views/startup.py Wed Feb 09 18:06:27 2011 +0100 @@ -38,7 +38,7 @@ add_etype_links = () skip_startup_views = set( ('index', 'manage', 'schema', 'owl', 'changelog', 'systempropertiesform', 'propertiesform', - 'cw.user-management', + 'cw.user-management', 'cw.source-management', 'siteinfo', 'info', 'registry', 'gc', 'tree') ) diff -r 686c59dfc401 -r 220e32f058be web/views/urlrewrite.py --- a/web/views/urlrewrite.py Wed Feb 09 18:06:25 2011 +0100 +++ b/web/views/urlrewrite.py Wed Feb 09 18:06:27 2011 +0100 @@ -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. @@ -97,6 +97,7 @@ ('/sparql', dict(vid='sparql')), ('/processinfo', dict(vid='processinfo')), (rgx('/cwuser', re.I), dict(vid='cw.user-management')), + (rgx('/cwsource', re.I), dict(vid='cw.source-management')), # XXX should be case insensitive as 'create', but I would like to find another way than # relying on the etype_selector (rgx('/schema/([^/]+?)/?'), dict(vid='primary', rql=r'Any X WHERE X is CWEType, X name "\1"')),