Fix detection of SEDAStartDate within the context of an archive unit
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 13 Jun 2017 12:04:06 +0200
changeset 2646 a21a6e5f04c4
parent 2645 0d8167d5a77e
child 2649 8e9585bcc97c
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
cubicweb_seda/views/simplified.py
--- a/cubicweb_seda/views/simplified.py	Tue Jun 13 12:01:22 2017 +0200
+++ b/cubicweb_seda/views/simplified.py	Tue Jun 13 12:04:06 2017 +0200
@@ -58,12 +58,12 @@
         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