--- a/web/views/cwsources.py Thu Sep 22 16:53:46 2011 +0200
+++ b/web/views/cwsources.py Thu Sep 22 17:20:38 2011 +0200
@@ -24,27 +24,41 @@
from itertools import repeat, chain
+from cubicweb import Unauthorized
from cubicweb.selectors import is_instance, score_entity, match_user_groups
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, add_etype_button
+from cubicweb.web.views import tabs, actions, ibreadcrumbs, add_etype_button
_abaa = uicfg.actionbox_appearsin_addmenu
+# there are explicit 'add' buttons for those
_abaa.tag_object_of(('CWSourceSchemaConfig', 'cw_schema', '*'), False)
_abaa.tag_object_of(('CWSourceSchemaConfig', 'cw_for_source', '*'), False)
+_abaa.tag_object_of(('CWSourceSchemaConfig', 'cw_host_config_of', '*'), False)
_afs = uicfg.autoform_section
_afs.tag_attribute(('CWSource', 'synchronizing'), 'main', 'hidden')
_afs.tag_object_of(('*', 'cw_for_source', 'CWSource'), 'main', 'hidden')
+
_affk = uicfg.autoform_field_kwargs
_affk.tag_attribute(('CWSource', 'parser'), {'widget': wdgs.TextInput})
# source primary views #########################################################
_pvs = uicfg.primaryview_section
+_pvs.tag_attribute(('CWSource', 'name'), 'hidden')
_pvs.tag_object_of(('*', 'cw_for_source', 'CWSource'), 'hidden')
+_pvs.tag_object_of(('*', 'cw_host_config_of', 'CWSource'), 'hidden')
+
+_pvdc = uicfg.primaryview_display_ctrl
+_pvdc.tag_attribute(('CWSource', 'type'), {'vid': 'attribute'})# disable reledit
+
+_rc = uicfg.reledit_ctrl
+_rc.tag_attribute(('CWSource', 'config'), {'rvid': 'verbatim'})
+_rc.tag_attribute(('CWSourceHostConfig', 'config'), {'rvid': 'verbatim'})
+_rc.tag_attribute(('CWSourceSchemaConfig', 'options'), {'rvid': 'verbatim'})
class CWSourcePrimaryView(tabs.TabbedPrimaryView):
@@ -57,6 +71,23 @@
__regid__ = 'cwsource-main'
__select__ = tabs.PrimaryTab.__select__ & is_instance('CWSource')
+ def render_entity_attributes(self, entity):
+ super(CWSourceMainTab, self).render_entity_attributes(entity)
+ self.w(add_etype_button(self._cw, 'CWSourceHostConfig',
+ __linkto='cw_host_config_of:%s:subject' % entity.eid,
+ __redirectpath=entity.rest_path()))
+ try:
+ hostconfig = self._cw.execute(
+ 'Any X, XC, XH WHERE X cw_host_config_of S, S eid %(s)s, '
+ 'X config XC, X match_host XH', {'s': entity.eid})
+ except Unauthorized:
+ pass
+ else:
+ if hostconfig:
+ self.w(u'<h3>%s</h3>' % self._cw._('CWSourceHostConfig_plural'))
+ self._cw.view('editable-table', hostconfig,
+ displaycols=range(2), w=self.w)
+
MAPPED_SOURCE_TYPES = set( ('pyrorql', 'datafeed') )
@@ -239,3 +270,11 @@
self._cw._('add a CWSource')))
self.w(u'<div class="clear"></div>')
self.wview('table', self._cw.execute(self.rql), displaycols=range(4))
+
+
+# breadcrumbs configuration ####################################################
+
+class CWsourceConfigIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter):
+ __select__ = is_instance('CWSourceHostConfig', 'CWSourceSchemaConfig')
+ def parent_entity(self):
+ return self.entity.cwsource