[PATCH 5 of 5 seda] [views] Attempt to display inherited rule if there is no rule defined at some level

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Mar 17 10:45:13 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1489741310 -3600
#      Fri Mar 17 10:01:50 2017 +0100
# Node ID 341e39717d65c7c14e864993f8e1d4e91bf6fac8
# Parent  6ba8714893470ce571da20d437898696cfe2dece
[views] Attempt to display inherited rule if there is no rule defined at some level

Closes extranet #14593198

diff --git a/cubicweb_seda/i18n/en.po b/cubicweb_seda/i18n/en.po
--- a/cubicweb_seda/i18n/en.po
+++ b/cubicweb_seda/i18n/en.po
@@ -4754,10 +4754,13 @@ msgid "format_litteral"
 msgstr ""
 
 msgid "import_unit"
 msgstr ""
 
+msgid "inherited value"
+msgstr ""
+
 msgid "juridictional"
 msgstr ""
 
 msgctxt "SEDAJuridictional"
 msgid "juridictional"
diff --git a/cubicweb_seda/i18n/fr.po b/cubicweb_seda/i18n/fr.po
--- a/cubicweb_seda/i18n/fr.po
+++ b/cubicweb_seda/i18n/fr.po
@@ -4773,10 +4773,13 @@ msgid "format_litteral"
 msgstr ""
 
 msgid "import_unit"
 msgstr "unité d'archive du référentiel"
 
+msgid "inherited value"
+msgstr "valeur héritée"
+
 msgid "juridictional"
 msgstr "juridication administrative"
 
 msgctxt "SEDAJuridictional"
 msgid "juridictional"
diff --git a/cubicweb_seda/views/mgmt_rules.py b/cubicweb_seda/views/mgmt_rules.py
--- a/cubicweb_seda/views/mgmt_rules.py
+++ b/cubicweb_seda/views/mgmt_rules.py
@@ -21,11 +21,11 @@ from six import text_type
 
 from logilab.mtconverter import xml_escape
 
 from cubicweb.predicates import is_instance
 from cubicweb.web import INTERNAL_FIELD_VALUE
-from cubicweb.web.views import uicfg
+from cubicweb.web.views import reledit, uicfg
 
 from ..entities import parent_and_container, rule_type_from_etype
 from . import viewlib
 from . import uicfg as sedauicfg  # noqa - ensure those rules are defined first
 
@@ -178,5 +178,20 @@ class ClassificationRuleComplexLinkEntit
                 need_human = _('need human intervention')
             else:
                 need_human = _('without human intervention')
             self.w(u'<div>{0}</div>'.format(xml_escape(need_human)))
         super(ClassificationRuleComplexLinkEntityAttributeView, self).entity_call(entity)
+
+
+class MgmtRuleAutoClickAndEditFormView(reledit.AutoClickAndEditFormView):
+    __select__ = (reledit.AutoClickAndEditFormView.__select__
+                  & is_instance('SEDASeqAltArchiveUnitArchiveUnitRefIdManagement'))
+
+    def _compute_default_value(self, rschema, role):
+        if rschema.type.endswith('_rule'):
+            rule_type = rschema.type[len('seda_'):-len('_rule')]
+            rule = self.entity.inherited_rule(rule_type)
+            if rule:
+                return rule.view('seda.reledit.text') + u'<p><mark>{}</mark></p>'.format(
+                    self._cw._(u'inherited value'))
+        return super(MgmtRuleAutoClickAndEditFormView, self)._compute_default_value(
+            rschema, role)


More information about the saem-devel mailing list