summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrimal Pappachan2012-03-07 21:02:42 +0530
committerPrimal Pappachan2012-03-07 21:02:42 +0530
commite11d0e7dc7a7d9c20546e5529e8e9fe8a2047698 (patch)
treef82148ab73ea01eaaa85cea65ced92abdae5395c
parent7ee4bbddaa6836f58183a7699f1d3d829f2cc150 (diff)
downloadaloha-e11d0e7dc7a7d9c20546e5529e8e9fe8a2047698.tar.gz
aloha-e11d0e7dc7a7d9c20546e5529e8e9fe8a2047698.tar.bz2
aloha-e11d0e7dc7a7d9c20546e5529e8e9fe8a2047698.zip
Added the application form
-rw-r--r--allotter/forms.py5
-rw-r--r--allotter/models.py2
-rw-r--r--allotter/urls.py1
-rw-r--r--allotter/views.py20
4 files changed, 23 insertions, 5 deletions
diff --git a/allotter/forms.py b/allotter/forms.py
index 0623ff5..6c2ad43 100644
--- a/allotter/forms.py
+++ b/allotter/forms.py
@@ -10,6 +10,8 @@ from string import digits, letters, punctuation
from allotter.models import BIRTH_YEAR_CHOICES, GENDER_CHOICES, EXAMINATION_SUBJECTS, CATEGORIES
+from allotter.models import Option
+
PWD_CHARS = letters + punctuation + digits
class RegistrationForm(forms.Form):
@@ -88,7 +90,7 @@ class RegistrationForm(forms.Form):
new_profile.gender = cleaned_data["gender"]
new_profile.rank = cleaned_data["air"]
new_profile.category = cleaned_data["category"]
- new_profile.dob = cleaned_date["dob"]
+ new_profile.dob = cleaned_data["dob"]
new_profile.application_number = cleaned_data["app_no"]
new_profile.save()
@@ -109,3 +111,4 @@ class UserLoginForm(forms.Form):
return user
+
diff --git a/allotter/models.py b/allotter/models.py
index 44b86e0..a12f1a9 100644
--- a/allotter/models.py
+++ b/allotter/models.py
@@ -89,7 +89,7 @@ class Profile(models.Model):
pd = models.BooleanField(default=False)
def __unicode__(self):
- return self.user.application_number
+ return unicode(self.application_number)
class Application(models.Model):
"""An application for the student - one per student
diff --git a/allotter/urls.py b/allotter/urls.py
index 349c645..43579de 100644
--- a/allotter/urls.py
+++ b/allotter/urls.py
@@ -5,4 +5,5 @@ urlpatterns = patterns('allotter.views',
url(r'^login/$', 'user_login'),
url(r'^register/$', 'user_register'),
url(r'^hello/$', 'hello'),
+ url(r'^apply/$', 'apply'),
)
diff --git a/allotter/views.py b/allotter/views.py
index 037941f..bc7dac8 100644
--- a/allotter/views.py
+++ b/allotter/views.py
@@ -1,9 +1,10 @@
from django.contrib.auth import login, logout, authenticate
-from django.shortcuts import render_to_response, get_object_or_404, redirect
+from django.shortcuts import render_to_response, get_object_or_404
+from django.shortcuts import render, redirect
from django.template import RequestContext
from django.http import Http404
-from allotter.models import Profile
+from allotter.models import Profile, Option, Exam
from allotter.forms import RegistrationForm, UserLoginForm
from settings import URL_ROOT
@@ -33,7 +34,7 @@ def user_register(request):
new_user = authenticate(username = u_name, password = pwd)
login(request, new_user)
- return redirect("/allotter/login/")
+ return redirect("allotter/hello/")
else:
return render_to_response('allotter/register.html',
@@ -75,3 +76,16 @@ def hello(request):
return render_to_response('allotter/hello.html', context,
context_instance=ci)
+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_code=subject).distinct()
+ context = {'user': user, 'subject': subject,
+ 'options' : options_available}
+ ci = RequestContext(request)
+ return render_to_response('allotter/apply.html', context,
+ context_instance=ci)
+