[views / zipview, csvexport] Add Card to specify conditions and licence.
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Wed, 17 Jul 2013 11:56:02 +0200
changeset 282 46a66880dbce
parent 281 77fce4bb1856
child 283 2920bacd4257
[views / zipview, csvexport] Add Card to specify conditions and licence.
migration/postcreate.py
views/secondary.py
--- a/migration/postcreate.py	Wed Jul 17 11:54:05 2013 +0200
+++ b/migration/postcreate.py	Wed Jul 17 11:56:02 2013 +0200
@@ -52,3 +52,7 @@
               <pre>Any S,SCF,FGEN WHERE S is Subject, SC is Scan, SC type "t map", SC label "auditory calculation", SC concerns S, SC filepath SCF, GEN is GenomicMeasure, GEN filepath FGEN, GEN concerns S, GEN platform P, P related_snps SN, G is Gene, G name "CFB", G start_position GSA, G stop_position GSO, SN position SP HAVING SP > GSA, SP &lt; GSO</pre></li>
               </ul>
               <p> <strong>You want more !!!??? Go to the <a href="%s">schema page to see the structure of the data !</a></strong></p>'''% session.build_url('schema'))
+
+
+create_entity('Card', content_format=u'text/html', title=u'license',
+              content=u"... License text ...")
--- a/views/secondary.py	Wed Jul 17 11:54:05 2013 +0200
+++ b/views/secondary.py	Wed Jul 17 11:56:02 2013 +0200
@@ -21,6 +21,8 @@
 from cubicweb.view import EntityView
 from cubicweb.web.views.baseviews import ListView
 
+from cubes.registration.views import RegistrationFormView
+
 
 ###############################################################################
 ### LIST VIEW #################################################################
@@ -53,6 +55,27 @@
         w(u'</div>')
 
 
+###############################################################################
+### REGISTRATION VIEW #########################################################
+###############################################################################
+class BrainomicsRegistrationFormView(RegistrationFormView):
+
+    def call(self):
+        # Redefine the RegistrationView to include (if existing)
+        # the license of the data
+        super(BrainomicsRegistrationFormView, self).call()
+        card = self._cw.execute('Any X WHERE X is Card, X title %(t)s', {'t': 'license'})
+        if card:
+            msg = self._cw._(u'By signing up to this site you implicitly accept its '
+                             'terms and conditions, which are stated '
+                             'in the License agreement shown below')
+            self.w(u'<span class="badge badge-important">%s</span>' % xml_escaoe(msg))
+            self.w(u'<div>%s</div>' % card.get_entity(0, 0).content)
+
+
 def registration_callback(vreg):
-    vreg.register_all(globals().values(), __name__, (BrainomicsListView,))
+    vreg.register_all(globals().values(), __name__, (BrainomicsListView,
+                                                     BrainomicsRegistrationFormView))
     vreg.register_and_replace(BrainomicsListView, ListView)
+    vreg.register_and_replace(BrainomicsRegistrationFormView, RegistrationFormView)
+