Fix format_supported selector to consider if a profile is simplified or not
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 17 Oct 2016 17:19:41 +0200
changeset 1849 8e833a9015e2
parent 1848 44879714e928
child 1850 c6c1802ebba9
Fix format_supported selector to consider if a profile is simplified or not
test/test_views.py
views/export.py
--- a/test/test_views.py	Mon Oct 17 14:43:32 2016 +0200
+++ b/test/test_views.py	Mon Oct 17 17:19:41 2016 +0200
@@ -157,7 +157,8 @@
         predicate = export.format_supported()
 
         with self.admin_access.web_request() as req:
-            transfer = req.create_entity('SEDAArchiveTransfer', title=u'Test widget')
+            transfer = req.create_entity('SEDAArchiveTransfer', title=u'Test widget',
+                                         simplified_profile=True)
             req.cnx.commit()
 
             for seda_version in ('2.0', '1.0', '0.2'):
@@ -196,6 +197,14 @@
             self.assertEqual(predicate(None, req, entity=transfer, version='1.0'),
                              0)
 
+            transfer.cw_set(simplified_profile=False)
+            req.cnx.commit()  # will reset compat_list
+
+            self.assertEqual(predicate(None, req, entity=transfer, version='2.0'),
+                             1)
+            self.assertEqual(predicate(None, req, entity=transfer, version='1.0'),
+                             0)
+
 
 class ArchiveTransferDiagnoseTabTC(CubicWebTC):
 
@@ -212,7 +221,8 @@
 
     def test_selected_export_class(self):
         with self.admin_access.web_request() as req:
-            transfer = req.create_entity('SEDAArchiveTransfer', title=u'diagnosis testing')
+            transfer = req.create_entity('SEDAArchiveTransfer', title=u'diagnosis testing',
+                                         simplified_profile=True)
             unit, unit_alt, unit_alt_seq = create_archive_unit(transfer)
             req.cnx.commit()
 
--- a/views/export.py	Mon Oct 17 14:43:32 2016 +0200
+++ b/views/export.py	Mon Oct 17 17:19:41 2016 +0200
@@ -31,6 +31,8 @@
     if entity is None:
         entity = rset.get_entity(0, 0)
     version = getattr(cls, 'seda_version', kwargs.get('version', req.form.get('version', '2.0')))
+    if version != '2.0' and not entity.simplified_profile:
+        return 0
     return int(('SEDA ' + version) in entity.formats_compat)