diff options
-rw-r--r-- | allotter/forms.py | 12 | ||||
-rw-r--r-- | allotter/models.py | 8 | ||||
-rw-r--r-- | allotter/urls.py | 2 | ||||
-rw-r--r-- | allotter/views.py | 24 | ||||
-rw-r--r-- | template/allotter/apply.html | 81 | ||||
-rw-r--r-- | template/allotter/complete.html | 14 |
6 files changed, 103 insertions, 38 deletions
diff --git a/allotter/forms.py b/allotter/forms.py index 8d4d021..980d3f7 100644 --- a/allotter/forms.py +++ b/allotter/forms.py @@ -23,11 +23,16 @@ class UserLoginForm(forms.Form): password = forms.CharField(label = "Application Number", max_length=10, help_text="As on your Examination ID Card") - dob = forms.DateField(label="Date of Birth", widget=SelectDateWidget(years=BIRTH_YEAR_CHOICES)) + dob = forms.DateField(label="Date of Birth", + widget=SelectDateWidget(years=BIRTH_YEAR_CHOICES), + initial=datetime.date.today) def clean_username(self): u_name = self.cleaned_data["username"] + if not u_name: + raise forms.ValidationError("Enter an username.") + ##Verifies whether username contains only digits and is not ##longer than 7, i.e Username == Registration Number. if str(u_name).strip(digits) or len(str(u_name)) != 7: @@ -43,6 +48,7 @@ class UserLoginForm(forms.Form): raise forms.ValidationError("Entered Registration Number haven't appeared for JAM Exam.") def clean_password(self): + pwd = self.cleaned_data['password'] ##Verifying the length of application number and whether it contains @@ -64,13 +70,13 @@ class UserLoginForm(forms.Form): if profile.dob != dob: raise forms.ValidationError("Date of Birth doesn't match.") except User.DoesNotExist: - raise forms.ValidationError("Verify the details entered.") + raise forms.ValidationError("Correct the following errors and try logging in again.") ##Authentication part user = authenticate(username = u_name, password = pwd) if not user: - raise forms.ValidationError("Invalid username/password") + raise forms.ValidationError("Application Number or Registration Number doesn't match.") return user diff --git a/allotter/models.py b/allotter/models.py index 0004505..77f0849 100644 --- a/allotter/models.py +++ b/allotter/models.py @@ -1,6 +1,10 @@ from django.db import models from django.contrib.auth.models import User +#email in profile +#course - place +#phone no(2) + ##EXAMINATION_SUBJECTS = ( ## ("Physics", "Physics"), ## ("Mathematics", "Mathematics"), @@ -64,6 +68,10 @@ class Option(models.Model): opt_code = models.IntegerField(max_length=3, verbose_name=u"Programme Code") + + opt_location = models.CharField(max_length=30, + verbose_name=u"Programme Location", + help_text=u"Offered by which IIT") exam = models.ManyToManyField(Exam) diff --git a/allotter/urls.py b/allotter/urls.py index aa0d62d..611fb88 100644 --- a/allotter/urls.py +++ b/allotter/urls.py @@ -5,7 +5,7 @@ urlpatterns = patterns('allotter.views', url(r'^logout/$', 'user_logout'), url(r'^apply/$', 'apply'), url(r'^(?P<reg_no>\w+)/submit/$', 'submit'), #change into numbers - url(r'^(?P<reg_no>\d+)/complete/$', 'complete'), #change into numbers + url(r'^(?P<reg_no>\w+)/complete/$', 'complete'), #change into numbers url(r'^$', 'apply'), #url(r'^quit/$', 'quit'), ) diff --git a/allotter/views.py b/allotter/views.py index 743c373..c9a5990 100644 --- a/allotter/views.py +++ b/allotter/views.py @@ -72,12 +72,14 @@ def get_details(user, error_message = ""): 'options_available_first' : options_available_first, 'second_paper': second_paper, 'options_available_second' : options_available_second, - 'np' : np,'oafl': oafl, 'oasl': oasl, + 'np' : np, 'oafl_range': range(1, oafl + 1, 1), + 'oasl_range': range(oafl, oafl + oasl, 1), 'error_message': error_message} else: #If written only one exam context = {'user': user, 'first_paper': first_paper, 'options_available_first' : options_available_first, - 'oafl': oafl, 'np' : np, 'error_message' : error_message} + 'oafl_range': range(1, oafl + 1, 1), + 'np' : np, 'error_message' : error_message} return context @login_required @@ -110,7 +112,7 @@ def submit(request, reg_no): for option in options_available_first: #TODO: Dealing with none option, Dealing with all nones - selected_option = Option.objects.get(pk=request.POST[option.opt_name]) + option_pref = request.POST[option.opt_name] #except (KeyError, Option.DoesNotExist): # Redisplay the application form with error message. # error_message = "You didn't select a choice." @@ -119,8 +121,8 @@ def submit(request, reg_no): # context_instance=RequestContext(request)) #else: - options_list += selected_option.opt_name - + options_list += option_pref + "-" + str(option.opt_code) + "," + user_application.options_selected += options_list user_application.save() return HttpResponseRedirect(reverse('allotter.views.complete', args=(reg_no,))) @@ -129,10 +131,16 @@ def submit(request, reg_no): #User Application def complete(request, reg_no): - - context = {'user': reg_no} + user = get_object_or_404(User, username=reg_no) + email = user.email + user_profile = user.get_profile() + user_application = user_profile.application + first_paper = user_application.first_paper #First Paper Name + options_available_first = Option.objects.filter(exam__exam_name=first_paper).distinct() #Options for First paper + context = {'user': reg_no, 'email': email, 'first_paper': first_paper, + 'options_available_first': options_available_first} ci = RequestContext(request) - return render_to_response('allotter/complete.html', context) + return render_to_response('allotter/complete.html', context, context_instance=ci) """def quit(request): pass diff --git a/template/allotter/apply.html b/template/allotter/apply.html index e1c728d..a336306 100644 --- a/template/allotter/apply.html +++ b/template/allotter/apply.html @@ -2,18 +2,18 @@ {% load range_filter %} -{% block title %}Application form {% endblock %} +{% block title %} Application form {% endblock %} {% block content %} -<h2>Thank you for providing the details. You have been authenticated.</h2> +<p> Welcome to JAM 2012 allotment! </p> -<p> Welcome <strong>{{user.first_name.title}} {{user.last_name.title}}</strong>, -to JAM 2012 allotment! </p> +<p>Read the following instructions carefully before continuing. </p> +<hr/> Choose the options as per your preference -<h3>You are in the merit list for {{first_paper}} +<h3>You are eligible for {{first_paper}} {% comment %} Checking if there is second paper and displaying its name. @@ -30,46 +30,77 @@ and {{second_paper}} <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> -<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> +<p> Preferences will be assigned to options 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> +<hr/> {% comment %} +</h3> Listing the options for first test paper. {% endcomment %} +<h3>Options available for {{first_paper}}</h3> + {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %} <form action="/allotter/{{user.username}}/submit/" method="post"> {% csrf_token %} -{% for option in options_available_first %} - <p>{{ option.opt_name }}</p> - {% for i in oafl|get_range %} - <input name="{{option.opt_name}}" type="radio" value="{{option.id}}" /><br/> +<table> +<tr> +<td><p>Programme Code </p></td> +<td><p>Programme Name </p></td> +<td><p>Insitute </p></td> +<td><p>Preference </p></td> +</tr> + +{% for option in options_available_first %} + <tr> + <td><p> {{ option.opt_code }} </p></td> + <td><p> {{option.opt_name }} </p></td> + <td><p> {{option.opt_location }} </p></td> + <td><select name="{{option.opt_name}}"> + {% for i in oafl_range %} + <option value="{{i}}" selected="selected">Preference {{i}}</option> {% endfor %} - <input name="{{option.opt_name}}" type="radio" value="None" />None<br/> + <option value="{{option.opt_code}}">None</option> + </select> + </td> + </tr> {% endfor %} - -{% comment %} -Listing the options for second test paper if it exists. -{% endcomment %} - +</table> {% 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}}"/><br/> +<h3>Options available for {{second_paper}} </h3> + +<table> +<tr> +<td><p>Programme Code </p></td> +<td><p>Programme Name </p></td> +<td><p>Insitute </p></td> +<td><p>Preference </p></td> +</tr> + +{% for option in options_available_second %} + <tr> + <td><p> {{option.opt_code }} </p></td> + <td><p> {{option.opt_name }} </p></td> + <td><p> {{option.opt_location }} </p></td> + <td><select name="{{option.opt_name}}"> + {% for i in oasl_range %} + <option value="{{i}}" selected="selected">Preference {{i}}</option> {% endfor %} - <input name="option" type="radio" value="None" />None<br/> -{% endfor %} + <option value="{{option.opt_code}}">None</option> + </select> + </td> + </tr> +{% endfor %} +</table> {% endif %} - <input type="submit" name="save" value="Save" /> </form> diff --git a/template/allotter/complete.html b/template/allotter/complete.html index 1759c30..e235772 100644 --- a/template/allotter/complete.html +++ b/template/allotter/complete.html @@ -5,7 +5,19 @@ {% block content %} -<h2> Thank you, your options have been saved to the database </h2> +<h2> Thank you, your following options have been saved to the database </h2> + +{{first_paper}} + +{% for option in options_available_first %} + <p>{{ option.opt_name }}</p> +{% endfor %} + +{% if email %} + +An email with all the options has been to the following email address: {{email}} + +{% endif %} {% endblock content %} |