[PATCH saem_ref] [seda] Restrict targets of "originating agency" relation to published AutorityRecord

Denis Laxalde denis.laxalde at logilab.fr
Tue Jun 26 10:04:20 CEST 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1529999035 -7200
#      Tue Jun 26 09:43:55 2018 +0200
# Node ID 40d9f2773a9ef27133a6a150dabca2f18d0ef5a7
# Parent  c468d1571ad4ad6df0988f97292c31592be86f46
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r 40d9f2773a9e
# EXP-Topic CONSEJIRA-507
[seda] Restrict targets of "originating agency" relation to published AutorityRecord

We add an RQL constraint on "seda_originating_agency_to" (class name
originating_agency_originating_agency_to in cubicweb-seda) to restrict
possible target AutorityRecord entities with a workflow state
"published". We need to do this with a full RQL constraint (although a
vocabulary constraint might be appropriate from a business point of
view) because the relation widget is used in archive unit form to render
this relation and the latter does not support vocabulary constraints.

CONSEJIRA-507.

diff --git a/cubicweb_saem_ref/migration/0.20.5_Any.py b/cubicweb_saem_ref/migration/0.20.5_Any.py
new file mode 100644
--- /dev/null
+++ b/cubicweb_saem_ref/migration/0.20.5_Any.py
@@ -0,0 +1,1 @@
+sync_schema_props_perms('seda_originating_agency_to')
diff --git a/cubicweb_saem_ref/schema.py b/cubicweb_saem_ref/schema.py
--- a/cubicweb_saem_ref/schema.py
+++ b/cubicweb_saem_ref/schema.py
@@ -28,8 +28,10 @@ from cubicweb.schemas.base import Extern
 from cubicweb_skos import schema as skos
 from cubicweb_prov import schema as prov
 from cubicweb_eac import schema as eac
-from cubicweb_seda.schema import simplified_profile
-from cubicweb_seda.schema.seda2 import SEDAArchiveTransfer
+from cubicweb_seda.schema import (
+    seda2,
+    simplified_profile,
+)
 from cubicweb_compound import utils
 
 
@@ -473,13 +475,18 @@ class optional_ark_naa(_ark_naa):
 
 # SEDA #######################################################################
 
-make_workflowable(SEDAArchiveTransfer)
-publication_permissions(SEDAArchiveTransfer)
+make_workflowable(seda2.SEDAArchiveTransfer)
+publication_permissions(seda2.SEDAArchiveTransfer)
 
 
 simplified_profile.default = True
 
 
+seda2.originating_agency_originating_agency_to.constraints.append(
+    RQLConstraint('O in_state ST, ST name "published"')
+)
+
+
 @authority_permissions_rdef
 class use_profile(RelationDefinition):
     subject = 'OrganizationUnit'



More information about the saem-devel mailing list