[saem-devel] [PATCH 9 of 9] [org] Use RTypeListView instead of RelatedEntitiesListView for ou's authority record tab

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Jan 27 16:02:57 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1485331822 -3600
#      Wed Jan 25 09:10:22 2017 +0100
# Node ID c44d0949648df2590c200793a99b87fdfef4921a
# Parent  364e8f577d67fa06a1ba00b0ca00ccd4cba1a8b0
[org] Use RTypeListView instead of RelatedEntitiesListView for ou's authority record tab

we want to handle the relation, not underlying entities.

Closes #12572793

diff --git a/cubicweb_saem_ref/views/org.py b/cubicweb_saem_ref/views/org.py
--- a/cubicweb_saem_ref/views/org.py
+++ b/cubicweb_saem_ref/views/org.py
@@ -195,34 +195,34 @@ class RTypeListView(RelatedEntitiesListV
 
     * only include button delete the relation (not the entity),
     * give extra arguments so the permission to delete the relation is checked.
     """
     __abstract__ = True
+    tabid = None
 
     @property
     def subvid_kwargs(self):
         entity = self.cw_rset.one()
         return {'unit': entity, '__redirectpath': entity.rest_path(),
-                'rtype': self.rtype, 'role': self.role}
+                'rtype': self.rtype, 'role': self.role, 'tabid': self.tabid}
 
 
 class OrganizationUnitUsingListItemView(EntityView):
     """Extended 'oneline' view for entities related to an organization unit, including link to
     remove the relation.
     """
     __regid__ = 'saem.listitem'
-    __select__ = EntityView.__select__ & match_kwargs('unit', 'rtype', 'role')
+    __select__ = EntityView.__select__ & match_kwargs('unit', 'rtype', 'role', 'tabid')
 
     # XXX usually expect role to be the role of the entity, here it's the role of the organization
     # unit
-    def entity_call(self, entity, unit, rtype, role, **editurlparams):
+    def entity_call(self, entity, unit, rtype, role, tabid, **editurlparams):
         entity.view('outofcontext', w=self.w)
         if has_rel_perm('delete', unit, rtype, role, target_entity=entity):
             self._cw.add_js(('cubicweb.ajax.js', 'cubes.saem_ref.js'))
             self.w(u'<div class="pull-right">')
-            jscall = js.saem.ajaxRemoveRelation(unit.eid, entity.eid, rtype, role,
-                                                'saem_ou_concepts_profiles_tab')
+            jscall = js.saem.ajaxRemoveRelation(unit.eid, entity.eid, rtype, role, tabid)
             self.w(tags.a(title=self._cw._('delete'), klass='icon-trash',
                           href='javascript: %s' % jscall))
             self.w(u'</div>')
 
 
@@ -301,17 +301,19 @@ class DepositOrganizationUnitConceptsPro
 class OrganizationUnitUsingConceptSchemeListView(RTypeListView):
     """View for ConceptScheme, to be displayed in the context of an organization unit."""
     __regid__ = 'saem.ou.schemes'
     rtype = 'related_concept_scheme'
     role = 'subject'
+    tabid = 'saem_ou_concepts_profiles_tab'
 
 
 class RelatedSEDAArchiveTransferListView(RTypeListView):
     """View for SEDAArchiveTransfer, to be displayed in the context of an organization unit."""
     __regid__ = 'saem.ou.profiles'
     rtype = 'use_profile'
     role = 'subject'
+    tabid = 'saem_ou_concepts_profiles_tab'
 
 
 class OrganizationUnitAuthorityRecordsTab(LinkedObjectsTab):
     """Authority records used by this organization unit."""
     __regid__ = 'saem_ou_authorityrecords_tab'
@@ -323,16 +325,17 @@ class OrganizationUnitAuthorityRecordsTa
     subvids = (
         'saem.ou.authorityrecords',
     )
 
 
-class OrganizationUnitAuthorityRecordsView(RelatedEntitiesListView):
+class OrganizationUnitAuthorityRecordsView(RTypeListView):
     __regid__ = 'saem.ou.authorityrecords'
     rtype = 'use_authorityrecord'
     role = 'subject'
     target_etype = 'AuthorityRecord'
     title = None
+    tabid = 'saem_ou_authorityrecords_tab'
 
 
 # Agent
 pvs.tag_subject_of(('Agent', 'phone_number', '*'), 'attributes')
 afs.tag_subject_of(('Agent', 'phone_number', '*'), 'main', 'inlined')


More information about the saem-devel mailing list