summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrimal Pappachan2012-03-29 14:37:12 +0530
committerPrimal Pappachan2012-03-29 14:37:12 +0530
commit5feb86799e923beeba51af388557ec431a351aff (patch)
tree884b868841b9114c5f01b45b1598eeff776af1ad
parentea68a068f51a8fa8bde4888d3361561b8b108b3d (diff)
downloadaloha-5feb86799e923beeba51af388557ec431a351aff.tar.gz
aloha-5feb86799e923beeba51af388557ec431a351aff.tar.bz2
aloha-5feb86799e923beeba51af388557ec431a351aff.zip
added a function to remove duplicates appearing among common options
-rw-r--r--aloha/allotter/views.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/aloha/allotter/views.py b/aloha/allotter/views.py
index 9c47e94..0d9d2ee 100644
--- a/aloha/allotter/views.py
+++ b/aloha/allotter/views.py
@@ -122,6 +122,13 @@ def user_logout(request):
##Logouts the user.
logout(request)
return redirect ('/allotter/login/')
+
+##http://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-python-whilst-preserving-##order
+def rem_dup(seq):
+ seen = set()
+ seen_add = seen.add
+ return [ x for x in seq if x not in seen and not seen_add(x)]
+
#TODO: Extensive Testing
@login_required
@@ -157,8 +164,9 @@ def submit_options(request, reg_no):
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 = list(set(options_code_list)) #Saving the data in model
+
+ print options_code_list
+ user_application.options_selected = rem_dup(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,)))