From aa5e85a81529245b22ad6afed170abe6879a1d7c Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 25 Sep 2013 18:10:11 +0200 Subject: [PATCH] use a Page context to handle dependecies, rather than messgin with the html template --- portal/registrationview.py | 33 ++++++++++++++++--------- portal/templates/registration_view.html | 10 +------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/portal/registrationview.py b/portal/registrationview.py index 9d6c569f..c7317468 100644 --- a/portal/registrationview.py +++ b/portal/registrationview.py @@ -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) diff --git a/portal/templates/registration_view.html b/portal/templates/registration_view.html index 18759f4e..ef524bb1 100644 --- a/portal/templates/registration_view.html +++ b/portal/templates/registration_view.html @@ -1,13 +1,5 @@ {% extends "layout-unfold1.html" %} -{% block head %} - - - - - -{% endblock %} - {% block unfold1_main %}
@@ -92,7 +84,7 @@