From f60d22247606b536227f9dc9a3d58d2a2919665d Mon Sep 17 00:00:00 2001 From: mahesh Date: Thu, 21 Apr 2016 17:23:38 +0530 Subject: added login_required decorator --- commentingapp/views.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'commentingapp/views.py') diff --git a/commentingapp/views.py b/commentingapp/views.py index f2a0f36..a97fc07 100644 --- a/commentingapp/views.py +++ b/commentingapp/views.py @@ -2,17 +2,13 @@ from django.shortcuts import render, render_to_response from django.contrib.auth.decorators import login_required from django.template import RequestContext from .models import Url, Comments -from django.contrib.auth.decorators import user_passes_test from django.db.models import Q -from django.contrib.auth.models import User from collections import Counter -import os.path -from email.mime.text import MIMEText from django.http import Http404 from tbc.models import Book, Chapters from tbc.views import is_reviewer -@user_passes_test(lambda u:u.is_superuser, login_url="/admin/login/") +@login_required(login_url="/login/") def commenting(request): ci = RequestContext(request) -- cgit From 1d6eede612130ae0bb6ea4fa03f60fc71ecbbe3d Mon Sep 17 00:00:00 2001 From: mahesh Date: Thu, 21 Apr 2016 18:34:46 +0530 Subject: changes in context --- commentingapp/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'commentingapp/views.py') diff --git a/commentingapp/views.py b/commentingapp/views.py index a97fc07..22bf0e0 100644 --- a/commentingapp/views.py +++ b/commentingapp/views.py @@ -17,7 +17,7 @@ def commenting(request): raise Http404("You are not allowed to view this page") else: url_instance = Url.objects.filter(Q(comments__is_notified = 0)).distinct() - context = {"url_context": url_instance, "user": curr_user} + context = {"url_context": url_instance, "reviewer": curr_user} if request.method == "POST": notified_comment_list = request.POST.getlist("comment") -- cgit From a1018449fb6e6d584a8b86f07c6642ce852c4a19 Mon Sep 17 00:00:00 2001 From: mahesh Date: Tue, 26 Apr 2016 15:30:21 +0530 Subject: removed request context --- commentingapp/views.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'commentingapp/views.py') diff --git a/commentingapp/views.py b/commentingapp/views.py index 22bf0e0..66606b7 100644 --- a/commentingapp/views.py +++ b/commentingapp/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render, render_to_response from django.contrib.auth.decorators import login_required -from django.template import RequestContext +from django.core.context_processors import csrf from .models import Url, Comments from django.db.models import Q from collections import Counter @@ -8,16 +8,19 @@ from django.http import Http404 from tbc.models import Book, Chapters from tbc.views import is_reviewer + @login_required(login_url="/login/") def commenting(request): - ci = RequestContext(request) + context = {} + context.update(csrf(request)) curr_user = request.user if not is_reviewer(curr_user): raise Http404("You are not allowed to view this page") else: url_instance = Url.objects.filter(Q(comments__is_notified = 0)).distinct() - context = {"url_context": url_instance, "reviewer": curr_user} + context["url_context"] = url_instance + context["reviewer"] = curr_user if request.method == "POST": notified_comment_list = request.POST.getlist("comment") @@ -33,10 +36,10 @@ def commenting(request): status = url_db_instance.send_mail_to_contributor(contributor_details) if status == True: - context = {"notified_comments": "You have suceesfully notified the contributors"} + context["notified_comments"] = "You have suceesfully notified the contributors" else: - context = {"notified_comments": "Mail couldnot be sent"} - return render_to_response("notified.html", context, ci) + context["notified_comments"] = "Mail could not be sent" + return render_to_response("notified.html", context) - return render_to_response ("commenting.html", context, ci) + return render_to_response ("commenting.html", context) -- cgit