Skip to content
Snippets Groups Projects
Commit 491dffca authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[ui][views] Moved from render_to_response to render

render_to_response is deprecated in Django 2.0 and render has
been available since 1.3. It's shorter to write and avoids the
writing of context_instance=RequestContext(request) in each of
its call.
parent 6266deb8
No related branches found
No related tags found
2 merge requests!2551.4.x,!238Upgrade to django 1.11
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.shortcuts import render_to_response from django.shortcuts import render
from django.template import RequestContext
from django.template import loader from django.template import loader
from django.template import Context from django.template import Context
from django.contrib.auth.views import login as django_login from django.contrib.auth.views import login as django_login
...@@ -63,8 +62,7 @@ logger = logging.getLogger(__name__) ...@@ -63,8 +62,7 @@ logger = logging.getLogger(__name__)
def index(request): def index(request):
'''Our main index page''' '''Our main index page'''
return render_to_response('ui/index.html', return render(request, 'ui/index.html')
context_instance=RequestContext(request))
#---------------------------------------------------------- #----------------------------------------------------------
...@@ -190,8 +188,9 @@ def blocked_user_reactivation(request): ...@@ -190,8 +188,9 @@ def blocked_user_reactivation(request):
else: else:
form = BlockedUserRevalidationForm() form = BlockedUserRevalidationForm()
return render_to_response('registration/blocked_user_reactivate.html', {'form': form}, return render(request,
context_instance=RequestContext(request)) 'registration/blocked_user_reactivate.html',
{'form': form})
#---------------------------------------------------------- #----------------------------------------------------------
...@@ -263,15 +262,14 @@ def activity_stream(request, author_name): ...@@ -263,15 +262,14 @@ def activity_stream(request, author_name):
# 2. request.user != author # 2. request.user != author
leaderboards = Leaderboard.objects.filter(search__in=Search.objects.for_user(request.user).filter(author=author)).order_by('-changed') leaderboards = Leaderboard.objects.filter(search__in=Search.objects.for_user(request.user).filter(author=author)).order_by('-changed')
return render_to_response('ui/activity_stream.html', return render(request,
dict( 'ui/activity_stream.html',
owner = (request.user == author), dict(
author= author, owner = (request.user == author),
statistics= gather_contributions(request.user, author), author= author,
leaderboards= leaderboards, statistics= gather_contributions(request.user, author),
), leaderboards= leaderboards,
context_instance=RequestContext(request), ))
)
#---------------------------------------------------------- #----------------------------------------------------------
...@@ -350,25 +348,25 @@ def user_settings(request): ...@@ -350,25 +348,25 @@ def user_settings(request):
password_change_form = PasswordChangeForm(user=user) password_change_form = PasswordChangeForm(user=user)
return render_to_response('ui/user_settings.html', return render(request,
{ 'ui/user_settings.html',
'password_change_form': password_change_form, {
'token' : user.auth_token, 'password_change_form': password_change_form,
'statistics' : { 'token' : user.auth_token,
'nb_experiments': user.experiments.count(), 'statistics' : {
'nb_public_experiments': user.experiments.filter(sharing=Shareable.PUBLIC).count(), 'nb_experiments': user.experiments.count(),
'nb_attested_experiments': user.experiments.filter(~Q(attestation=None)).count(), 'nb_public_experiments': user.experiments.filter(sharing=Shareable.PUBLIC).count(),
'nb_toolchains': user.toolchains.count(), 'nb_attested_experiments': user.experiments.filter(~Q(attestation=None)).count(),
'nb_public_toolchains': user.toolchains.filter(sharing=Shareable.PUBLIC).count(), 'nb_toolchains': user.toolchains.count(),
'nb_algorithms': user.algorithms.count(), 'nb_public_toolchains': user.toolchains.filter(sharing=Shareable.PUBLIC).count(),
'nb_public_algorithms': user.algorithms.filter(sharing=Shareable.PUBLIC).count(), 'nb_algorithms': user.algorithms.count(),
'nb_libraries': user.algorithms.count(), 'nb_public_algorithms': user.algorithms.filter(sharing=Shareable.PUBLIC).count(),
'nb_public_libraries': user.librarys.filter(sharing=Shareable.PUBLIC).count(), 'nb_libraries': user.algorithms.count(),
'nb_dataformats': user.dataformats.count(), 'nb_public_libraries': user.librarys.filter(sharing=Shareable.PUBLIC).count(),
'nb_public_dataformats': user.dataformats.filter(sharing=Shareable.PUBLIC).count(), 'nb_dataformats': user.dataformats.count(),
}, 'nb_public_dataformats': user.dataformats.filter(sharing=Shareable.PUBLIC).count(),
}, },
context_instance=RequestContext(request)) })
#---------------------------------------------------------- #----------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment