[saem-devel] [PATCH 4 of 9] [org] Allow edition of use_authorityrecord from organization units

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


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1485328104 -3600
#      Wed Jan 25 08:08:24 2017 +0100
# Node ID 9ce9c54497960a49e7650cabec1d32cc63dec31d
# Parent  91037154d43a1091907a63d02722c19380be952a
[org] Allow edition of use_authorityrecord from organization units

using the relation widget.


Closes extranet #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
@@ -235,11 +235,12 @@ class DepositOrganizationUnitConceptsPro
 
 
 class OrganizationUnitSearchForRelatedEntitiesView(rwdg.SearchForRelatedEntitiesView):
     __select__ = (rwdg.SearchForRelatedEntitiesView.__select__
                   & (rwdg.edited_relation('use_profile')
-                     | rwdg.edited_relation('related_concept_scheme')))
+                     | rwdg.edited_relation('related_concept_scheme')
+                     | rwdg.edited_relation('use_authorityrecord')))
     has_creation_form = False
 
     def linkable_rset(self):
         """Return rset of entities to be displayed as possible values for the edited relation. You
         may want to override this.
@@ -310,14 +311,18 @@ class OrganizationUnitUsingListItemView(
             self.w(tags.a(title=self._cw._('delete'), klass='icon-trash',
                           href='javascript: %s' % jscall))
             self.w(u'</div>')
 
 
-class OrganizationUnitAuthorityRecordsTab(SubviewsTabView):
-    """Authority records used by this OrganizationUnit."""
+class OrganizationUnitAuthorityRecordsTab(LinkedObjectsTab):
+    """Authority records used by this organization unit."""
     __regid__ = 'saem_ref_ou_authorityrecords'
     __select__ = EntityView.__select__ & relation_possible('use_authorityrecord')
+    required_role = 'archival'
+    not_possible_msg = ("You can't add authority record to organization unit "
+                        "without the 'archvial' role.")
+    link_targets = [('AuthorityRecord', 'use_authorityrecord', 'subject')]
     subvids = (
         'saem.ou.authorityrecords',
     )
 
 


More information about the saem-devel mailing list