[PATCH 2 of 2 seda] Fix detection of SEDAStartDate within the context of an archive unit

Sylvain Thenault sylvain.thenault at logilab.fr
Tue Jun 13 14:35:48 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1497348246 -7200
#      Tue Jun 13 12:04:06 2017 +0200
# Node ID a21a6e5f04c4a353e269ff7a174eb78e8e19cdc8
# Parent  0d8167d5a77e0af9b3cff38703a9d50dd4019df1
# Available At https://hg.logilab.org/review/cubes/seda
#              hg pull https://hg.logilab.org/review/cubes/seda -r a21a6e5f04c4
Fix detection of SEDAStartDate within the context of an archive unit

in which case we want the cardinality to be editable. To fix this, we've to
consider inlined creation view's "petype" parameter. This has probably not be
necessary until now becase SEDAStartDate wasn't until recently editable at
entity creation time.

Closes #17084051

diff --git a/cubicweb_seda/views/simplified.py b/cubicweb_seda/views/simplified.py
--- a/cubicweb_seda/views/simplified.py
+++ b/cubicweb_seda/views/simplified.py
@@ -56,16 +56,16 @@ class StartDateAutomaticEntityForm(autof
     def editable_attributes(self, strict=False):
         """return a list of (relation schema, role) to edit for the entity"""
         attributes = super(StartDateAutomaticEntityForm, self).editable_attributes(strict)
         if self.linked_to.get(('seda_start_date', 'subject')):
             eid = self.linked_to[('seda_start_date', 'subject')][0]
-            start_date_of = self._cw.entity_from_eid(eid)
+            start_date_of = self._cw.entity_from_eid(eid).cw_etype
         elif self.edited_entity.has_eid():
-            start_date_of = self.edited_entity.seda_start_date[0]
+            start_date_of = self.edited_entity.seda_start_date[0].cw_etype
         else:
-            start_date_of = None
-        if start_date_of is None or start_date_of.cw_etype != CONTENT_ETYPE:
+            start_date_of = self.cw_extra_kwargs.get('petype')
+        if start_date_of != CONTENT_ETYPE:
             attributes.remove(('user_cardinality', 'subject'))
         return attributes
 
 
 class RuleAutomaticEntityForm(autoform.AutomaticEntityForm):


More information about the saem-devel mailing list