use a Page context to handle dependecies, rather than messgin with the html template
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 25 Sep 2013 16:10:11 +0000 (18:10 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 25 Sep 2013 16:10:11 +0000 (18:10 +0200)
portal/registrationview.py
portal/templates/registration_view.html

index 9d6c569..c731746 100644 (file)
@@ -6,6 +6,7 @@ from django.views.generic       import View
 from django.template.loader     import render_to_string
 from django.shortcuts           import render
 
+from unfold.page                import Page
 from myslice.viewutils          import topmenu_items
 
 from manifold.manifoldapi       import execute_query
@@ -33,6 +34,14 @@ class RegistrationView (View):
             select('name', 'authority_hrn')
         #authorities_query = Query.get('authority').select('authority_hrn')
         authorities = execute_query(request, authorities_query)
+        # xxx tocheck - if authorities is empty, it's no use anyway
+        # (users won't be able to validate the form anyway)
+
+        page = Page(request)
+        page.add_js_files  ( [ "js/jquery.validate.js", "js/my_account.register.js" ] )
+        page.add_css_files ( [ "css/onelab.css", "css/registration.css" ] )
+
+        print 'registration view, method',request.method
 
         if request.method == 'POST':
             # We shall use a form here
@@ -114,14 +123,16 @@ class RegistrationView (View):
 
             return render(request, 'user_register_complete.html')
 
-        return render(request, 'registration_view.html',{
-            'topmenu_items': topmenu_items('Register', request),
-            'errors': errors,
-            'firstname': request.POST.get('firstname', ''),
-            'lastname': request.POST.get('lastname', ''),
-            #'affiliation': request.POST.get('affiliation', ''),
-            'authority_hrn': request.POST.get('authority_hrn', ''),
-            'email': request.POST.get('email', ''),
-            'password': request.POST.get('password', ''),           
-            'authorities': authorities,
-            })
+        template_env = {
+          'topmenu_items': topmenu_items('Register', request),
+          'errors': errors,
+          'firstname': request.POST.get('firstname', ''),
+          'lastname': request.POST.get('lastname', ''),
+          #'affiliation': request.POST.get('affiliation', ''),
+          'authority_hrn': request.POST.get('authority_hrn', ''),
+          'email': request.POST.get('email', ''),
+          'password': request.POST.get('password', ''),           
+          'authorities': authorities,
+          }
+        template_env.update(page.prelude_env ())
+        return render(request, 'registration_view.html',template_env)
index 18759f4..ef524bb 100644 (file)
@@ -1,13 +1,5 @@
 {% extends "layout-unfold1.html" %}
 
-{% block head %}
-<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/onelab.css" />
-<!-- xxx ideally only onelab.css but ... xxx -->
-<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/registration.css" />
-<script type="text/javascript" src="{{STATIC_URL}}/js/jquery.validate.js"></script> 
-<script type="text/javascript" src="{{STATIC_URL}}/js/my_account.register.js"></script>
-{% endblock %}                              
-                                    
 {% block unfold1_main %}        
 
 <div class="onelab-title well well-lg">
@@ -92,7 +84,7 @@
     <div class="form-group" style="display:none;" id="upload_key">
       <label for="file" class="col-md-4 control-label">Upload public key</label>
       <div class="col-md-4">
-       <input type="file" name="user_public_key" class="form-control" id="user_public_key" required/>
+       <input type="file" name="user_public_key" class="form-control" id="user_public_key" />
        <p class="warning" id="pkey_del_msg">Once your account is validated, you will have to delegate your credentials manually using SFA [Advanced users only]</p>
       </div>
       <div class="col-md-4"><p class="form-hint">Account Delegation: Manual (Advanced Users)</p></div>