diff options
author | Primal Pappachan | 2012-03-16 19:06:37 +0530 |
---|---|---|
committer | Primal Pappachan | 2012-03-16 19:06:37 +0530 |
commit | 2c97aecefd592649e88f5ace6ed39ef98f93089d (patch) | |
tree | 4b89325262c664de8955fe3c9d88884240c684fd | |
parent | 801352eaf61a9eec25caaf02bce42ced1d396614 (diff) | |
download | aloha-2c97aecefd592649e88f5ace6ed39ef98f93089d.tar.gz aloha-2c97aecefd592649e88f5ace6ed39ef98f93089d.tar.bz2 aloha-2c97aecefd592649e88f5ace6ed39ef98f93089d.zip |
added the options listing page
-rw-r--r-- | allotter/urls.py | 1 | ||||
-rw-r--r-- | allotter/views.py | 70 | ||||
-rw-r--r-- | template/allotter/apply.html | 59 |
3 files changed, 98 insertions, 32 deletions
diff --git a/allotter/urls.py b/allotter/urls.py index e0c7c7b..6238e3c 100644 --- a/allotter/urls.py +++ b/allotter/urls.py @@ -2,6 +2,7 @@ from django.conf.urls.defaults import patterns, url urlpatterns = patterns('allotter.views', url(r'^login/$', 'user_login'), + url(r'^apply/$', 'apply'), #url(r'^apply/$', 'apply'), #url(r'^submit/$', 'submit'), #url(r'^quit/$', 'quit'), diff --git a/allotter/views.py b/allotter/views.py index a63873f..abfec2e 100644 --- a/allotter/views.py +++ b/allotter/views.py @@ -31,6 +31,52 @@ def user_login(request): context = {"form": form} return render_to_response('allotter/login.html', context, context_instance=RequestContext(request)) + + +@login_required +def apply(request): + user = request.user + if not(user.is_authenticated()): + return redirect('/allotter/login/') + user_profile = user.get_profile() + user_application = user_profile.application + np = user_application.np #Number of Papers + first_paper = user_application.first_paper + options_available_first = Option.objects.filter(exam__exam_name=first_paper).distinct() + oafl = len(options_available_first) + if np == 2: + second_paper = user_application.second_paper + options_available_second = Option.objects.filter(exam__exam_name=second_paper).distinct() + oasl = len(options_available_second) + context = {'user': user, 'first_paper': first_paper, + 'options_available_first' : options_available_first,'np' : np, + 'oafl': oafl, 'oasl': oasl, 'second_paper': second_paper, + 'options_available_second' : options_available_second} + ci = RequestContext(request) + return render_to_response('allotter/apply.html', context, + context_instance=ci) + + #form = ApplicationForm(logged_user=user) + context = {'user': user, 'first_paper': first_paper, + 'options_available_first' : options_available_first, + 'oafl': oafl, 'np' : np} + ci = RequestContext(request) + return render_to_response('allotter/apply.html', context, + context_instance=ci) + + +""" +def submit(request): + pass + +def quit(request): + pass + +def user_logout(request): + logout(request) + return redirect ('/allotter/') + +""" """def user_register(request): Register a new user. @@ -62,27 +108,3 @@ def user_login(request): """ -"""@login_required -def apply(request): - user = request.user - if not(user.is_authenticated()): - return redirect('/allotter/login/') - user_profile = user.get_profile() - subject = user_profile.exam_code - options_available = Option.objects.filter(exam__exam_name=subject).distinct() - #form = ApplicationForm(logged_user=user) - context = {'user': user, 'subject': subject, - 'options' : options_available} - ci = RequestContext(request) - return render_to_response('allotter/apply.html', context, - context_instance=ci) - -def submit(request): - pass - -def quit(request): - pass - -def user_logout(request): - logout(request) - return redirect ('/allotter/')""" diff --git a/template/allotter/apply.html b/template/allotter/apply.html index 72c96c3..ca03726 100644 --- a/template/allotter/apply.html +++ b/template/allotter/apply.html @@ -1,34 +1,77 @@ {% extends "base.html" %} +{% load range_filter %} + {% block title %}Application form {% endblock %} {% block content %} -<h2>Hello, there</h2> +<h2>Thank you for providing the details. You have been authenticated.</h2> <p> Welcome <strong>{{user.first_name.title}} {{user.last_name.title}}</strong>, to JAM 2012 allotment! </p> Choose the options as per your preference -<h3> {{user.first_name}} {{user.last_name}} {{user.user_name}}</h3> +<h3>You are in the merit list for {{first_paper}} + +{% comment %} +Checking if there is second paper and displaying its name. +{% endcomment %} + +{% if np == 2 %} + +and {{second_paper}} + +{% endif %} + +</h3> + +<h4>For the paper(s) in which you are in the merit list, the following +options are available to you. Please rank your choices.</h4> -<h3> {{subject}} </h3> +<p> Options will be given preference in the ascending order. Make sure it's +<b>None</b> for all options after your last option so that it is not considered. </p> + +<h3>Number of Options {{ oafl }} Number of subjects {{np}} </h3> + +{% comment %} +Listing the options for first test paper. +{% endcomment %} <form action="/allotter/save" method="post"> {% csrf_token %} -{% for option in options %} -<input name="option" type="radio" value="{{option}}" />{{option.opt_name}}<br/> +{% for option in options_available_first %} + <p>{{ option.opt_name }}</p> + {% for i in oafl|get_range %} + <input name="option" type="radio" value="{{i}}" />{{i}}<br/> + {% endfor %} + <input name="option" type="radio" value="None" />None<br/> {% endfor %} +{% comment %} +Listing the options for second test paper if it exists. +{% endcomment %} + +{% if np == 2 %} + +{% for option in options_available_second %} + <p>{{ option.opt_name }}</p> + {% for i in oafl|get_range %} + <input name="option" type="radio" value="{{i}}" />{{i}}<br/> + {% endfor %} + <input name="option" type="radio" value="None" />None<br/> +{% endfor %} + +{% endif %} + <input type="submit" name="save" value="Save" /> </form> -<form action="/allotter/quit/" method="post"> +<form action="/allotter/logout/" method="post"> {% csrf_token %} -<input type="submit" name="quit" value="Quit Allotment" /> +<input type="submit" name="logout" value="Quit Allotment" /> </form> -<a href="{{URL_ROOT}}/allotter/logout/">Logout</a> {% endblock content %} |