summaryrefslogtreecommitdiff
path: root/tbc/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'tbc/views.py')
-rwxr-xr-xtbc/views.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tbc/views.py b/tbc/views.py
index cc48577..5e8912c 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -130,6 +130,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))
@@ -309,6 +313,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():
@@ -336,6 +343,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 = {}
@@ -382,6 +391,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))
@@ -455,6 +466,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 = {}
@@ -478,6 +491,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))
@@ -671,6 +686,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)
@@ -713,6 +730,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"])
@@ -756,6 +775,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: