Commit 9b721884 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[ui] Management rules handling

Fix the model so that rules are properly linked to concept,
Introduces custom entity classes and views to handle those complex objects.

Closes #12663502
parent dbb9f4c168d0
......@@ -14,11 +14,10 @@
# 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/>.
from cubes.seda.entities.generated import (SEDAArchiveUnit, SEDAAltArchiveUnitArchiveUnitRefId,
SEDAContent)
from cubes.seda.entities import generated
class SEDAArchiveUnit(SEDAArchiveUnit):
class SEDAArchiveUnit(generated.SEDAArchiveUnit):
@property
def first_level_choice(self):
......@@ -28,7 +27,7 @@ class SEDAArchiveUnit(SEDAArchiveUnit):
return self.related('seda_alt_archive_unit_archive_unit_ref_id', 'subject').one()
class SEDAAltArchiveUnitArchiveUnitRefId(SEDAAltArchiveUnitArchiveUnitRefId):
class SEDAAltArchiveUnitArchiveUnitRefId(generated.SEDAAltArchiveUnitArchiveUnitRefId):
@property
def reference(self):
......@@ -48,8 +47,48 @@ class SEDAAltArchiveUnitArchiveUnitRefId(SEDAAltArchiveUnitArchiveUnitRefId):
return None
class SEDAContent(SEDAContent):
class SEDAContent(generated.SEDAContent):
def dc_title(self):
seda_title = self.reverse_seda_title[0]
return seda_title.title or self._cw._('<no title specified>')
class RuleMixIn(object):
@property
def _rule_type(self):
return self.cw_etype[4:-4].lower()
@property
def rules(self):
return getattr(self, 'seda_seq_{0}_rule_rule'.format(self._rule_type))
@property
def inheritance_control(self):
alt = getattr(self, 'seda_alt_{0}_rule_prevent_inheritance'.format(self._rule_type))
return alt[0] if alt else None
class SEDAAccessRule(RuleMixIn, generated.SEDAAccessRule):
pass
class SEDAAppraisalRule(RuleMixIn, generated.SEDAAppraisalRule):
pass
class SEDAClassificationRule(RuleMixIn, generated.SEDAClassificationRule):
pass
class SEDADisseminationRule(RuleMixIn, generated.SEDADisseminationRule):
pass
class SEDAReuseRule(RuleMixIn, generated.SEDAReuseRule):
pass
class SEDAStorageRule(RuleMixIn, generated.SEDAStorageRule):
pass
......@@ -89,8 +89,8 @@ class SEDAReuseRule(AnyEntity):
class SEDAClassificationRule(AnyEntity):
__regid__ = 'SEDAClassificationRule'
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
value_attr = None
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality', 'classification_owner'])
value_attr = 'classification_owner'
class SEDANeedAuthorization(AnyEntity):
__regid__ = 'SEDANeedAuthorization'
......@@ -127,11 +127,6 @@ class SEDARefNonRuleId(AnyEntity):
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
value_attr = None
class SEDARule(AnyEntity):
__regid__ = 'SEDARule'
fetch_attrs, cw_fetch_order = fetch_config([])
value_attr = None
class SEDAStartDate(AnyEntity):
__regid__ = 'SEDAStartDate'
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
......
......@@ -21,6 +21,21 @@ msgstr ""
msgid ", of relationship type %s"
msgstr ""
msgid "<no classification level specified>"
msgstr ""
msgid "<no classification owner specified>"
msgstr ""
msgid "<no final action specified>"
msgstr ""
msgid "<no rule specified>"
msgstr ""
msgid "<no rule to prevent specified>"
msgstr ""
msgid "<no title specified>"
msgstr ""
......@@ -377,9 +392,6 @@ msgstr ""
msgid "New SEDAReuseRuleCodeListVersion"
msgstr ""
msgid "New SEDARule"
msgstr ""
msgid "New SEDASentDate"
msgstr ""
......@@ -1300,34 +1312,35 @@ msgid "SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltAccessRulePreventInheritance.seda_ref_non_rule_id.object"
"inlined:SEDAAltAccessRulePreventInheritance.seda_ref_non_rule_id_from.object"
msgid "SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltAppraisalRulePreventInheritance.seda_ref_non_rule_id.object"
"inlined:SEDAAltAppraisalRulePreventInheritance.seda_ref_non_rule_id_from."
"object"
msgid "SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltClassificationRulePreventInheritance.seda_ref_non_rule_id."
"object"
"inlined:SEDAAltClassificationRulePreventInheritance."
"seda_ref_non_rule_id_from.object"
msgid "SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltDisseminationRulePreventInheritance.seda_ref_non_rule_id."
"inlined:SEDAAltDisseminationRulePreventInheritance.seda_ref_non_rule_id_from."
"object"
msgid "SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltReuseRulePreventInheritance.seda_ref_non_rule_id.object"
"inlined:SEDAAltReuseRulePreventInheritance.seda_ref_non_rule_id_from.object"
msgid "SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltStorageRulePreventInheritance.seda_ref_non_rule_id.object"
"inlined:SEDAAltStorageRulePreventInheritance.seda_ref_non_rule_id_from.object"
msgid "SEDARefNonRuleId"
msgstr ""
......@@ -1491,36 +1504,6 @@ msgstr ""
msgid "SEDAReuseRule_plural"
msgstr ""
msgid "SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqAccessRuleRule.seda_rule.subject"
msgid "SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqAppraisalRuleRule.seda_rule.subject"
msgid "SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqClassificationRuleRule.seda_rule.subject"
msgid "SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqDisseminationRuleRule.seda_rule.subject"
msgid "SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqReuseRuleRule.seda_rule.subject"
msgid "SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqStorageRuleRule.seda_rule.subject"
msgid "SEDARule"
msgstr ""
msgid "SEDARule_plural"
msgstr ""
msgid "SEDASentDate"
msgstr ""
......@@ -2542,12 +2525,6 @@ msgstr ""
msgid "This SEDAReuseRuleCodeListVersion:"
msgstr ""
msgid "This SEDARule"
msgstr ""
msgid "This SEDARule:"
msgstr ""
msgid "This SEDASentDate"
msgstr ""
......@@ -3303,34 +3280,35 @@ msgid "add a SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltAccessRulePreventInheritance.seda_ref_non_rule_id.object"
"inlined:SEDAAltAccessRulePreventInheritance.seda_ref_non_rule_id_from.object"
msgid "add a SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltAppraisalRulePreventInheritance.seda_ref_non_rule_id.object"
"inlined:SEDAAltAppraisalRulePreventInheritance.seda_ref_non_rule_id_from."
"object"
msgid "add a SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltClassificationRulePreventInheritance.seda_ref_non_rule_id."
"object"
"inlined:SEDAAltClassificationRulePreventInheritance."
"seda_ref_non_rule_id_from.object"
msgid "add a SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltDisseminationRulePreventInheritance.seda_ref_non_rule_id."
"inlined:SEDAAltDisseminationRulePreventInheritance.seda_ref_non_rule_id_from."
"object"
msgid "add a SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltReuseRulePreventInheritance.seda_ref_non_rule_id.object"
"inlined:SEDAAltReuseRulePreventInheritance.seda_ref_non_rule_id_from.object"
msgid "add a SEDARefNonRuleId"
msgstr ""
msgctxt ""
"inlined:SEDAAltStorageRulePreventInheritance.seda_ref_non_rule_id.object"
"inlined:SEDAAltStorageRulePreventInheritance.seda_ref_non_rule_id_from.object"
msgid "add a SEDARefNonRuleId"
msgstr ""
......@@ -3452,33 +3430,6 @@ msgstr ""
msgid "add a SEDAReuseRuleCodeListVersion"
msgstr ""
msgid "add a SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqAccessRuleRule.seda_rule.subject"
msgid "add a SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqAppraisalRuleRule.seda_rule.subject"
msgid "add a SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqClassificationRuleRule.seda_rule.subject"
msgid "add a SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqDisseminationRuleRule.seda_rule.subject"
msgid "add a SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqReuseRuleRule.seda_rule.subject"
msgid "add a SEDARule"
msgstr ""
msgctxt "inlined:SEDASeqStorageRuleRule.seda_rule.subject"
msgid "add a SEDARule"
msgstr ""
msgid "add a SEDASentDate"
msgstr ""
......@@ -3730,6 +3681,21 @@ msgstr ""
msgid "archive unit (reference)"
msgstr ""
#, python-brace-format
msgid "classification level: {0}"
msgstr ""
#, python-brace-format
msgid "classification owner: {0}"
msgstr ""
msgid "classification_owner"
msgstr ""
msgctxt "SEDAClassificationRule"
msgid "classification_owner"
msgstr ""
msgctxt "SEDAComment"
msgid "comment"
msgstr ""
......@@ -4172,10 +4138,6 @@ msgctxt "SEDAReuseRuleCodeListVersion"
msgid "container"
msgstr ""
msgctxt "SEDARule"
msgid "container"
msgstr ""
msgctxt "SEDASentDate"
msgid "container"
msgstr ""
......@@ -4507,6 +4469,9 @@ msgctxt "SEDADocumentType"
msgid "document_type"
msgstr ""
msgid "don't prevent inheritance"
msgstr ""
msgid "file_plan_position"
msgstr ""
......@@ -4514,6 +4479,10 @@ msgctxt "SEDAFilePlanPosition"
msgid "file_plan_position"
msgstr ""
#, python-brace-format
msgid "final action: {0}"
msgstr ""
msgid "format_litteral"
msgstr ""
......@@ -4561,6 +4530,9 @@ msgctxt "Agent"
msgid "name"
msgstr ""
msgid "need human intervention"
msgstr ""
msgid "need_authorization"
msgstr ""
......@@ -4585,6 +4557,13 @@ msgctxt "SEDAOriginatingAgencyArchiveUnitIdentifier"
msgid "originating_agency_archive_unit_identifier"
msgstr ""
msgid "prevent all rules"
msgstr ""
#, python-brace-format
msgid "prevent rule {0}"
msgstr ""
msgid "prevent_inheritance"
msgstr ""
......@@ -4606,6 +4585,10 @@ msgctxt "SEDArestrictionValue"
msgid "restriction_value"
msgstr ""
#, python-brace-format
msgid "rule: {0}"
msgstr ""
msgid "scheme_entity_type"
msgstr ""
......@@ -5194,20 +5177,6 @@ msgctxt "Concept"
msgid "seda_classification_level_object"
msgstr ""
msgid "seda_classification_owner"
msgstr ""
msgctxt "SEDAClassificationRule"
msgid "seda_classification_owner"
msgstr ""
msgid "seda_classification_owner_object"
msgstr ""
msgctxt "Agent"
msgid "seda_classification_owner_object"
msgstr ""
msgid "seda_classification_reassessing_date"
msgstr ""
......@@ -6587,38 +6556,52 @@ msgctxt "Agent"
msgid "seda_recipient_to_object"
msgstr ""
msgid "seda_ref_non_rule_id"
msgid "seda_ref_non_rule_id_from"
msgstr ""
msgctxt "SEDARefNonRuleId"
msgid "seda_ref_non_rule_id"
msgid "seda_ref_non_rule_id_from"
msgstr ""
msgid "seda_ref_non_rule_id_object"
msgid "seda_ref_non_rule_id_from_object"
msgstr ""
msgctxt "SEDAAltAccessRulePreventInheritance"
msgid "seda_ref_non_rule_id_object"
msgid "seda_ref_non_rule_id_from_object"
msgstr ""
msgctxt "SEDAAltAppraisalRulePreventInheritance"
msgid "seda_ref_non_rule_id_object"
msgid "seda_ref_non_rule_id_from_object"
msgstr ""
msgctxt "SEDAAltClassificationRulePreventInheritance"
msgid "seda_ref_non_rule_id_object"
msgid "seda_ref_non_rule_id_from_object"
msgstr ""
msgctxt "SEDAAltDisseminationRulePreventInheritance"
msgid "seda_ref_non_rule_id_object"
msgid "seda_ref_non_rule_id_from_object"
msgstr ""
msgctxt "SEDAAltReuseRulePreventInheritance"
msgid "seda_ref_non_rule_id_object"
msgid "seda_ref_non_rule_id_from_object"
msgstr ""
msgctxt "SEDAAltStorageRulePreventInheritance"
msgid "seda_ref_non_rule_id_object"
msgid "seda_ref_non_rule_id_from_object"
msgstr ""
msgid "seda_ref_non_rule_id_to"
msgstr ""
msgctxt "SEDARefNonRuleId"
msgid "seda_ref_non_rule_id_to"
msgstr ""
msgid "seda_ref_non_rule_id_to_object"
msgstr ""
msgctxt "Concept"
msgid "seda_ref_non_rule_id_to_object"
msgstr ""
msgid "seda_referenced_object"
......@@ -6957,7 +6940,7 @@ msgstr ""
msgid "seda_rule_object"
msgstr ""
msgctxt "SEDARule"
msgctxt "Concept"
msgid "seda_rule_object"
msgstr ""
......@@ -8246,3 +8229,20 @@ msgstr ""
msgctxt "SEDAVersion"
msgid "version"
msgstr ""
#, python-brace-format
msgid "with {0} reassessing date"
msgstr ""
#, python-brace-format
msgid "with {0} start date"
msgstr ""
msgid "without human intervention"
msgstr ""
msgid "without reassessing date"
msgstr ""
msgid "without start date"
msgstr ""
This diff is collapsed.
......@@ -264,6 +264,7 @@ class archive_transfer_reuse_rule(RelationDefinition):
annotable=False)
class SEDAClassificationRule(EntityType):
u""""""
classification_owner = String()
class archive_transfer_classification_rule(RelationDefinition):
......@@ -330,15 +331,6 @@ class classification_rule_classification_level(RelationDefinition):
inlined = True
constraints = [RQLConstraint('O in_scheme CS, CS scheme_relation_type CR, CR name "seda_classification_level"')]
class classification_rule_classification_owner(RelationDefinition):
name = 'seda_classification_owner'
subject = 'SEDAClassificationRule'
object = 'Agent'
cardinality = '?*'
composite = fulltext_container = None
inlined = True
constraints = []
@seda_profile_element(cardinalities=['0..1', '1'], default_cardinality='0..1',
annotable=False)
class SEDAClassificationReassessingDate(EntityType):
......@@ -392,29 +384,32 @@ class SEDARefNonRuleId(EntityType):
u""""""
class alt_classification_rule_prevent_inheritance_ref_non_rule_id(RelationDefinition):
name = 'seda_ref_non_rule_id'
class alt_classification_rule_prevent_inheritance_ref_non_rule_id_from(RelationDefinition):
name = 'seda_ref_non_rule_id_from'
subject = 'SEDARefNonRuleId'
object = 'SEDAAltClassificationRulePreventInheritance'
object = ('SEDAAltAccessRulePreventInheritance', 'SEDAAltAppraisalRulePreventInheritance', 'SEDAAltClassificationRulePreventInheritance', 'SEDAAltDisseminationRulePreventInheritance', 'SEDAAltReuseRulePreventInheritance', 'SEDAAltStorageRulePreventInheritance')
cardinality = '1*'
composite = fulltext_container = 'object'
inlined = True
constraints = []
@seda_profile_element(cardinalities=['1'], default_cardinality='1',
annotable=False)
class SEDARule(EntityType):
u""""""
class ref_non_rule_id_ref_non_rule_id_to(RelationDefinition):
name = 'seda_ref_non_rule_id_to'
subject = 'SEDARefNonRuleId'
object = 'Concept'
cardinality = '**'
composite = fulltext_container = None
inlined = False
constraints = []
class seq_classification_rule_rule_rule(RelationDefinition):
name = 'seda_rule'
subject = 'SEDASeqClassificationRuleRule'
object = 'SEDARule'
cardinality = '11'
composite = fulltext_container = 'subject'
object = 'Concept'
cardinality = '?*'
composite = fulltext_container = None
inlined = True
constraints = []
constraints = [RQLConstraint('O in_scheme CS, CACLV seda_classification_rule_code_list_version_from AT, CACLV seda_classification_rule_code_list_version_to CS,S container AT')]
@seda_profile_element(cardinalities=['0..1', '1'], default_cardinality='0..1',
annotable=False)
......@@ -461,23 +456,14 @@ class reuse_rule_alt_reuse_rule_prevent_inheritance(RelationDefinition):
inlined = False
constraints = []
class alt_reuse_rule_prevent_inheritance_ref_non_rule_id(RelationDefinition):
name = 'seda_ref_non_rule_id'
subject = 'SEDARefNonRuleId'
object = 'SEDAAltReuseRulePreventInheritance'
cardinality = '1*'
composite = fulltext_container = 'object'
inlined = True
constraints = []
class seq_reuse_rule_rule_rule(RelationDefinition):
name = 'seda_rule'
subject = 'SEDASeqReuseRuleRule'
object = 'SEDARule'
cardinality = '11'
composite = fulltext_container = 'subject'
object = 'Concept'
cardinality = '?*'
composite = fulltext_container = None
inlined = True
constraints = []
constraints = [RQLConstraint('O in_scheme CS, CACLV seda_reuse_rule_code_list_version_from AT, CACLV seda_reuse_rule_code_list_version_to CS,S container AT')]
@seda_profile_element(cardinalities=['0..1', '0..n', '1', '1..n'], default_cardinality='0..1',
annotable=False)
......@@ -509,23 +495,14 @@ class dissemination_rule_alt_dissemination_rule_prevent_inheritance(RelationDefi
inlined = False
constraints = []
class alt_dissemination_rule_prevent_inheritance_ref_non_rule_id(RelationDefinition):
name = 'seda_ref_non_rule_id'
subject = 'SEDARefNonRuleId'
object = 'SEDAAltDisseminationRulePreventInheritance'
cardinality = '1*'
composite = fulltext_container = 'object'
inlined = True
constraints = []
class seq_dissemination_rule_rule_rule(RelationDefinition):
name = 'seda_rule'
subject = 'SEDASeqDisseminationRuleRule'
object = 'SEDARule'
cardinality = '11'
composite = fulltext_container = 'subject'
object = 'Concept'
cardinality = '?*'
composite = fulltext_container = None
inlined = True
constraints = []
constraints = [RQLConstraint('O in_scheme CS, CACLV seda_dissemination_rule_code_list_version_from AT, CACLV seda_dissemination_rule_code_list_version_to CS,S container AT')]
@seda_profile_element(cardinalities=['0..1', '0..n', '1', '1..n'], default_cardinality='0..1',
annotable=False)
......@@ -557,23 +534,14 @@ class access_rule_alt_access_rule_prevent_inheritance(RelationDefinition):
inlined = False
constraints = []
class alt_access_rule_prevent_inheritance_ref_non_rule_id(RelationDefinition):
name = 'seda_ref_non_rule_id'
subject = 'SEDARefNonRuleId'
object = 'SEDAAltAccessRulePreventInheritance'
cardinality = '1*'
composite = fulltext_container = 'object'
inlined = True
constraints = []
class seq_access_rule_rule_rule(RelationDefinition):
name = 'seda_rule'
subject = 'SEDASeqAccessRuleRule'
object = 'SEDARule'
cardinality = '11'
composite = fulltext_container = 'subject'
object = 'Concept'
cardinality = '?*'
composite = fulltext_container = None
inlined = True
constraints = []
constraints = [RQLConstraint('O in_scheme CS, CACLV seda_access_rule_code_list_version_from AT, CACLV seda_access_rule_code_list_version_to CS,S container AT')]
@seda_profile_element(cardinalities=['0..1', '0..n', '1', '1..n'], default_cardinality='0..1',
annotable=False)
......@@ -612,25 +580,16 @@ class appraisal_rule_final_action(RelationDefinition):
cardinality = '?*'
composite = fulltext_container = None
inlined = True
constraints = [RQLConstraint('O in_scheme CS, CACLV seda_appraisal_rule_code_list_version_from AT, CACLV seda_appraisal_rule_code_list_version_to CS,S container AT')]
class alt_appraisal_rule_prevent_inheritance_ref_non_rule_id(RelationDefinition):
name = 'seda_ref_non_rule_id'
subject = 'SEDARefNonRuleId'
object = 'SEDAAltAppraisalRulePreventInheritance'
cardinality = '1*'
composite = fulltext_container = 'object'
inlined = True