summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrimal Pappachan2012-04-02 12:41:14 +0530
committerPrimal Pappachan2012-04-02 12:41:14 +0530
commit9c407a7670d205617004a8246a6775d036fd1144 (patch)
treed22fecf72640b06182f5f4e05784eb226a76462c
parent765ab4d193a9fbfdbddc5be0a1721ebedb924070 (diff)
downloadaloha-9c407a7670d205617004a8246a6775d036fd1144.tar.gz
aloha-9c407a7670d205617004a8246a6775d036fd1144.tar.bz2
aloha-9c407a7670d205617004a8246a6775d036fd1144.zip
removed the registration number from the urls
-rw-r--r--aloha/allotter/urls.py10
-rw-r--r--aloha/allotter/views.py26
-rw-r--r--aloha/template/allotter/apply.html2
-rw-r--r--aloha/template/allotter/complete.html4
4 files changed, 22 insertions, 20 deletions
diff --git a/aloha/allotter/urls.py b/aloha/allotter/urls.py
index bb1d16a..0d3c334 100644
--- a/aloha/allotter/urls.py
+++ b/aloha/allotter/urls.py
@@ -3,10 +3,10 @@ from django.conf.urls.defaults import patterns, url
urlpatterns = patterns('allotter.views',
url(r'^login/$', 'user_login'),
url(r'^logout/$', 'user_logout'),
- url(r'^(?P<reg_no>\d+)/apply/$', 'apply'),
- url(r'^(?P<reg_no>\d+)/details/$', 'submit_details'),
- url(r'^(?P<reg_no>\d+)/get_pdf/$', 'generate_pdf'),
- url(r'^(?P<reg_no>\d+)/submit/$', 'submit_options', name='submit_options'),
- url(r'^(?P<reg_no>\d+)/complete/$', 'complete_allotment', name='complete_allotment'),
+ url(r'^apply/$', 'apply'),
+ url(r'^details/$', 'submit_details'),
+ url(r'^get_pdf/$', 'generate_pdf'),
+ url(r'^submit/$', 'submit_options', name='submit_options'),
+ url(r'^complete/$', 'complete_allotment', name='complete_allotment'),
url(r'^$', 'user_login'),
)
diff --git a/aloha/allotter/views.py b/aloha/allotter/views.py
index ab4232a..aa72205 100644
--- a/aloha/allotter/views.py
+++ b/aloha/allotter/views.py
@@ -33,9 +33,9 @@ def user_login(request):
if user.is_authenticated():
status = user.get_profile().application.submitted #Getting the submission status
if status: #If already submitted, takes to Completion Page
- return HttpResponseRedirect(reverse('allotter.views.complete_allotment', args=(user.username,)))
+ return redirect('/allotter/complete/')
else: #Otherwise to Option Choosing Page
- return HttpResponseRedirect(reverse('allotter.views.apply', args=(user.username,)))
+ return redirect('/allotter/apply/')
if request.method == "POST":
form = UserLoginForm(request.POST)
@@ -44,9 +44,9 @@ def user_login(request):
login(request, user)
status = user.get_profile().application.submitted #Getting the submission status
if status:
- return HttpResponseRedirect(reverse('allotter.views.complete_allotment', args=(user.username,)))
+ return redirect('/allotter/complete/') #Redirect to Completion Page
else:
- return HttpResponseRedirect(reverse('allotter.views.submit_details', args=(user.username,)))
+ return redirect('/allotter/details/') #Redirect to user details submission
else:
context = {"form": form}
return render(request, 'allotter/login.html', context)
@@ -57,7 +57,7 @@ def user_login(request):
@login_required
-def submit_details(request, reg_no):
+def submit_details(request):
"""
Get the secondary email address, phone number and save it to the Profile.
"""
@@ -71,7 +71,7 @@ def submit_details(request, reg_no):
if form.is_valid():
data = form.cleaned_data
form.save()
- return HttpResponseRedirect(reverse('allotter.views.apply', args=(user.username,)))
+ return redirect('/allotter/apply/') #Details submitted, taken to application page
else:
return render(request, 'allotter/details.html', {'form':form})
@@ -113,7 +113,7 @@ def get_details(user, error_message = ""):
return context
@login_required
-def apply(request, reg_no):
+def apply(request):
"""
Displays the application page for an authenticated user.
"""
@@ -140,12 +140,13 @@ def rem_dup(seq):
#TODO: Extensive Testing
@login_required
-def submit_options(request, reg_no):
+def submit_options(request):
"""
Gets the Options and their preference number through the POST object and
stores them as list(sorted according to preferences). Options with None are
ignored.
"""
+ reg_no = request.user.username
user = get_object_or_404(User, username=reg_no)
user_profile = user.get_profile()
user_application = user_profile.application
@@ -176,13 +177,14 @@ def submit_options(request, reg_no):
user_application.options_selected = options_code_list #Saving the data in model
user_application.submitted = True #Submission Status
user_application.save()
- return HttpResponseRedirect(reverse('allotter.views.complete_allotment', args=(reg_no,)))
+ return redirect('/allotter/complete/')
-def complete_allotment(request, reg_no):
+def complete_allotment(request):
"""
Passes the chosen options queryset to the Completion Page Template
"""
+ reg_no = request.user.username
user = get_object_or_404(User, username=reg_no)
sec_email = user.get_profile().secondary_email
options_chosen = get_chosen_options(user)
@@ -219,11 +221,11 @@ def get_chosen_options(user):
@login_required
-def generate_pdf(request, reg_no):
+def generate_pdf(request):
"""
The Ugly code for generating the pdf using ReportLab.
"""
-
+ reg_no = request.user.username
user = get_object_or_404(User, username=reg_no)
user_profile = user.get_profile()
user_application = user_profile.application
diff --git a/aloha/template/allotter/apply.html b/aloha/template/allotter/apply.html
index fc9b930..9189828 100644
--- a/aloha/template/allotter/apply.html
+++ b/aloha/template/allotter/apply.html
@@ -100,7 +100,7 @@ Listing the options for first test paper.
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
-<form action="/allotter/{{user.username}}/submit/" method="post">
+<form action="/allotter/submit/" method="post">
{% csrf_token %}
<table class="table table-bordered table-striped">
diff --git a/aloha/template/allotter/complete.html b/aloha/template/allotter/complete.html
index 34939f4..1b87da7 100644
--- a/aloha/template/allotter/complete.html
+++ b/aloha/template/allotter/complete.html
@@ -59,7 +59,7 @@ options otherwise click <b>Quit Allotment</b> to exit the allotment process </h3
<br/>
<p>You may edit your options by clicking <b>Edit Options</b>. <i>Please keep in mind that your previous options
will be deleted.</i></p>
-<form id="apply" action="/allotter/{{username}}/apply/" method="post">
+<form id="apply" action="/allotter/apply/" method="post">
{% csrf_token %}
<input type="submit" name="apply" value="Edit Options" class="btn" />
</form>
@@ -72,7 +72,7 @@ will be deleted.</i></p>
<p>Click on the button <b>Generate Allotment PDF</b> to generate a Portable Document
Format(PDF) of your options. Take a print out of this PDF and send it with
your completed application form to the Organizing chairman </p>
-<form id ="get_pdf" action="/allotter/{{username}}/get_pdf/" method="post">
+<form id ="get_pdf" action="/allotter/get_pdf/" method="post">
{% csrf_token %}
<input type="submit" name="get_pdf" value="Generate Allotment PDF" class="btn" />
</form>