From patchwork Thu Mar 24 17:52:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 601747 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qWDZ83cd2z9sD2 for ; Fri, 25 Mar 2016 04:53:36 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3qWDZ82qthzDqG1 for ; Fri, 25 Mar 2016 04:53:36 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lists.ozlabs.org (Postfix) with ESMTP id 3qWDYg2Mw1zDqCj for ; Fri, 25 Mar 2016 04:53:11 +1100 (AEDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP; 24 Mar 2016 10:53:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,386,1455004800"; d="scan'208";a="931077472" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 24 Mar 2016 10:53:09 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u2OHr93g015874; Thu, 24 Mar 2016 17:53:09 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id u2OHr8Ps018957; Thu, 24 Mar 2016 17:53:09 GMT Received: (from sfinucan@localhost) by sivswdev01.ir.intel.com with id u2OHr8BC018952; Thu, 24 Mar 2016 17:53:08 GMT From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 05/15] views: Use context dictionaries in 'pwclient' Date: Thu, 24 Mar 2016 17:52:50 +0000 Message-Id: <1458841980-17014-6-git-send-email-stephen.finucane@intel.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1458841980-17014-1-git-send-email-stephen.finucane@intel.com> References: <1458841980-17014-1-git-send-email-stephen.finucane@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Remove the use of PatchworkRequestContext in this view as it is not required and causes a 'RemovedInDjango110Warning' warning. This requires the use of 'render', rather than a combo of 'response.write' and 'render_to_string'. Signed-off-by: Stephen Finucane --- patchwork/views/pwclient.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/patchwork/views/pwclient.py b/patchwork/views/pwclient.py index b3e0052..6fa1c17 100644 --- a/patchwork/views/pwclient.py +++ b/patchwork/views/pwclient.py @@ -20,31 +20,32 @@ from __future__ import absolute_import from django.conf import settings -from django.http import HttpResponse -from django.shortcuts import get_object_or_404 -from django.template.loader import render_to_string +from django.shortcuts import get_object_or_404, render from patchwork.models import Project -from patchwork.requestcontext import PatchworkRequestContext def pwclientrc(request, project_id): project = get_object_or_404(Project, linkname=project_id) - context = PatchworkRequestContext(request) - context.project = project + + context = { + 'project': project, + } if settings.FORCE_HTTPS_LINKS or request.is_secure(): context['scheme'] = 'https' else: context['scheme'] = 'http' - response = HttpResponse(content_type="text/plain") + + response = render(request, 'patchwork/pwclientrc', context, + content_type='text/plain') response['Content-Disposition'] = 'attachment; filename=.pwclientrc' - response.write(render_to_string('patchwork/pwclientrc', context)) + return response def pwclient(request): - context = PatchworkRequestContext(request) - response = HttpResponse(content_type="text/x-python") + response = render(request, 'patchwork/pwclientrc', + content_type='text/x-python') response['Content-Disposition'] = 'attachment; filename=pwclient' - response.write(render_to_string('patchwork/pwclient', context)) + return response