[PATCH 2 of 4 saem_ref] [schema] Allow to delete/update a concept scheme in "deprecated" state

Denis Laxalde denis.laxalde at logilab.fr
Fri Apr 13 14:35:08 CEST 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1523539941 -7200
#      Thu Apr 12 15:32:21 2018 +0200
# Node ID ac4b89c371aaeba271419859171cc860e016f5e7
# Parent  31a3846bab46a63f4832bd37a5a1fbeef3a451e3
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r ac4b89c371aa
# EXP-Topic CONSEJIRA-447
[schema] Allow to delete/update a concept scheme in "deprecated" state

CONSEJIRA-447.

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
@@ -135,7 +135,9 @@ for etype_def in (eac.ChronologicalRelat
 # SKOS #########################################################################
 
 make_workflowable(skos.ConceptScheme)
-publication_permissions(skos.ConceptScheme, groups=('managers',))
+publication_permissions(skos.ConceptScheme,
+                        groups=('managers',),
+                        states=('draft', 'deprecated'))
 skos.ConceptScheme.__permissions__['add'] = ('managers',)
 
 skos.in_scheme.cardinality = '1*'
diff --git a/test/test_security.py b/test/test_security.py
--- a/test/test_security.py
+++ b/test/test_security.py
@@ -132,6 +132,17 @@ class NonManagerUserTC(CubicWebTC):
                               label_of=type_concept)
             cnx.commit()
 
+    def test_deprecated_vocabulary_can_be_deleted(self):
+        with self.admin_access.cnx() as cnx:
+            scheme = testutils.setup_scheme(cnx, u'my scheme', u'lab1', u'lab2')
+            cnx.commit()
+            scheme.cw_adapt_to('IWorkflowable').fire_transition('publish')
+            cnx.commit()
+            with self.assertUnauthorized(cnx):
+                scheme.cw_delete()
+            scheme.cw_adapt_to('IWorkflowable').fire_transition('deprecate')
+            scheme.cw_delete()
+
     def test_create_update_agent_in_own_organization(self):
         with self.admin_access.cnx() as cnx:
             other_authority = testutils.authority_with_naa(cnx, name=u'other authority')
@@ -462,6 +473,13 @@ class ManagerUserTC(CubicWebTC):
                 scheme.cw_delete()
             with self.assertUnauthorized(cnx):
                 new_concept.cw_delete()
+            # deprecated, deletion (and update) is allowed.
+            scheme.cw_adapt_to('IWorkflowable').fire_transition('deprecate')
+            cnx.commit()
+            new_concept.cw_delete()
+            cnx.commit()
+            scheme.cw_delete()
+            cnx.commit()
 
 
 if __name__ == '__main__':



More information about the saem-devel mailing list