summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparth2012-03-29 14:26:08 +0530
committerparth2012-03-29 14:26:08 +0530
commitea68a068f51a8fa8bde4888d3361561b8b108b3d (patch)
tree9668efdced396d3234564511e870486240de0d77
parentbf70aecd2826537a27bfca56362eb8899808b384 (diff)
downloadaloha-ea68a068f51a8fa8bde4888d3361561b8b108b3d.tar.gz
aloha-ea68a068f51a8fa8bde4888d3361561b8b108b3d.tar.bz2
aloha-ea68a068f51a8fa8bde4888d3361561b8b108b3d.zip
now only one option can be selected among common options
-rw-r--r--aloha/allotter/views.py4
-rw-r--r--aloha/template/allotter/apply.html9
2 files changed, 9 insertions, 4 deletions
diff --git a/aloha/allotter/views.py b/aloha/allotter/views.py
index 93a1660..9c47e94 100644
--- a/aloha/allotter/views.py
+++ b/aloha/allotter/views.py
@@ -146,17 +146,19 @@ def submit_options(request, reg_no):
options_available_list = options_available_first
options_chosen_list = [] #Initializing empty list for storing options
+
for option in options_available_list:
option_pref = request.POST[unicode(option.opt_code)]
options_chosen_list.append([option_pref, str(option.opt_code)]) #[preference, option code]
+
options_chosen_list.sort() #Sorting by preference
options_code_list = []
for opt in options_chosen_list:
if int(opt[0]): #ignoring the options for which None was marked
options_code_list.append(opt[1])
- user_application.options_selected = options_code_list #Saving the data in model
+ user_application.options_selected = list(set(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,)))
diff --git a/aloha/template/allotter/apply.html b/aloha/template/allotter/apply.html
index 59f4874..4e09716 100644
--- a/aloha/template/allotter/apply.html
+++ b/aloha/template/allotter/apply.html
@@ -18,11 +18,14 @@ $(document).ready(function(){
$("select").change(function () {
console.log("here we go")
var $this = $(this);
+ var thisClass = $this.attr("class");
var prevVal = $this.data("prev");
var otherSelects = $("select").not(this);
+ var otherSameSelects = $("select[class=" + thisClass + "]").not(this);
+ console.log(otherSameSelects)
if ($(this).val() !="0"){
- console.log("some shit would happen")
otherSelects.find("option[value=" + $(this).val() + "]").attr('disabled', true);
+ otherSameSelects.find("option[value=" + $(this).val() + "]").attr('selected', 'selected');
}
if (prevVal) {
otherSelects.find("option[value=" + prevVal + "]").attr('disabled', false);
@@ -102,7 +105,7 @@ Listing the options for first test paper.
<td><p> {{ option.opt_code }} </p></td>
<td><p> {{option.opt_name }} </p></td>
<td><p> {{option.opt_location }} </p></td>
- <td><select id="{{option.opt_code}}" name="{{option.opt_code}}">
+ <td><select class="{{option.opt_code}}" name="{{option.opt_code}}">
{% for i in options_range %}
<option value="{{i}}" selected="selected">Preference {{i}}</option>
{% endfor %}
@@ -132,7 +135,7 @@ Listing the options for first test paper.
<td><p> {{option.opt_code }} </p></td>
<td><p> {{option.opt_name }} </p></td>
<td><p> {{option.opt_location }} </p></td>
- <td><select id="option.opt_code" name="{{option.opt_code}}">
+ <td><select class="{{option.opt_code}}" name="{{option.opt_code}}">
{% for i in options_range %}
<option value="{{i}}" selected="selected">Preference {{i}}</option>
{% endfor %}