Skip to content

Commit 141ebf0

Browse files
committed
Merge pull request #1574 from rtfd/fix-18-template-context
Just straight dicts, not Context’s for django Templates
2 parents cb542aa + 3249414 commit 141ebf0

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

readthedocs/core/management/commands/archive.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from glob import glob
22
import os
33
import logging
4-
from optparse import make_option
54

65
from django.conf import settings
76
from django.core.management.base import BaseCommand
8-
from django.template import Context, loader as template_loader
7+
from django.template import loader as template_loader
98

109
log = logging.getLogger(__name__)
1110

@@ -26,9 +25,9 @@ def handle(self, *args, **options):
2625
v = version.replace(path + '/', '')
2726
doc_index[directory].append(v)
2827

29-
context = Context({
28+
context = {
3029
'doc_index': doc_index,
3130
'MEDIA_URL': settings.MEDIA_URL,
32-
})
31+
}
3332
html = template_loader.get_template('archive/index.html').render(context)
3433
print html

readthedocs/core/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from django.conf import settings
88
from django.core.mail import EmailMultiAlternatives
99
from django.template.loader import get_template
10-
from django.template import Context
1110

1211
from readthedocs.builds.constants import LATEST
1312
from readthedocs.builds.constants import LATEST_VERBOSE_NAME
@@ -112,7 +111,8 @@ def send_email(recipient, subject, template, template_html, context=None,
112111
scheme = 'https' if request.is_secure() else 'http'
113112
context['uri'] = '{scheme}://{host}'.format(scheme=scheme,
114113
host=request.get_host())
115-
ctx = Context(context)
114+
ctx = {}
115+
ctx.update(context)
116116
msg = EmailMultiAlternatives(
117117
subject,
118118
get_template(template).render(ctx),

readthedocs/doc_builder/backends/mkdocs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ def append_conf(self, **kwargs):
109109
'commit': self.version.project.vcs_repo(self.version.slug).commit,
110110
}
111111
data_json = json.dumps(readthedocs_data, indent=4)
112-
data_ctx = Context({
112+
data_ctx = {
113113
'data_json': data_json,
114114
'current_version': readthedocs_data['version'],
115115
'slug': readthedocs_data['project'],
116116
'html_theme': readthedocs_data['theme'],
117117
'pagename': None,
118-
})
118+
}
119119
data_string = template_loader.get_template(
120120
'doc_builder/data.js.tmpl'
121121
).render(data_ctx)
@@ -125,10 +125,10 @@ def append_conf(self, **kwargs):
125125
data_file.write('\nREADTHEDOCS_DATA["page"] = mkdocs_page_name')
126126
data_file.close()
127127

128-
include_ctx = Context({
128+
include_ctx = {
129129
'global_analytics_code': getattr(settings, 'GLOBAL_ANALYTICS_CODE', 'UA-17997319-1'),
130130
'user_analytics_code': self.version.project.analytics_code,
131-
})
131+
}
132132
include_string = template_loader.get_template(
133133
'doc_builder/include.js.tmpl'
134134
).render(include_ctx)

readthedocs/doc_builder/backends/sphinx.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
import zipfile
88

9-
from django.template import Context, loader as template_loader
9+
from django.template import loader as template_loader
1010
from django.template.loader import render_to_string
1111
from django.conf import settings
1212

@@ -88,7 +88,7 @@ def append_conf(self, **kwargs):
8888
bitbucket_version_is_editable = (self.version.type == 'branch')
8989
display_bitbucket = bitbucket_user is not None
9090

91-
rtd_ctx = Context({
91+
rtd_ctx = {
9292
'current_version': self.version.verbose_name,
9393
'project': project,
9494
'settings': settings,
@@ -109,7 +109,7 @@ def append_conf(self, **kwargs):
109109
'bitbucket_version_is_editable': bitbucket_version_is_editable,
110110
'display_bitbucket': display_bitbucket,
111111
'commit': self.project.vcs_repo(self.version.slug).commit,
112-
})
112+
}
113113

114114
# Avoid hitting database and API if using Docker build environment
115115
if getattr(settings, 'DONT_HIT_API', False):

readthedocs/restapi/views/footer_views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.shortcuts import get_object_or_404
2-
from django.template import Context, loader as template_loader
2+
from django.template import loader as template_loader
33
from django.conf import settings
44
from django.core.context_processors import csrf
55

@@ -101,7 +101,7 @@ def footer_html(request):
101101

102102
version_compare_data = get_version_compare_data(project, version)
103103

104-
context = Context({
104+
context = {
105105
'project': project,
106106
'path': path,
107107
'downloads': version.get_downloads(pretty=True),
@@ -118,7 +118,7 @@ def footer_html(request):
118118
'github_edit_url': version.get_github_url(docroot, page_slug, source_suffix, 'edit'),
119119
'github_view_url': version.get_github_url(docroot, page_slug, source_suffix, 'view'),
120120
'bitbucket_url': version.get_bitbucket_url(docroot, page_slug, source_suffix),
121-
})
121+
}
122122

123123
context.update(csrf(request))
124124
html = template_loader.get_template('restapi/footer.html').render(context)

0 commit comments

Comments
 (0)