[ui] Add an action to expose RNG export. Closes #14022989
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 06 Jul 2016 20:12:37 +0200
changeset 1341 a68075226224
parent 1340 a6fd38685740
child 1368 ef09c56b211b
[ui] Add an action to expose RNG export. Closes #14022989
views/xsd.py
--- a/views/xsd.py	Wed Jul 06 18:38:52 2016 +0200
+++ b/views/xsd.py	Wed Jul 06 20:12:37 2016 +0200
@@ -22,18 +22,24 @@
 _ = unicode
 
 
-class SEDA2DownloadAction(action.Action):
+class SEDA2DownloadRNGAction(action.Action):
     __regid__ = 'seda.seda2export'
     __select__ = (action.Action.__select__
                   & one_line_rset()
                   & is_instance('SEDAArchiveTransfer'))
+    category = 'moreactions'
 
-    title = _('SEDA 2.0 export')
-    category = 'moreactions'
+    title = _('SEDA 2.0 RNG export')
+    export_format = 'rng'
 
     def url(self):
         entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
-        return entity.absolute_url(vid=self.__regid__)
+        return entity.absolute_url(vid=self.__regid__, format=self.export_format)
+
+
+class SEDA2DownloadXSDAction(SEDA2DownloadRNGAction):
+    title = _('SEDA 2.0 XSD export')
+    export_format = 'xsd'
 
 
 class SEDA2DownloadView(idownloadable.DownloadView):
@@ -42,7 +48,10 @@
     __select__ = one_line_rset() & is_instance('SEDAArchiveTransfer')
 
     http_cache_manager = httpcache.NoHTTPCacheManager
-    seda_adapter_id = 'SEDA-2.0.xsd'
+
+    @property
+    def seda_adapter_id(self):
+        return 'SEDA-2.0.' + self._cw.form.get('format', 'rng').lower()
 
     def set_request_content_type(self):
         entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)