Skip to content

Commit

Permalink
updated requirements
Browse files Browse the repository at this point in the history
refactored usage of all render_to_response calls to be compatible with Django 1.11
  • Loading branch information
kakulukia authored and tony committed Dec 18, 2017
1 parent 9e7bcb7 commit 20cc779
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 167 deletions.
18 changes: 8 additions & 10 deletions readthedocs/bookmarks/views.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
"""Views for the bookmarks app."""

from __future__ import absolute_import

import json

from django.contrib.auth.decorators import login_required
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect
from django.http import HttpResponseBadRequest
from django.shortcuts import get_object_or_404, render_to_response
from django.views.generic import ListView, View
from django.core.urlresolvers import reverse
from django.template import RequestContext
from django.shortcuts import get_object_or_404, render
from django.utils.decorators import method_decorator
from django.core.exceptions import ObjectDoesNotExist
from django.views.decorators.csrf import csrf_exempt
import json
from django.views.generic import ListView, View

from readthedocs.bookmarks.models import Bookmark
from readthedocs.projects.models import Project
Expand Down Expand Up @@ -161,10 +162,7 @@ def dispatch(self, request, *args, **kwargs):
return super(BookmarkRemoveView, self).dispatch(request, *args, **kwargs)

def get(self, request, *args, **kwargs):
return render_to_response(
'bookmarks/bookmark_delete.html',
context_instance=RequestContext(request)
)
return render(request, 'bookmarks/bookmark_delete.html')

def post(self, request, *args, **kwargs):
"""
Expand Down
6 changes: 2 additions & 4 deletions readthedocs/comments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import absolute_import
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.template import RequestContext
from django.utils.decorators import method_decorator
from rest_framework import permissions, status
Expand Down Expand Up @@ -92,9 +92,7 @@ def build(request): # pylint: disable=unused-argument
def serve_file(request, file): # pylint: disable=redefined-builtin
document = support.get_document(file)

return render_to_response('doc.html',
{'document': document},
context_instance=RequestContext(request))
return render(request, 'doc.html', {'document': document})

######
# Called by Builder
Expand Down
12 changes: 4 additions & 8 deletions readthedocs/core/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

from django.conf import settings
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.template import RequestContext
from django.shortcuts import render, get_object_or_404, redirect
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView

Expand Down Expand Up @@ -98,8 +97,7 @@ def wipe_version(request, project_slug, version_slug):
for del_dir in del_dirs:
broadcast(type='build', task=remove_dir, args=[del_dir])
return redirect('project_version_list', project_slug)
return render_to_response('wipe_version.html', {'version': version, 'project': version.project},
context_instance=RequestContext(request))
return render(request, 'wipe_version.html', {'version': version, 'project': version.project})


def divide_by_zero(request): # pylint: disable=unused-argument
Expand All @@ -108,8 +106,7 @@ def divide_by_zero(request): # pylint: disable=unused-argument

def server_error_500(request, template_name='500.html'):
"""A simple 500 handler so we get media"""
r = render_to_response(template_name,
context_instance=RequestContext(request))
r = render(request, template_name)
r.status_code = 500
return r

Expand All @@ -119,7 +116,6 @@ def server_error_404(request, exception, template_name='404.html'): # pylint: d
response = get_redirect_response(request, path=request.get_full_path())
if response:
return response
r = render_to_response(template_name,
context_instance=RequestContext(request))
r = render(request, template_name)
r.status_code = 404
return r
5 changes: 2 additions & 3 deletions readthedocs/core/views/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from __future__ import absolute_import
from django.conf import settings
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.template import RequestContext
from django.views.static import serve

Expand Down Expand Up @@ -109,8 +109,7 @@ def redirect_page_with_filename(request, project, subproject, filename): # pyli


def _serve_401(request, project):
res = render_to_response('401.html',
context_instance=RequestContext(request))
res = render(request, '401.html')
res.status_code = 401
log.error('Unauthorized access to {0} documentation'.format(project.slug))
return res
Expand Down
20 changes: 8 additions & 12 deletions readthedocs/gold/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.contrib.messages.views import SuccessMessageMixin
from django.contrib import messages
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
from django.shortcuts import render, get_object_or_404
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext_lazy as _
Expand Down Expand Up @@ -106,17 +106,13 @@ def projects(request):
else:
form = GoldProjectForm()

return render_to_response(
'gold/projects.html',
{
'form': form,
'gold_user': gold_user,
'publishable': settings.STRIPE_PUBLISHABLE,
'user': request.user,
'projects': gold_projects
},
context_instance=RequestContext(request)
)
return render(request, 'gold/projects.html', {
'form': form,
'gold_user': gold_user,
'publishable': settings.STRIPE_PUBLISHABLE,
'user': request.user,
'projects': gold_projects
})


@login_required
Expand Down
14 changes: 5 additions & 9 deletions readthedocs/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.http import Http404
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render, redirect
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.template import RequestContext

from readthedocs.core.forms import UserDeleteForm
Expand Down Expand Up @@ -103,9 +103,7 @@ def create_profile(request, form_class, success_url=None,
for key, value in list(extra_context.items()):
context[key] = (value() if callable(value) else value)

return render_to_response(template_name,
{'form': form},
context_instance=context)
return render(request, template_name, {'form': form})
create_profile = login_required(create_profile)


Expand Down Expand Up @@ -180,11 +178,11 @@ def edit_profile(request, form_class, success_url=None,
for key, value in list(extra_context.items()):
context[key] = (value() if callable(value) else value)

return render_to_response(template_name, {
return render(request, template_name, {
'form': form,
'profile': profile_obj,
'user': profile_obj.user,
}, context_instance=context)
})
edit_profile = login_required(edit_profile)


Expand Down Expand Up @@ -271,6 +269,4 @@ def profile_detail(request, username, public_profile_field=None,
for key, value in list(extra_context.items()):
context[key] = (value() if callable(value) else value)

return render_to_response(template_name,
{'profile': profile_obj},
context_instance=context)
return render(request, template_name, {'profile': profile_obj})
57 changes: 26 additions & 31 deletions readthedocs/projects/views/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,10 @@ def project_versions(request, project_slug):
project_dashboard = reverse('projects_detail', args=[project.slug])
return HttpResponseRedirect(project_dashboard)

return render_to_response(
'projects/project_versions.html',
{'form': form, 'project': project},
context_instance=RequestContext(request)
)
return render(request, 'projects/project_versions.html', {
'form': form,
'project': project,
})


@login_required
Expand Down Expand Up @@ -468,11 +467,11 @@ def project_users(request, project_slug):

users = project.users.all()

return render_to_response(
'projects/project_users.html',
{'form': form, 'project': project, 'users': users},
context_instance=RequestContext(request)
)
return render(request, 'projects/project_users.html', {
'form': form,
'project': project,
'users': users
})


@login_required
Expand Down Expand Up @@ -509,17 +508,13 @@ def project_notifications(request, project_slug):
emails = project.emailhook_notifications.all()
urls = project.webhook_notifications.all()

return render_to_response(
'projects/project_notifications.html',
{
'email_form': email_form,
'webhook_form': webhook_form,
'project': project,
'emails': emails,
'urls': urls,
},
context_instance=RequestContext(request)
)
return render(request, 'projects/project_notifications.html', {
'email_form': email_form,
'webhook_form': webhook_form,
'project': project,
'emails': emails,
'urls': urls,
})


@login_required
Expand Down Expand Up @@ -569,11 +564,11 @@ def project_translations(request, project_slug):

lang_projects = project.translations.all()

return render_to_response(
'projects/project_translations.html',
{'form': form, 'project': project, 'lang_projects': lang_projects},
context_instance=RequestContext(request)
)
return render(request, 'projects/project_translations.html', {
'form': form,
'project': project,
'lang_projects': lang_projects
})


@login_required
Expand All @@ -600,11 +595,11 @@ def project_redirects(request, project_slug):

redirects = project.redirects.all()

return render_to_response(
'projects/project_redirects.html',
{'form': form, 'project': project, 'redirects': redirects},
context_instance=RequestContext(request)
)
return render(request, 'projects/project_redirects.html', {
'form': form,
'project': project,
'redirects': redirects
})


@login_required
Expand Down
Loading

0 comments on commit 20cc779

Please sign in to comment.