Consistently use CONTENT_ETYPE global in view
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 11 Jan 2017 09:50:56 +0100
changeset 2272 5f865a907e6c
parent 2271 e5d4d14ac7d3
child 2291 82a17de65358
Consistently use CONTENT_ETYPE global in view instead of 'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement' which is boring to read and remember. Related to #16684017
views/archiveunit.py
views/content.py
views/simplified.py
views/viewlib.py
--- a/views/archiveunit.py	Wed Jan 11 09:43:26 2017 +0100
+++ b/views/archiveunit.py	Wed Jan 11 09:50:56 2017 +0100
@@ -116,7 +116,7 @@
     the parent
     """
     __select__ = is_instance('SEDAAltArchiveUnitArchiveUnitRefId',
-                             'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement')
+                             CONTENT_ETYPE)
 
     def breadcrumbs(self, view=None, recurs=None):
         parent = self.parent_entity()
@@ -127,7 +127,7 @@
 class SkipInContextView(baseviews.InContextView):
     """Custom incontext view, for use in title of creation form, among others"""
     __select__ = is_instance('SEDAAltArchiveUnitArchiveUnitRefId',
-                             'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement')
+                             CONTENT_ETYPE)
 
     def cell_call(self, row, col):
         entity = self.cw_rset.get_entity(row, col)
@@ -188,7 +188,7 @@
         ('seda_need_authorization', 'object', None),
     ]
     rsection, display_ctrl = rtags_from_rtype_role_targets(
-        'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement', rtype_role_targets
+        CONTENT_ETYPE, rtype_role_targets
     )
 
     def entity_call(self, entity, **kwargs):
@@ -204,7 +204,7 @@
         ('seda_access_rule', 'object', None),
     ]
     rsection, display_ctrl = rtags_from_rtype_role_targets(
-        'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement', rtype_role_targets
+        CONTENT_ETYPE, rtype_role_targets
     )
 
 
@@ -425,11 +425,9 @@
 # other for archive unit content. This is done by a mix of uicfg, form and renderer customization
 # depending on a 'unit_type' parameter in form params.
 
-pvs.tag_object_of(('*', 'seda_data_object_reference',
-                   'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement'),
+pvs.tag_object_of(('*', 'seda_data_object_reference', CONTENT_ETYPE),
                   'hidden')
-afs.tag_object_of(('*', 'seda_data_object_reference',
-                   'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement'),
+afs.tag_object_of(('*', 'seda_data_object_reference', CONTENT_ETYPE),
                   'main', 'hidden')
 
 
@@ -473,7 +471,7 @@
 
     __select__ = (widgets.NoTitleEntityInlinedFormRenderer.__select__
                   & (is_instance('SEDAAltArchiveUnitArchiveUnitRefId',
-                                 'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement')
+                                 CONTENT_ETYPE)
                      | (is_instance('SEDAArchiveUnitRefId')
                         & is_archive_unit_ref())))
 
--- a/views/content.py	Wed Jan 11 09:43:26 2017 +0100
+++ b/views/content.py	Wed Jan 11 09:50:56 2017 +0100
@@ -54,7 +54,7 @@
                 return 0
     else:
         entity = entity.seda_data_object_reference[0]
-    if entity is not None and entity.cw_etype == 'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement':
+    if entity is not None and entity.cw_etype == CONTENT_ETYPE:
         return 0
     return 1
 
--- a/views/simplified.py	Wed Jan 11 09:43:26 2017 +0100
+++ b/views/simplified.py	Wed Jan 11 09:50:56 2017 +0100
@@ -21,7 +21,7 @@
 from cubicweb.web.views import uicfg, autoform, formrenderers
 
 from ..entities import simplified_profile
-from . import copy_rtag
+from . import CONTENT_ETYPE, copy_rtag
 # ensure those are registered first
 from . import mgmt_rules, archivetransfer, dataobject, archiveunit, content  # noqa
 
@@ -62,8 +62,7 @@
             start_date_of = self.edited_entity.seda_start_date[0]
         else:
             start_date_of = None
-        if (start_date_of is None
-                or start_date_of.cw_etype != 'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement'):
+        if start_date_of is None or start_date_of.cw_etype != CONTENT_ETYPE:
             attributes.remove(('user_cardinality', 'subject'))
         return attributes
 
--- a/views/viewlib.py	Wed Jan 11 09:43:26 2017 +0100
+++ b/views/viewlib.py	Wed Jan 11 09:50:56 2017 +0100
@@ -22,7 +22,7 @@
 
 from ..xsd import un_camel_case
 from ..xsd2uicfg import FIRST_LEVEL_ETYPES
-from . import add_subobjects_button
+from . import CONTENT_ETYPE, add_subobjects_button
 
 
 class XSDMetaEntityView(EntityView):
@@ -306,7 +306,7 @@
     to a data object (not a qualified reference, eg IsVersionOf, IsPartOf, Reference, etc.).
     """
     parent = reference.seda_data_object_reference[0]
-    return parent.cw_etype == 'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement'
+    return parent.cw_etype == CONTENT_ETYPE
 
 
 class MainDataObjectReferenceBusinessValueLinkEntityView(BusinessValueLinkEntityView):
@@ -339,7 +339,7 @@
 
     def entity_call(self, entity):
         au_seq = entity.seda_data_object_reference[0]
-        if au_seq.cw_etype == 'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement':
+        if au_seq.cw_etype == CONTENT_ETYPE:
             au_choice = au_seq.reverse_seda_seq_alt_archive_unit_archive_unit_ref_id_management[0]
             target = au_choice.reverse_seda_alt_archive_unit_archive_unit_ref_id[0]
         else: