[PATCH 3 of 4 saem_ref V2] Follow changes in the seda cube

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Feb 24 16:27:56 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1487948183 -3600
#      Fri Feb 24 15:56:23 2017 +0100
# Node ID 3432a5b5af90222d5a25bcc1a000a4c788a1ae98
# Parent  e62af2d03c9dda1d131264dd8a963ea44d590da6
Follow changes in the seda cube

Breadcrumbs and navigation components handling /sedalib route moved there.

diff --git a/cubicweb_saem_ref/views/seda.py b/cubicweb_saem_ref/views/seda.py
--- a/cubicweb_saem_ref/views/seda.py
+++ b/cubicweb_saem_ref/views/seda.py
@@ -13,13 +13,11 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 """cubicweb-saem-ref views related to SEDA"""
 
-from cubicweb.predicates import (is_instance, multi_lines_rset,
-                                 has_related_entities, relation_possible)
-from cubicweb.web.views import basecomponents, baseviews, ibreadcrumbs, uicfg
+from cubicweb.web.views import uicfg
 
 from cubicweb_seda.views.simplified import simplified_afs, simplified_pvs
 
 
 # primary view configuration #######################################################################
@@ -46,41 +44,5 @@ simplified_pvs.tag_object_of(('*', 'use_
 simplified_afs.tag_object_of(('*', 'use_profile', '*'), 'main', 'hidden')
 
 simplified_pvs.tag_attribute(('SEDABinaryDataObject', 'filename'), 'hidden')
 simplified_afs.tag_attribute(('SEDABinaryDataObject', 'filename'), 'main', 'hidden')
 afs.tag_attribute(('SEDABinaryDataObject', 'filename'), 'main', 'hidden')
-
-
-# navigation #######################################################################################
-
-class SEDAComponentsBreadcrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter):
-    """Breadcrumbs adapter pointing to /sedalib route when entity has no
-    parent.
-    """
-    __select__ = (ibreadcrumbs.IBreadCrumbsAdapter.__select__
-                  & relation_possible('seda_archive_unit', role='subject')
-                  & ~has_related_entities('seda_archive_unit', role='subject'))
-
-    def breadcrumbs(self, *args, **kwargs):
-        return [(self._cw.build_url('sedalib'), self._cw._('SEDA components')),
-                self.entity]
-
-
-class SEDAComponentsBreadCrumbETypeVComponent(ibreadcrumbs.BreadCrumbEntityVComponent):
-    """For proper display of the breadcrumb in the SEDA components list"""
-    __select__ = (basecomponents.HeaderComponent.__select__
-                  & multi_lines_rset() & is_instance('SEDAArchiveUnit'))
-
-    def render_breadcrumbs(self, w, contextentity, path):
-        w(u'<a href="%s">%s</a>' % (self._cw.build_url('sedalib'),
-                                    self._cw._('SEDA components')))
-
-# SEDA lib components ##############################################################################
-
-
-class SEDALibView(baseviews.SameETypeListView):
-    __regid__ = 'saem_ref.sedalib'
-    __select__ = is_instance('SEDAArchiveUnit')
-
-    @property
-    def title(self):
-        return self._cw._('SEDA components')
diff --git a/test/test_views.py b/test/test_views.py
--- a/test/test_views.py
+++ b/test/test_views.py
@@ -232,34 +232,10 @@ class FuncViewsTC(CubicWebTC):
                              {'divid': expected_divid,
                               'vid': vid,
                               'rql': u'Any X WHERE X eid {}'.format(ou.eid)})
 
 
-class SEDANavigationTC(CubicWebTC):
-
-    def test_breadcrumbs(self):
-        with self.admin_access.cnx() as cnx:
-            transfer = testutils.setup_profile(cnx)
-            unit1 = testutils.create_archive_unit(transfer)[0]
-            unit2 = testutils.create_archive_unit(None, cnx=cnx)[0]
-            cnx.commit()
-        with self.admin_access.web_request() as req:
-            unit1 = req.entity_from_eid(unit1.eid)
-            unit2 = req.entity_from_eid(unit2.eid)
-            # unit1 is related to a transfer
-            breadcrumbs = unit1.cw_adapt_to('IBreadCrumbs').breadcrumbs()
-            expected_breadcrumbs = [transfer, unit1]
-            self.assertEqual(breadcrumbs, expected_breadcrumbs)
-            # unit2 is not related to a transfer, breadcrumbs leads to /sedalib.
-            breadcrumbs = unit2.cw_adapt_to('IBreadCrumbs').breadcrumbs()
-            expected_breadcrumbs = [
-                (u'http://testing.fr/cubicweb/sedalib', u'SEDA components'),
-                unit2,
-            ]
-            self.assertEqual(breadcrumbs, expected_breadcrumbs)
-
-
 class SEDAViewsTC(CubicWebTC):
 
     def test_seda_get_related_version(self):
         """Check that we get correct results when asking for `draft`, `published`, `replaced`
         version of a profile."""


More information about the saem-devel mailing list