Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Jingo upgrade rebase #1052

Merged
merged 2 commits into from

3 participants

@groovecoder
Owner

supersedes #1038 and kuma-lib #14 with rebasing.

berkerpeksag and others added some commits
@berkerpeksag berkerpeksag Update Jingo version to 0.6.1.
- Replace all jingo.render calls
- Convert all email templates to Jinja2
- Replace safe_django_forms with jingo.monkey.patch()
- Remove dead code from demos.urls
690f347
@groovecoder groovecoder update vendor submodule with jingo upgrade c8c6607
@ubernostrum

Is there something specific we're waiting on before merging this?

@groovecoder
Owner

Nope, we can merge anytime. We should wait to push until we're on official hours though. ;)

@groovecoder groovecoder merged commit 2e44513 into mozilla:master

1 check passed

Details default Jenkins build 'mdn-github' #631 has succeeded
@groovecoder groovecoder deleted the groovecoder:jingo-upgrade-rebase branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 30, 2013
  1. @berkerpeksag

    Update Jingo version to 0.6.1.

    berkerpeksag authored
    - Replace all jingo.render calls
    - Convert all email templates to Jinja2
    - Replace safe_django_forms with jingo.monkey.patch()
    - Remove dead code from demos.urls
  2. @groovecoder
This page is out of date. Refresh to see the latest.
View
12 apps/authkeys/views.py
@@ -1,11 +1,9 @@
import logging
-import jingo
-
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.core.paginator import Paginator
-from django.shortcuts import get_object_or_404
+from django.shortcuts import get_object_or_404, render
from django.http import (HttpResponseRedirect, HttpResponseForbidden)
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
@@ -33,13 +31,13 @@ def new(request):
new_key.save()
data['key'] = new_key
- return jingo.render(request, 'authkeys/new.html', data)
+ return render(request, 'authkeys/new.html', data)
@login_required
def list(request):
keys = Key.objects.filter(user=request.user)
- return jingo.render(request, 'authkeys/list.html', dict(keys=keys))
+ return render(request, 'authkeys/list.html', dict(keys=keys))
@login_required
@@ -49,7 +47,7 @@ def history(request, pk):
raise PermissionDenied
items = key.history.all().order_by('-pk')
items = paginate(request, items, per_page=ITEMS_PER_PAGE)
- return jingo.render(request, 'authkeys/history.html',
+ return render(request, 'authkeys/history.html',
dict(key=key, items=items))
@@ -61,4 +59,4 @@ def delete(request, pk):
if request.method == "POST":
key.delete()
return HttpResponseRedirect(reverse('authkeys.list'))
- return jingo.render(request, 'authkeys/delete.html', dict(key=key))
+ return render(request, 'authkeys/delete.html', dict(key=key))
View
12 apps/dashboards/views.py
@@ -7,10 +7,10 @@
from django.contrib.auth.models import User
from django.db.models import Q
from django.http import Http404, HttpResponseRedirect, HttpResponse
+from django.shortcuts import render
from django.utils.datastructures import SortedDict
from django.views.decorators.http import require_GET
-import jingo
import jinja2
from tower import ugettext_lazy as _lazy, ugettext as _
from waffle.decorators import waffle_flag
@@ -44,7 +44,7 @@ def home(request):
Document, title, request.locale, message)
data.update(SHOWFOR_DATA)
- return jingo.render(request, 'dashboards/home.html', data)
+ return render(request, 'dashboards/home.html', data)
def mobile(request):
@@ -55,7 +55,7 @@ def mobile(request):
Document, title, request.locale, message)
data.update(SHOWFOR_DATA)
- return jingo.render(request, 'dashboards/mobile.html', data)
+ return render(request, 'dashboards/mobile.html', data)
def _kb_readout(request, readout_slug, readouts, locale=None, mode=None):
@@ -72,7 +72,7 @@ def _kb_readout(request, readout_slug, readouts, locale=None, mode=None):
def _kb_detail(request, readout_slug, readouts, main_view_name,
main_dash_title, locale=None):
"""Show all the rows for the given KB article statistics table."""
- return jingo.render(request, 'dashboards/kb_detail.html',
+ return render(request, 'dashboards/kb_detail.html',
{'readout': _kb_readout(request, readout_slug, readouts, locale),
'locale': locale,
'main_dash_view': main_view_name,
@@ -117,7 +117,7 @@ def _kb_main(request, readouts, template, locale=None, extra_data=None):
request.user, locale=settings.WIKI_DEFAULT_LANGUAGE)}
if extra_data:
data.update(extra_data)
- return jingo.render(request, 'dashboards/' + template, data)
+ return render(request, 'dashboards/' + template, data)
@require_GET
@@ -228,7 +228,7 @@ def revisions(request):
result = json.dumps(revision_json)
return HttpResponse(result, mimetype='application/json')
- return jingo.render(request, 'dashboards/revisions.html')
+ return render(request, 'dashboards/revisions.html')
@require_GET
View
3  apps/demos/urls.py
@@ -4,9 +4,6 @@
from .feeds import TagSubmissionsFeed, ProfileSubmissionsFeed
from .feeds import SearchSubmissionsFeed
-from utils import JingoTemplateLoader
-template_loader = JingoTemplateLoader()
-
urlpatterns = patterns('demos.views',
View
26 apps/demos/views.py
@@ -7,7 +7,7 @@
from django.http import HttpResponseRedirect, HttpResponseForbidden
-from django.shortcuts import get_object_or_404
+from django.shortcuts import get_object_or_404, render
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
@@ -103,7 +103,7 @@ def detail(request, slug):
.exclude(hidden=True)\
.order_by('-modified').all()[:5]
- return jingo.render(request, 'demos/detail.html', {
+ return render(request, 'demos/detail.html', {
'submission': submission,
'last_new_comment_id': last_new_comment_id,
'more_by': more_by
@@ -185,7 +185,7 @@ def unlike(request, slug):
@xframe_options_sameorigin
def _like_feedback(request, submission, event):
if request.GET.get('iframe', False):
- return jingo.render(request, 'demos/iframe_utils.html', dict(
+ return render(request, 'demos/iframe_utils.html', dict(
submission=submission, event=event
))
return HttpResponseRedirect(reverse(
@@ -215,7 +215,7 @@ def flag(request, slug):
return HttpResponseRedirect(reverse(
'demos.views.detail', args=(submission.slug,)))
- return jingo.render(request, 'demos/flag.html', {
+ return render(request, 'demos/flag.html', {
'form': form, 'submission': submission})
@@ -233,14 +233,14 @@ def launch(request, slug):
return HttpResponseRedirect(
submission.demo_package.url.replace('.zip', '/index.html'))
else:
- return jingo.render(request, 'demos/launch.html', {
+ return render(request, 'demos/launch.html', {
'submission': submission})
def submit(request):
"""Accept submission of a demo"""
if not request.user.is_authenticated():
- return jingo.render(request, 'demos/submit_noauth.html', {})
+ return render(request, 'demos/submit_noauth.html')
if request.method != "POST":
initial = {}
@@ -263,7 +263,7 @@ def submit(request):
return HttpResponseRedirect(reverse(
'demos.views.detail', args=(new_sub.slug,)))
- return jingo.render(request, 'demos/submit.html', {'form': form})
+ return render(request, 'demos/submit.html', {'form': form})
def edit(request, slug):
@@ -289,7 +289,7 @@ def edit(request, slug):
return HttpResponseRedirect(reverse(
'demos.views.detail', args=(sub.slug,)))
- return jingo.render(request, 'demos/submit.html', {
+ return render(request, 'demos/submit.html', {
'form': form, 'submission': submission, 'edit': True})
@@ -305,7 +305,7 @@ def delete(request, slug):
_invalidate_submission_listing_helper_cache()
return HttpResponseRedirect(reverse('demos.views.home'))
- return jingo.render(request, 'demos/delete.html', {
+ return render(request, 'demos/delete.html', {
'submission': submission})
@@ -346,7 +346,7 @@ def delete_comment(request, slug, object_id):
tc.delete()
return HttpResponseRedirect(reverse(
'demos.views.detail', args=(submission.slug,)))
- return jingo.render(request, 'demos/delete_comment.html', {
+ return render(request, 'demos/delete_comment.html', {
'comment': tc
})
@@ -367,7 +367,7 @@ def hideshow(request, slug, hide=True):
def terms(request):
"""Terms of use page"""
- return jingo.render(request, 'demos/terms.html', {})
+ return render(request, 'demos/terms.html', {})
def devderby_landing(request):
@@ -396,7 +396,7 @@ def devderby_landing(request):
.exclude(hidden=True))
# TODO: Use an object_list here, in case we need pagination?
- return jingo.render(request, 'demos/devderby_landing.html', dict(
+ return render(request, 'demos/devderby_landing.html', dict(
current_challenge_tag_name=current_challenge_tag_name,
previous_winner_tag_name=previous_winner_tag_name,
previous_challenge_tag_names=previous_challenge_tag_names,
@@ -408,7 +408,7 @@ def devderby_landing(request):
def devderby_rules(request):
"""Dev Derby rules page"""
- return jingo.render(request, 'demos/devderby_rules.html', {})
+ return render(request, 'demos/devderby_rules.html', {})
def devderby_by_date(request, year, month):
View
9 apps/devmo/views.py
@@ -1,9 +1,8 @@
-import jingo
import logging
from django.conf import settings
from django.core.paginator import Paginator
-from django.shortcuts import get_object_or_404
+from django.shortcuts import get_object_or_404, render
from django.http import (HttpResponseRedirect, HttpResponseForbidden)
from devmo.urlresolvers import reverse
@@ -36,7 +35,7 @@ def events(request):
"ABQIAAAAijZqBZcz-rowoXZC1tt9iRT5rHVQFKUGOHoyfP"
"_4KyrflbHKcRTt9kQJVST5oKMRj8vKTQS2b7oNjQ")
- return jingo.render(request, 'devmo/calendar.html', {
+ return render(request, 'devmo/calendar.html', {
'upcoming_events': upcoming_events,
'past_events': past_events,
'google_maps_api_key': google_maps_api_key
@@ -66,7 +65,7 @@ def profile_view(request, username):
wiki_activity, docs_feed_items = None, None
wiki_activity = profile.wiki_activity()
- return jingo.render(request, 'devmo/profile.html', dict(
+ return render(request, 'devmo/profile.html', dict(
profile=profile, demos=demos, demos_paginator=demos_paginator,
demos_page=demos_page, docs_feed_items=docs_feed_items,
wiki_activity=wiki_activity
@@ -136,7 +135,7 @@ def profile_edit(request, username):
return HttpResponseRedirect(reverse(
'devmo.views.profile_view', args=(profile.user.username,)))
- return jingo.render(request, 'devmo/profile_edit.html', dict(
+ return render(request, 'devmo/profile_edit.html', dict(
profile=profile, form=form, INTEREST_SUGGESTIONS=INTEREST_SUGGESTIONS
))
View
4 apps/docs/views.py
@@ -4,11 +4,11 @@
from django.conf import settings
from django.http import (HttpResponseRedirect)
+from django.shortcuts import render
from caching.base import cached
import commonware
from dateutil.parser import parse as date_parse
-import jingo
from tower import ugettext as _
from feeder.models import Entry
@@ -68,7 +68,7 @@ def docs(request):
data = {'active_docs': active_docs,
'review_flag_docs': review_flag_docs,
'dotd': dotd}
- return jingo.render(request, 'docs/docs.html', data)
+ return render(request, 'docs/docs.html', data)
def _get_popular_item():
View
28 apps/landing/views.py
@@ -5,9 +5,9 @@
from django.conf import settings
from django.http import HttpResponseServerError
+from django.shortcuts import render
import constance.config
-import jingo
from waffle.decorators import waffle_switch
from devmo import (SECTION_USAGE, SECTION_ADDONS, SECTION_APPS, SECTION_MOBILE,
@@ -32,8 +32,8 @@ def home(request):
for s in SECTION_USAGE:
updates += Bundle.objects.recent_entries(s.updates)[:1]
- return jingo.render(request, 'landing/home.html', {
- 'demos': demos, 'updates': updates, 'tweets': tweets})
+ return render(request, 'landing/home.html',
+ {'demos': demos, 'updates': updates, 'tweets': tweets})
def addons(request):
@@ -55,8 +55,8 @@ def mozilla(request):
def search(request):
"""Google Custom Search results page."""
query = request.GET.get('q', '')
- return jingo.render(request, 'landing/searchresults.html',
- {'query': query})
+ return render(request, 'landing/searchresults.html',
+ {'query': query})
def mobile(request):
@@ -103,17 +103,17 @@ def apps_newsletter(request):
else:
context = {'form': SubscriptionForm(request.locale)}
- return jingo.render(request, 'landing/apps_newsletter.html', context)
+ return render(request, 'landing/apps_newsletter.html', context)
def learn(request):
"""Learn landing page."""
- return jingo.render(request, 'landing/learn.html')
+ return render(request, 'landing/learn.html')
def learn_html(request):
"""HTML landing page."""
- return jingo.render(request, 'landing/learn_html.html')
+ return render(request, 'landing/learn_html.html')
@waffle_switch('html5_landing')
@@ -121,27 +121,27 @@ def learn_html5(request):
"""HTML5 landing page."""
demos = (Submission.objects.all_sorted()
.filter(featured=True, taggit_tags__name__in=['tech:html5']))[:6]
- return jingo.render(request, 'landing/learn_html5.html', {'demos': demos})
+ return render(request, 'landing/learn_html5.html', {'demos': demos})
def learn_css(request):
"""CSS landing page."""
- return jingo.render(request, 'landing/learn_css.html')
+ return render(request, 'landing/learn_css.html')
def learn_javascript(request):
"""JavaScript landing page."""
- return jingo.render(request, 'landing/learn_javascript.html')
+ return render(request, 'landing/learn_javascript.html')
def promote_buttons(request):
"""Bug 646192: MDN affiliate buttons"""
- return jingo.render(request, 'landing/promote_buttons.html')
+ return render(request, 'landing/promote_buttons.html')
def forum_archive(request):
"""Forum Archive from phpbb-static landing page."""
- return jingo.render(request, 'landing/forum_archive.html')
+ return render(request, 'landing/forum_archive.html')
def common_landing(request, section=None, extra=None):
@@ -156,4 +156,4 @@ def common_landing(request, section=None, extra=None):
if extra:
data.update(extra)
- return jingo.render(request, 'landing/%s.html' % section.short, data)
+ return render(request, 'landing/%s.html' % section.short, data)
View
9 apps/search/views.py
@@ -3,6 +3,7 @@
from django.contrib.sites.models import Site
from django.http import HttpResponse, HttpResponseBadRequest
+from django.shortcuts import render
from django.views.decorators.cache import cache_page
import jingo
@@ -21,7 +22,7 @@ def search(request):
if not flag_is_active(request, 'elasticsearch'):
"""Google Custom Search results page."""
query = request.GET.get('q', '')
- return jingo.render(request, 'landing/searchresults.html',
+ return render(request, 'landing/searchresults.html',
{'query': query})
"""Performs search or displays the search form."""
@@ -42,7 +43,7 @@ def search(request):
result_count = results.count()
results = results[start:end]
- return jingo.render(request, 'search/results.html', {'results': results,
+ return render(request, 'search/results.html', {'results': results,
'search_query': search_query,
'result_count': result_count,
'prev_page': page - 1 if start > 0 else None,
@@ -67,6 +68,6 @@ def suggestions(request):
def plugin(request):
"""Render an OpenSearch Plugin."""
site = Site.objects.get_current()
- return jingo.render(request, 'search/plugin.html',
+ return render(request, 'search/plugin.html',
{'site': site, 'locale': request.locale},
- mimetype='application/opensearchdescription+xml')
+ content_type='application/opensearchdescription+xml')
View
2  apps/sumo/helpers.py
@@ -107,7 +107,7 @@ def range(self):
def render(self):
c = {'pager': self.pager, 'num_pages': self.num_pages,
'count': self.count}
- t = env.get_template('layout/paginator.html').render(**c)
+ t = env.get_template('layout/paginator.html').render(c)
return jinja2.Markup(t)
View
8 apps/sumo/views.py
@@ -8,10 +8,10 @@
from django.core.cache import cache, parse_backend_uri
from django.http import (HttpResponsePermanentRedirect, HttpResponseRedirect,
HttpResponse)
+from django.shortcuts import render
from django.views.decorators.cache import never_cache
import celery.task
-import jingo
from PIL import Image
from sumo.urlresolvers import reverse
@@ -23,19 +23,19 @@
def handle403(request):
"""A 403 message that looks nicer than the normal Apache forbidden page."""
- return jingo.render(request, 'handlers/403.html', status=403)
+ return render(request, 'handlers/403.html', status=403)
def handle404(request):
"""A handler for 404s."""
- return jingo.render(request, 'handlers/404.html', status=404)
+ return render(request, 'handlers/404.html', status=404)
def handle500(request):
"""A 500 message that looks nicer than the normal Apache error page."""
- return jingo.render(request, 'handlers/500.html', status=500)
+ return render(request, 'handlers/500.html', status=500)
def redirect_to(request, url, permanent=True, **kwargs):
View
8 apps/users/templates/users/email/activate.ltxt
@@ -1,4 +1,8 @@
-{% load i18n %}{# L10n: This is an email. Whitespace matters! #}{% blocktrans %}
+{# This is an email. Whitespace matters! #}
+
+{% autoescape false %}
+
+{% trans domain=domain, activate_url=activate_url %}
Welcome to {{ domain }}.
Before you can use your new account you must activate it -
@@ -14,4 +18,4 @@ away this e-mail.
Thanks!
The {{ domain }} team
-{% endblocktrans %}
+{% endtrans %}{% endautoescape %}
View
8 apps/users/templates/users/email/confirm_email.ltxt
@@ -1,4 +1,8 @@
-{% load i18n %}{# L10n: This is an email. Whitespace matters! #}{% blocktrans %}
+{# This is an email. Whitespace matters! #}
+
+{% autoescape false %}
+
+{% trans domain=domain, activate_url=activate_url %}
Before we update your email, you must confirm it.
Please click the link below or copy and paste the whole thing
into your browser's location bar:
@@ -8,4 +12,4 @@ https://{{ domain }}{{ activate_url }}
Thanks!
The {{ domain }} team
-{% endblocktrans %}
+{% endtrans %}{% endautoescape %}
View
9 apps/users/templates/users/email/pw_reset.ltxt
@@ -1,4 +1,9 @@
-{% load i18n %}{# L10n: This is an email. Whitespace matters! #}{% blocktrans with user.username as username %}
+{# This is an email. Whitespace matters! #}
+
+{% autoescape false %}
+
+{% trans username=user.username, domain=domain, protocol=protocol,
+ site_name=site_name, uid=uid, token=token %}
{{ domain }} Password Reset
A request was received to reset the password for user '{{ username }}' on
@@ -12,4 +17,4 @@ If you did not request this email there is no need for further action.
Thanks,
The {{ site_name }} team
-{% endblocktrans %}
+{% endtrans %}{% endautoescape %}
View
8 apps/users/templates/users/email/reminder.ltxt
@@ -1,7 +1,11 @@
-{% load i18n %}{# L10n: This is an email. Whitespace matters! #}{% blocktrans %}
+{# This is an email. Whitespace matters! #}
+
+{% autoescape false %}
+
+{% trans username=username, domain=domain %}
This email address is used for the {{ username }} account.
Thanks!
The {{ domain }} team
-{% endblocktrans %}
+{% endtrans %}{% endautoescape %}
View
81 apps/users/views.py
@@ -10,20 +10,19 @@
from django.contrib import messages
from django.contrib.sites.models import Site
from django.http import HttpResponseRedirect, Http404
+from django.shortcuts import render
from django.views.decorators.http import (require_http_methods, require_GET,
require_POST)
from django.views.decorators.clickjacking import xframe_options_sameorigin
from django.views.decorators.csrf import csrf_exempt
-from django.shortcuts import get_object_or_404
+from django.shortcuts import get_object_or_404, render
from django.utils.http import base36_to_int, is_safe_url
from django_browserid.forms import BrowserIDForm
from django_browserid.auth import get_audience
from django_browserid import auth as browserid_auth
-import jingo
-
from access.decorators import logout_required, login_required
from tidings.tasks import claim_watches
from sumo.decorators import ssl_required
@@ -215,7 +214,7 @@ def browserid_register(request):
except MindTouchAPIError:
if user:
user.delete()
- return jingo.render(request, '500.html',
+ return render(request, '500.html',
{'error_message': "We couldn't "
"register a new account at this time. "
"Please try again later."})
@@ -224,7 +223,7 @@ def browserid_register(request):
# for the next request.
request.session.modified = True
- return jingo.render(request, 'users/browserid_register.html',
+ return render(request, 'users/browserid_register.html',
{'login_form': login_form,
'register_form': register_form})
@@ -247,7 +246,7 @@ def login(request):
form.cleaned_data.get('username'),
form.cleaned_data.get('password'))
- return jingo.render(request, 'users/login.html',
+ return render(request, 'users/login.html',
{'form': form, 'next_url': next_url})
@@ -270,11 +269,11 @@ def register(request):
try:
form = handle_register(request)
if form.is_valid():
- return jingo.render(request, 'users/register_done.html')
- return jingo.render(request, 'users/register.html',
+ return render(request, 'users/register_done.html')
+ return render(request, 'users/register.html',
{'form': form})
except MindTouchAPIError, e:
- return jingo.render(request, '500.html',
+ return render(request, '500.html',
{'error_message': "We couldn't "
"register a new account at this time. "
"Please try again later."})
@@ -295,9 +294,9 @@ def activate(request, activation_key):
# my_questions = Question.uncached.filter(creator=account)
# TODO: remove this after dropping unconfirmed questions.
# my_questions.update(status=CONFIRMED)
- return jingo.render(request, 'users/activate.html',
- {'account': account, 'questions': my_questions,
- 'form': form})
+ return render(request, 'users/activate.html',
+ {'account': account, 'questions': my_questions,
+ 'form': form})
def resend_confirmation(request):
@@ -313,13 +312,11 @@ def resend_confirmation(request):
except RegistrationProfile.DoesNotExist:
# Don't leak existence of email addresses.
pass
- return jingo.render(request,
- 'users/resend_confirmation_done.html',
- {'email': email})
+ return render(request, 'users/resend_confirmation_done.html',
+ {'email': email})
else:
form = EmailConfirmationForm()
- return jingo.render(request, 'users/resend_confirmation.html',
- {'form': form})
+ return render(request, 'users/resend_confirmation.html', {'form': form})
def send_email_reminder(request):
@@ -346,13 +343,11 @@ def send_email_reminder(request):
# Don't leak existence of email addresses.
statsd_waffle_incr('users.send_email_reminder.NOUSER',
'signin_metrics')
- return jingo.render(request,
- 'users/send_email_reminder_done.html',
- {'username': username, 'error': error})
+ return render(request, 'users/send_email_reminder_done.html',
+ {'username': username, 'error': error})
else:
form = EmailConfirmationForm()
- return jingo.render(request, 'users/resend_confirmation.html',
- {'form': form})
+ return render(request, 'users/resend_confirmation.html', {'form': form})
@login_required
@@ -370,14 +365,12 @@ def change_email(request):
user=request.user, email=form.cleaned_data['email'])
EmailChange.objects.send_confirmation_email(
email_change, form.cleaned_data['email'])
- return jingo.render(request,
- 'users/change_email_done.html',
- {'email': form.cleaned_data['email']})
+ return render(request, 'users/change_email_done.html',
+ {'email': form.cleaned_data['email']})
else:
form = EmailChangeForm(request.user,
initial={'email': request.user.email})
- return jingo.render(request, 'users/change_email.html',
- {'form': form})
+ return render(request, 'users/change_email.html', {'form': form})
@require_GET
@@ -402,15 +395,14 @@ def confirm_change_email(request, activation_key):
# Delete the activation profile now, we don't need it anymore.
email_change.delete()
- return jingo.render(request, 'users/change_email_complete.html',
- {'old_email': old_email, 'new_email': new_email,
- 'username': u.username, 'duplicate': duplicate})
+ return render(request, 'users/change_email_complete.html',
+ {'old_email': old_email, 'new_email': new_email,
+ 'username': u.username, 'duplicate': duplicate})
def profile(request, user_id):
user_profile = get_object_or_404(UserProfile, user__id=user_id)
- return jingo.render(request, 'users/profile.html',
- {'profile': user_profile})
+ return render(request, 'users/profile.html', {'profile': user_profile})
@login_required
@@ -433,8 +425,8 @@ def edit_profile(request):
else: # request.method == 'GET'
form = ProfileForm(instance=user_profile)
- return jingo.render(request, 'users/edit_profile.html',
- {'form': form, 'profile': user_profile})
+ return render(request, 'users/edit_profile.html',
+ {'form': form, 'profile': user_profile})
@login_required
@@ -470,8 +462,8 @@ def edit_avatar(request):
else: # request.method == 'GET'
form = AvatarForm(instance=user_profile)
- return jingo.render(request, 'users/edit_avatar.html',
- {'form': form, 'profile': user_profile})
+ return render(request, 'users/edit_avatar.html',
+ {'form': form, 'profile': user_profile})
@login_required
@@ -492,8 +484,8 @@ def delete_avatar(request):
return HttpResponseRedirect(reverse('users.edit_profile'))
# else: # request.method == 'GET'
- return jingo.render(request, 'users/confirm_avatar_delete.html',
- {'profile': user_profile})
+ return render(request, 'users/confirm_avatar_delete.html',
+ {'profile': user_profile})
def password_reset(request):
@@ -513,7 +505,7 @@ def password_reset(request):
else:
form = PasswordResetForm()
- return jingo.render(request, 'users/pw_reset_form.html', {'form': form})
+ return render(request, 'users/pw_reset_form.html', {'form': form})
def password_reset_sent(request):
@@ -523,7 +515,7 @@ def password_reset_sent(request):
email is sent.
"""
- return jingo.render(request, 'users/pw_reset_sent.html')
+ return render(request, 'users/pw_reset_sent.html')
@ssl_required
@@ -555,7 +547,7 @@ def password_reset_confirm(request, uidb36=None, token=None):
context['validlink'] = False
form = None
context['form'] = form
- return jingo.render(request, 'users/pw_reset_confirm.html', context)
+ return render(request, 'users/pw_reset_confirm.html', context)
def password_reset_complete(request):
@@ -565,8 +557,7 @@ def password_reset_complete(request):
"""
form = AuthenticationForm()
- return jingo.render(request, 'users/pw_reset_complete.html',
- {'form': form})
+ return render(request, 'users/pw_reset_complete.html', {'form': form})
@login_required
@@ -579,13 +570,13 @@ def password_change(request):
return HttpResponseRedirect(reverse('users.pw_change_complete'))
else:
form = PasswordChangeForm(user=request.user)
- return jingo.render(request, 'users/pw_change.html', {'form': form})
+ return render(request, 'users/pw_change.html', {'form': form})
@login_required
def password_change_complete(request):
"""Change password complete page."""
- return jingo.render(request, 'users/pw_change_complete.html')
+ return render(request, 'users/pw_change_complete.html')
def _clean_next_url(request):
View
2  apps/wiki/cron.py
@@ -89,7 +89,7 @@ def build_sitemaps():
info = {'queryset': queryset, 'date_field': 'modified'}
sitemap = GenericSitemap(info, priority=0.5)
urls = sitemap.get_urls(page=1)
- xml = smart_str(loader.render_to_string('sitemap.xml',
+ xml = smart_str(loader.render_to_string('wiki/sitemap.xml',
{'urlset': urls}))
xml = xml.replace('http://developer.mozilla.org',
'https://developer.mozilla.org')
View
4 apps/wiki/middleware.py
@@ -1,4 +1,4 @@
-import jingo
+from django.shortcuts import render
from wiki import ReadOnlyException
@@ -9,7 +9,7 @@ class ReadOnlyMiddleware(object):
"""
def process_exception(self, request, exception):
if isinstance(exception, ReadOnlyException):
- return jingo.render(request, '403.html',
+ return render(request, '403.html',
{'reason': exception.args[0]},
status=403)
return None
View
13 apps/wiki/templates/wiki/email/approved.ltxt
@@ -1,9 +1,12 @@
-{% load i18n %}
-{# L10n: This is an email. Whitespace matters! #}
-{% blocktrans %}A new revision has been approved for the document
+{# This is an email. Whitespace matters! #}
+
+{% autoescape false %}
+
+{% trans document_title=document_title %}
+A new revision has been approved for the document
{{ document_title }}.
To view the updated document, click the following
link, or paste it into your browser's location bar:
-{% endblocktrans %}
-https://{{ host }}{{ url }}
+{% endtrans %}
+https://{{ host }}{{ url }}{% endautoescape %}
View
12 apps/wiki/templates/wiki/email/ready_for_review.ltxt
@@ -1,10 +1,12 @@
-{% load i18n %}
-{# L10n: This is an email. Whitespace matters! #}
-{% blocktrans %}
+{# This is an email. Whitespace matters! #}
+
+{% autoescape false %}
+
+{% trans creator=creator, document_title=document_title %}
{{ creator }} submitted a new revision to the document
{{ document_title }}.
To review this revision, click the following
link, or paste it into your browser's location bar:
-{% endblocktrans %}
-https://{{ host }}{{ url }}
+{% endtrans %}
+https://{{ host }}{{ url }}{% endautoescape %}
View
38 apps/wiki/templates/wiki/email/reviewed.ltxt
@@ -1,18 +1,36 @@
-{% load i18n %}
-{# L10n: This is an email. Whitespace matters! #}
-{% blocktrans %}Your revision has been reviewed.{% endblocktrans %}
+{# This is an email. Whitespace matters! #}
+
+{% autoescape false %}
+
+{% trans %}
+Your revision has been reviewed.
+{% endtrans %}
+
{% if approved %}
-{% blocktrans %}{{ reviewer }} has approved your revision to the document
-{{ document_title }}.{% endblocktrans %}
+
+{% trans reviewer=reviewer, document_title=document_title %}
+{{ reviewer }} has approved your revision to the document
+
+
+{{ document_title }}.
+{% endtrans %}
+
{% else %}
-{% blocktrans %}{{ reviewer }} has rejected your revision to the document
-{{ document_title }}.{% endblocktrans %}
+
+{% trans reviewer=reviewer, document_title=document_title %}
+{{ reviewer }} has rejected your revision to the document
+{{ document_title }}.
+{% endtrans %}
+
{% endif %}
-{% blocktrans %}Message from the reviewer:
+
+{% trans message=message %}
+Message from the reviewer:
+
{{ message }}
To view the history of this document, click the following
link, or paste it into your browser's location bar:
-{% endblocktrans %}
-https://{{ host }}{{ url }}
+{% endtrans %}
+https://{{ host }}{{ url }}{% endautoescape %}
View
11 apps/wiki/templates/wiki/sitemap.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
+{% for url in urlset %}
+ <url>
+ <loc>{{ url.location }}</loc>
+ {% if url.lastmod %}<lastmod>{{ url.lastmod|datetime("Y-m-d") }}</lastmod>{% endif %}
+ {% if url.changefreq %}<changefreq>{{ url.changefreq }}</changefreq>{% endif %}
+ {% if url.priority %}<priority>{{ url.priority }}</priority>{% endif %}
+ </url>
+{% endfor %}
+</urlset>
View
24 apps/wiki/tests/test_tasks.py
@@ -9,7 +9,7 @@
import celery.conf
import mock
-from nose.tools import eq_
+from nose.tools import eq_, ok_
from test_utils import RequestFactory
from sumo.tests import TestCase
@@ -19,24 +19,6 @@
from wiki.tests import TestCaseBase, revision
-REVIEWED_EMAIL_CONTENT = """
-
-Your revision has been reviewed.
-
-admin has approved your revision to the document
-%s.
-
-Message from the reviewer:
-
-%s
-
-To view the history of this document, click the following
-link, or paste it into your browser's location bar:
-
-https://testserver/en-US/docs/%s$history
-"""
-
-
class RebuildTestCase(TestCase):
fixtures = ['test_users.json', 'wiki/documents.json']
rf = RequestFactory()
@@ -116,8 +98,8 @@ def test_reviewed_notification(self, get_current):
eq_('Your revision has been approved: %s' % doc.title,
mail.outbox[0].subject)
eq_([rev.creator.email], mail.outbox[0].to)
- eq_(REVIEWED_EMAIL_CONTENT % (doc.title, msg, doc.slug),
- mail.outbox[0].body)
+ ok_('https://testserver/en-US/docs/%s$history' % doc.slug
+ in mail.outbox[0].body)
@mock.patch_object(Site.objects, 'get_current')
def test_reviewed_by_creator_no_notification(self, get_current):
View
72 apps/wiki/views.py
@@ -20,14 +20,14 @@
from django.conf import settings
from django.db import transaction
from django.core.exceptions import PermissionDenied
-from django.template import RequestContext
+from django.template import RequestContext, loader
from django.core.cache import cache
from django.contrib import messages
from django.http import (HttpResponse, HttpResponseRedirect,
HttpResponsePermanentRedirect,
Http404, HttpResponseBadRequest)
from django.http.multipartparser import MultiPartParser
-from django.shortcuts import get_object_or_404, render_to_response, redirect
+from django.shortcuts import get_object_or_404, render_to_response, redirect, render
from django.views.decorators.http import (require_GET, require_POST,
require_http_methods, condition)
from django.views.decorators.clickjacking import xframe_options_exempt
@@ -222,8 +222,6 @@ def _added_header(request, *args, **kwargs):
def _format_attachment_obj(attachments):
attachments_list = []
for attachment in attachments:
- html = jingo.get_env().select_template(
- ['wiki/includes/attachment_row.html'])
obj = {
'title': attachment.title,
'date': str(attachment.current_revision.created),
@@ -244,7 +242,8 @@ def _format_attachment_obj(attachments):
except:
pass
- obj['html'] = mark_safe(html.render({'attachment': obj}))
+ obj['html'] = mark_safe(loader.render_to_string('wiki/includes/attachment_row.html',
+ {'attachment': obj}))
attachments_list.append(obj)
return attachments_list
@@ -581,7 +580,7 @@ def set_common_headers(r):
'attachment_data_json': json.dumps(attachments)}
data.update(SHOWFOR_DATA)
- response = jingo.render(request, 'wiki/document.html', data)
+ response = render(request, 'wiki/document.html', data)
return set_common_headers(response)
@@ -709,7 +708,7 @@ def revision(request, document_slug, document_locale, revision_id):
data = {'document': rev.document, 'revision': rev,
'comment': format_comment(rev)}
data.update(SHOWFOR_DATA)
- return jingo.render(request, 'wiki/revision.html', data)
+ return render(request, 'wiki/revision.html', data)
@require_GET
@@ -733,7 +732,7 @@ def list_documents(request, category=None, tag=None):
category=category_id,
tag=tag_obj)
docs = paginate(request, docs, per_page=DOCUMENTS_PER_PAGE)
- return jingo.render(request, 'wiki/list_documents.html',
+ return render(request, 'wiki/list_documents.html',
{'documents': docs,
'category': category,
'tag': tag})
@@ -744,7 +743,7 @@ def list_templates(request):
"""Returns listing of all templates"""
docs = Document.objects.filter(is_template=True).order_by('title')
docs = paginate(request, docs, per_page=DOCUMENTS_PER_PAGE)
- return jingo.render(request, 'wiki/list_documents.html',
+ return render(request, 'wiki/list_documents.html',
{'documents': docs,
'is_templates': True})
@@ -754,7 +753,7 @@ def list_tags(request):
"""Returns listing of all tags"""
tags = DocumentTag.objects.order_by('name')
tags = paginate(request, tags, per_page=DOCUMENTS_PER_PAGE)
- return jingo.render(request, 'wiki/list_tags.html',
+ return render(request, 'wiki/list_tags.html',
{'tags': tags})
@@ -764,7 +763,7 @@ def list_files(request):
files = paginate(request,
Attachment.objects.order_by('title'),
per_page=DOCUMENTS_PER_PAGE)
- return jingo.render(request, 'wiki/list_files.html',
+ return render(request, 'wiki/list_files.html',
{'files': files})
@@ -774,7 +773,7 @@ def list_documents_for_review(request, tag=None):
tag_obj = tag and get_object_or_404(ReviewTag, name=tag) or None
docs = paginate(request, Document.objects.filter_for_review(tag=tag_obj),
per_page=DOCUMENTS_PER_PAGE)
- return jingo.render(request, 'wiki/list_documents_for_review.html',
+ return render(request, 'wiki/list_documents_for_review.html',
{'documents': docs,
'tag': tag_obj,
'tag_name': tag})
@@ -866,7 +865,7 @@ def new_document(request):
allow_add_attachment = (
Attachment.objects.allow_add_attachment_by(request.user))
- return jingo.render(request, 'wiki/new_document.html',
+ return render(request, 'wiki/new_document.html',
{'is_template': is_template,
'parent_slug': parent_slug,
'parent_id': initial_parent_id,
@@ -910,7 +909,7 @@ def new_document(request):
allow_add_attachment = (
Attachment.objects.allow_add_attachment_by(request.user))
- return jingo.render(request, 'wiki/new_document.html',
+ return render(request, 'wiki/new_document.html',
{'is_template': is_template,
'document_form': doc_form,
'revision_form': rev_form,
@@ -1125,7 +1124,7 @@ def edit_document(request, document_slug, document_locale, revision_id=None):
Attachment.objects.allow_add_attachment_by(request.user))
docInfo = json.dumps(_get_document_for_json(doc))
- return jingo.render(request, 'wiki/edit_document.html',
+ return render(request, 'wiki/edit_document.html',
{'revision_form': rev_form,
'document_form': doc_form,
'section_id': section_id,
@@ -1176,7 +1175,7 @@ def _edit_document_collision(request, orig_rev, curr_rev, is_iframe_target,
# Make this response iframe-friendly so we can hack around the
# save-and-edit iframe button
- return jingo.render(request, 'wiki/edit_document.html',
+ return render(request, 'wiki/edit_document.html',
{'collision': True,
'revision_form': rev_form,
'document_form': doc_form,
@@ -1207,7 +1206,7 @@ def move(request, document_slug, document_locale):
if form.is_valid():
conflicts = doc._tree_conflicts(form.cleaned_data['slug'])
if conflicts:
- return jingo.render(request, 'wiki/move_document.html', {
+ return render(request, 'wiki/move_document.html', {
'form': form,
'document': doc,
'descendants': descendants,
@@ -1235,7 +1234,7 @@ def move(request, document_slug, document_locale):
else:
form = TreeMoveForm()
- return jingo.render(request, 'wiki/move_document.html', {
+ return render(request, 'wiki/move_document.html', {
'form': form,
'document': doc,
'descendants': descendants,
@@ -1251,7 +1250,7 @@ def ckeditor_config(request):
else:
code = ''
context = {'editor_config': code, 'redirect_pattern': REDIRECT_CONTENT}
- return jingo.render(request, 'wiki/ckeditor_config.js', context,
+ return render(request, 'wiki/ckeditor_config.js', context,
mimetype="application/x-javascript")
@@ -1273,7 +1272,7 @@ def preview_revision(request):
data = {'content': wiki_content, 'title': request.POST.get('title', ''),
'kumascript_errors': kumascript_errors}
#data.update(SHOWFOR_DATA)
- return jingo.render(request, 'wiki/preview.html', data)
+ return render(request, 'wiki/preview.html', data)
@require_GET
@@ -1382,7 +1381,7 @@ def document_revisions(request, document_slug, document_locale):
revs_out = [r for r in revs if r.id == curr_id]
revs_out.extend([r for r in revs if r.id != curr_id])
- return jingo.render(request, 'wiki/document_revisions.html',
+ return render(request, 'wiki/document_revisions.html',
{'revisions': revs_out, 'document': doc,
'page': page, 'revs': revs, 'curr_id': curr_id})
@@ -1432,7 +1431,7 @@ def review_revision(request, document_slug, document_locale, revision_id):
data = {'revision': rev, 'document': doc, 'form': form,
'parent_revision': parent_revision}
data.update(SHOWFOR_DATA)
- return jingo.render(request, template, data)
+ return render(request, template, data)
@require_GET
@@ -1464,11 +1463,11 @@ def compare_revisions(request, document_slug, document_locale):
context = {'document': doc, 'revision_from': revision_from,
'revision_to': revision_to}
if request.GET.get('raw', 0):
- response = jingo.render(request,
+ response = render(request,
'wiki/includes/revision_diff_table.html',
context)
else:
- response = jingo.render(request, 'wiki/compare_revisions.html',
+ response = render(request, 'wiki/compare_revisions.html',
context)
return response
@@ -1479,7 +1478,7 @@ def select_locale(request, document_slug, document_locale):
"""Select a locale to translate the document to."""
doc = get_object_or_404(
Document, locale=document_locale, slug=document_slug)
- return jingo.render(request, 'wiki/select_locale.html', {'document': doc})
+ return render(request, 'wiki/select_locale.html', {'document': doc})
@require_http_methods(['GET', 'POST'])
@@ -1519,7 +1518,7 @@ def translate(request, document_slug, document_locale, revision_id=None):
if not parent_doc.is_localizable:
message = _lazy(u'You cannot translate this document.')
- return jingo.render(request, 'handlers/400.html',
+ return render(request, 'handlers/400.html',
{'message': message}, status=400)
if revision_id:
@@ -1653,7 +1652,7 @@ def translate(request, document_slug, document_locale, revision_id=None):
parent_split = _split_slug(parent_doc.slug)
- return jingo.render(request, 'wiki/translate.html',
+ return render(request, 'wiki/translate.html',
{'parent': parent_doc, 'document': doc,
'document_form': doc_form, 'revision_form': rev_form,
'locale': document_locale, 'based_on': based_on_rev,
@@ -1804,8 +1803,7 @@ def code_sample(request, document_slug, document_locale, sample_id):
locale=document_locale)
data = document.extract_code_sample(sample_id)
data['document'] = document
- return jingo.render(request, 'wiki/code_sample.html', data)
- return response
+ return render(request, 'wiki/code_sample.html', data)
@require_POST
@@ -1857,7 +1855,7 @@ def revert_document(request, document_path, revision_id):
if request.method == 'GET':
# Render the confirmation page
- return jingo.render(request, 'wiki/confirm_revision_revert.html',
+ return render(request, 'wiki/confirm_revision_revert.html',
{'revision': revision, 'document': document})
document.revert(revision, request.user)
@@ -1879,7 +1877,7 @@ def delete_revision(request, document_path, revision_id):
if request.method == 'GET':
# Render the confirmation page
- return jingo.render(request, 'wiki/confirm_revision_delete.html',
+ return render(request, 'wiki/confirm_revision_delete.html',
{'revision': revision, 'document': document})
# Handle confirm delete form POST
@@ -2169,7 +2167,7 @@ def mindtouch_file_redirect(request, file_id, filename):
def attachment_detail(request, attachment_id):
"""Detail view of an attachment."""
attachment = get_object_or_404(Attachment, pk=attachment_id)
- return jingo.render(request, 'wiki/attachment_detail.html',
+ return render(request, 'wiki/attachment_detail.html',
{'attachment': attachment,
'revision': attachment.current_revision})
@@ -2181,7 +2179,7 @@ def attachment_history(request, attachment_id):
# a few extra bits, like the ability to set an arbitrary revision
# to be current.
attachment = get_object_or_404(Attachment, pk=attachment_id)
- return jingo.render(request, 'wiki/attachment_history.html',
+ return render(request, 'wiki/attachment_history.html',
{'attachment': attachment,
'revision': attachment.current_revision})
@@ -2219,7 +2217,7 @@ def new_attachment(request):
rev.filename())
if request.POST.get('is_ajax', ''):
- response = jingo.render(
+ response = render(
request,
'wiki/includes/attachment_upload_results.html',
{'result': json.dumps(_format_attachment_obj([attachment]))})
@@ -2231,12 +2229,12 @@ def new_attachment(request):
'title': request.POST.get('is_ajax', ''),
'error': _(u'The file provided is not valid')
}
- response = jingo.render(
+ response = render(
request,
'wiki/includes/attachment_upload_results.html',
{'result': json.dumps([error_obj])})
else:
- response = jingo.render(request, 'wiki/edit_attachment.html',
+ response = render(request, 'wiki/edit_attachment.html',
{'form': form})
return response
@@ -2260,5 +2258,5 @@ def edit_attachment(request, attachment_id):
return HttpResponseRedirect(attachment.get_absolute_url())
else:
form = AttachmentRevisionForm()
- return jingo.render(request, 'wiki/edit_attachment.html',
+ return render(request, 'wiki/edit_attachment.html',
{'form': form})
View
4 manage.py
@@ -34,8 +34,8 @@
os.environ.setdefault('DJANGO_SETTINGS_MODULE', settings_mod)
-import safe_django_forms
-safe_django_forms.monkeypatch()
+import jingo.monkey
+jingo.monkey.patch()
if __name__ == "__main__":
execute_from_command_line(sys.argv)
View
1  settings.py
@@ -309,6 +309,7 @@ def lazy_language_deki_map():
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
+ 'jingo.Loader',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
View
4 urls.py
@@ -2,7 +2,7 @@
from django.conf import settings
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
-from django.shortcuts import redirect
+from django.shortcuts import redirect, render
from django.views.i18n import javascript_catalog
from django.views.decorators.cache import cache_page
@@ -76,7 +76,7 @@
# Handle 404 and 500 errors
def _error_page(request, status):
"""Render error pages with jinja2."""
- return jingo.render(request, '%d.html' % status, status=status)
+ return render(request, '%d.html' % status, status=status)
handler403 = lambda r: _error_page(r, 403)
handler404 = lambda r: _error_page(r, 404)
handler500 = lambda r: _error_page(r, 500)
2  vendor
@@ -1 +1 @@
-Subproject commit 81386eec0d91b9faec569b46d1027fbbb0656e2b
+Subproject commit 621b0612911353f86af6c399e7b881d782a8a1c1
Something went wrong with that request. Please try again.