diff sat_website/views.py @ 34:9d553570cc61

add adhesion_form.html and thank_you.html
author souliane <souliane@mailoo.org>
date Tue, 27 Jan 2015 08:20:30 +0100
parents 73c6333fd124
children d2c45f4ba57e
line wrap: on
line diff
--- a/sat_website/views.py	Tue Jan 27 08:07:15 2015 +0100
+++ b/sat_website/views.py	Tue Jan 27 08:20:30 2015 +0100
@@ -24,8 +24,9 @@
 from django.shortcuts import render_to_response
 from django.core.context_processors import csrf
 from django.utils.translation import ugettext_lazy as _
+from django.template import RequestContext
 from collections import OrderedDict
-import screenshots, social_contract, utils
+import screenshots, social_contract, utils, forms
 
 CATEGORIES = OrderedDict([('frontends', (_(u"Presentation"),
                                 OrderedDict([("features", _(u"Features")),
@@ -50,19 +51,21 @@
                                 ("social_contract", _(u"Social contract")),
                                 ])
 
+CATEGORIES_HIDDEN = ('adhesion_form', 'thank_you')
+
 
 def overview(request):
     return render_to_response('sat_website/overview.html')
 
 def generic_cat(request, category):
-    context = {
+    context = RequestContext(request, {
                "available_languages": ['fr', 'en'],
                "categories": CATEGORIES,
                "categories_right": CATEGORIES_RIGHT,
                "category": category,
-              }
                "libervia_demo_url": utils.get_libervia_demo_url(),
                "subscription_amounts": utils.get_asso_subscr_amounts(),
+               })
 
     context.update(csrf(request))
 
@@ -79,12 +82,23 @@
         latest_dl_path, latest_version = utils.get_latest_sat()
         context["latest_dl_path"] = latest_dl_path
         context["latest_version"] = latest_version
+    elif category == "adhesion":
+        context.update(utils.get_asso_finance_status())
+    elif category == "adhesion_form":
+        if request.method == 'POST':
+            form = forms.RegistrationForm(request.POST)
+            if form.is_valid():
+                category = 'thank_you'
+        else:
+            form = forms.RegistrationForm(initial={'subscription_amount': 10,
+                                                   'payment_method': 'card'})
+        context['form'] = form
 
     def all_keys(cats):
         subcats = [value[1].keys() for value in cats.values() if isinstance(value, tuple)]
         return sum(subcats, cats.keys())
 
-    if category in all_keys(CATEGORIES) or category in all_keys(CATEGORIES_RIGHT):
+    if category in all_keys(CATEGORIES) or category in all_keys(CATEGORIES_RIGHT) or category in CATEGORIES_HIDDEN:
         return render_to_response('sat_website/%s.html' % (category,), context)
     else:
         raise Http404