From 9c3c51ae31a7a3a4cfb56c63db09f51f5bf0ab83 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Wed, 24 Dec 2014 13:45:55 +0530 Subject: Profile made mandatory. Proposal or code submission links will redirect to profile page, if the profile does not exist. --- tbc/templates/tbc/profile.html | 2 +- tbc/views.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'tbc') diff --git a/tbc/templates/tbc/profile.html b/tbc/templates/tbc/profile.html index 195ba3f..d7a1b56 100644 --- a/tbc/templates/tbc/profile.html +++ b/tbc/templates/tbc/profile.html @@ -4,7 +4,7 @@
× -

Congratulations on your first log in. Please update your profile.

+

Please update your profile first and then proceed.

diff --git a/tbc/views.py b/tbc/views.py index ef389aa..2c47593 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -127,6 +127,10 @@ def Home(request): return render_to_response('base.html', context) +def _checkProfile(user): + return Profile.objects.filter(user=user).exists() + + def UserLogin(request): context = {} context.update(csrf(request)) @@ -306,6 +310,9 @@ def UpdatePassword(request): def SubmitBook(request): context = {} curr_user = request.user + if not _checkProfile(curr_user): + return HttpResponseRedirect("/profile/?update=profile") + if request.method == 'POST': form = BookForm(request.POST) if form.is_valid(): @@ -333,6 +340,8 @@ def SubmitBook(request): def SubmitCodeOld(request, book_id=None): user = request.user + if not _checkProfile(user): + return HttpResponseRedirect("/profile/?update=profile") curr_profile = Profile.objects.get(user=user) context = {} dict = {} @@ -379,6 +388,8 @@ def SubmitCodeOld(request, book_id=None): def SubmitProposal(request): curr_user = request.user + if not _checkProfile(curr_user): + return HttpResponseRedirect("/profile/?update=profile") user_profile = Profile.objects.get(user=curr_user.id) context = {} context.update(csrf(request)) @@ -452,6 +463,8 @@ def SubmitProposal(request): def ListAICTE(request): curr_user = request.user + if not _checkProfile(curr_user): + return HttpResponseRedirect("/profile/?update=profile") user_profile = Profile.objects.get(user=curr_user.id) user_proposals = Proposal.objects.filter(user=user_profile) context = {} @@ -475,6 +488,8 @@ def ListAICTE(request): def SubmitAICTEProposal(request, aicte_book_id=None): curr_user = request.user + if not _checkProfile(curr_user): + return HttpResponseRedirect("/profile/?update=profile") user_profile = Profile.objects.get(user=curr_user.id) context = {} context.update(csrf(request)) @@ -653,6 +668,8 @@ def RejectProposal(request, proposal_id=None): def SubmitSample(request, proposal_id=None, old_notebook_id=None): context = {} user = request.user + if not _checkProfile(user): + return HttpResponseRedirect("/profile/?update=profile") context.update(csrf(request)) if request.method == "POST": curr_proposal = Proposal.objects.get(id=proposal_id) @@ -695,6 +712,8 @@ def SubmitSample(request, proposal_id=None, old_notebook_id=None): def ConfirmBookDetails(request): context = {} current_user = request.user + if not _checkProfile(current_user): + return HttpResponseRedirect("/profile/?update=profile") user_profile = Profile.objects.get(user=current_user) try: proposal = Proposal.objects.get(user=user_profile, status__in=["book alloted", "codes disapproved"]) @@ -738,6 +757,8 @@ def ConfirmBookDetails(request): def SubmitCode(request): user = request.user + if not _checkProfile(user): + return HttpResponseRedirect("/profile/?update=profile") curr_profile = Profile.objects.get(user=user) context = {} try: -- cgit From f30592d8e81b3c1831cda87bcb1727ce36018e00 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 7 Jan 2015 16:38:54 +0530 Subject: Remove alert message from aicte-book template --- tbc/templates/tbc/aicte-books.html | 1 - 1 file changed, 1 deletion(-) (limited to 'tbc') diff --git a/tbc/templates/tbc/aicte-books.html b/tbc/templates/tbc/aicte-books.html index 5ed4021..a15d686 100644 --- a/tbc/templates/tbc/aicte-books.html +++ b/tbc/templates/tbc/aicte-books.html @@ -5,7 +5,6 @@ -- cgit