diff options
-rw-r--r-- | commentingapp/views.py | 17 | ||||
-rw-r--r-- | tbc_error_page/views.py | 24 |
2 files changed, 24 insertions, 17 deletions
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) diff --git a/tbc_error_page/views.py b/tbc_error_page/views.py index 6dd5206..d788afa 100644 --- a/tbc_error_page/views.py +++ b/tbc_error_page/views.py @@ -1,14 +1,15 @@ from django.shortcuts import render_to_response from .models import Error, Broken, get_json_from_file from django.contrib.auth.decorators import login_required -from django.template import RequestContext +from django.core.context_processors import csrf from django.http import Http404 from tbc.views import is_reviewer @login_required(login_url="/login/") def error(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") @@ -28,17 +29,19 @@ def error(request): deliberate_urls_list = request.POST.getlist("deliberate") db_instance.update_deliberate_error(deliberate_urls_list) - context = {"reviewer":request.user, "deliberate" :deliberate_urls_list} + context["reviewer"] = request.user + context["deliberate"] = deliberate_urls_list - return render_to_response ("deliberate.html", context, ci) + return render_to_response ("deliberate.html", context) - - context = {"context": error_details, "reviewer": curr_user} - return render_to_response ("error.html", context, ci) + context["context"] = error_details + context[ "reviewer"] = curr_user + return render_to_response ("error.html", context) @login_required(login_url="/login/") def broken(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") @@ -54,7 +57,8 @@ def broken(request): db_instance.update_broken_data(broken_json_data) broken = Broken.objects.all() - context = {"broken": broken, "reviewer": curr_user} - return render_to_response("broken.html", context, ci) + context["broken"] = broken + context[ "reviewer"] = curr_user + return render_to_response("broken.html", context) |