23 _ = unicode |
23 _ = unicode |
24 |
24 |
25 from itertools import repeat, chain |
25 from itertools import repeat, chain |
26 |
26 |
27 from cubicweb.selectors import is_instance, score_entity, match_user_groups |
27 from cubicweb.selectors import is_instance, score_entity, match_user_groups |
28 from cubicweb.view import EntityView |
28 from cubicweb.view import EntityView, StartupView |
29 from cubicweb.schema import META_RTYPES, VIRTUAL_RTYPES, display_name |
29 from cubicweb.schema import META_RTYPES, VIRTUAL_RTYPES, display_name |
30 from cubicweb.web import uicfg |
30 from cubicweb.web import uicfg |
31 from cubicweb.web.views import tabs |
31 from cubicweb.web.views import tabs, actions |
|
32 |
|
33 # source primary views ######################################################### |
32 |
34 |
33 _pvs = uicfg.primaryview_section |
35 _pvs = uicfg.primaryview_section |
34 _pvs.tag_object_of(('*', 'cw_for_source', 'CWSource'), 'hidden') |
36 _pvs.tag_object_of(('*', 'cw_for_source', 'CWSource'), 'hidden') |
35 |
37 |
36 |
38 |
54 & score_entity(lambda x:x.type in MAPPED_SOURCE_TYPES)) |
56 & score_entity(lambda x:x.type in MAPPED_SOURCE_TYPES)) |
55 |
57 |
56 def entity_call(self, entity): |
58 def entity_call(self, entity): |
57 _ = self._cw._ |
59 _ = self._cw._ |
58 self.w('<h3>%s</h3>' % _('Entity and relation supported by this source')) |
60 self.w('<h3>%s</h3>' % _('Entity and relation supported by this source')) |
|
61 eschema = self._cw.vreg.schema.eschema('CWSourceSchemaConfig') |
|
62 if eschema.has_perm(self._cw, 'add'): |
|
63 self.w(u'<a href="%s" class="addButton right">%s</a>' % ( |
|
64 self._cw.build_url('add/%s' % eschema), |
|
65 self._cw._('add a CWSourceSchemaConfig'))) |
|
66 self.w(u'<div class="clear"></div>') |
59 rset = self._cw.execute( |
67 rset = self._cw.execute( |
60 'Any X, SCH, XO ORDERBY ET WHERE X options XO, X cw_for_source S, S eid %(s)s, ' |
68 'Any X, SCH, XO ORDERBY ET WHERE X options XO, X cw_for_source S, S eid %(s)s, ' |
61 'X cw_schema SCH, SCH is ET', {'s': entity.eid}) |
69 'X cw_schema SCH, SCH is ET', {'s': entity.eid}) |
62 self.wview('table', rset, 'noresult') |
70 self.wview('table', rset, 'noresult') |
63 # self.w('<h3>%s</h3>' % _('Relations that should not be crossed')) |
71 # self.w('<h3>%s</h3>' % _('Relations that should not be crossed')) |
195 'supported and may be crossed ') % rschema) |
203 'supported and may be crossed ') % rschema) |
196 |
204 |
197 MAPPING_CHECKERS = { |
205 MAPPING_CHECKERS = { |
198 'pyrorql': PyroRQLMappingChecker, |
206 'pyrorql': PyroRQLMappingChecker, |
199 } |
207 } |
|
208 |
|
209 # sources management view ###################################################### |
|
210 |
|
211 class ManageSourcesAction(actions.ManagersAction): |
|
212 __regid__ = 'cwsource' |
|
213 title = _('data sources') |
|
214 category = 'manage' |
|
215 |
|
216 class CWSourceManagementView(StartupView): |
|
217 __regid__ = 'cw.source-management' |
|
218 rql = ('Any S, ST, SN ORDERBY SN WHERE S is CWSource, S name SN, S type ST') |
|
219 title = _('data sources management') |
|
220 |
|
221 def call(self, **kwargs): |
|
222 self.w('<h1>%s</h1>' % self._cw._(self.title)) |
|
223 eschema = self._cw.vreg.schema.eschema('CWSource') |
|
224 if eschema.has_perm(self._cw, 'add'): |
|
225 self.w(u'<a href="%s" class="addButton right">%s</a>' % ( |
|
226 self._cw.build_url('add/%s' % eschema), |
|
227 self._cw._('add a CWSource'))) |
|
228 self.w(u'<div class="clear"></div>') |
|
229 self.wview('table', self._cw.execute(self.rql), displaycols=range(2)) |