Replace 'jinja2.contextfunction' with 'jinja2.pass_context' (#17466)
* Updated error message. * Replaced all the instances * Replaced Mutliple Instances @jinja2.contextfunction instances replaced with @jinja2.pass_context * Replaced Multiple Instances Multiple Instances of @jinja2.contextfunction were replaced with @jinja2.pass_context . * Mutiple Instances were replaced Multiple instances of @jinja2.contextfunction were replaced with @jinja2.pass_context * Multiple Instances were replaced Multiple instances of @jinja2.contextfunction were replaced with @jinja2.pass_context * Replaced Multiple Instances Multiple instances of @jinja2.contextfunction were replaced with @jinja2.pass_context . * Replaced Multiple Instances Multiple Instances of @jinja2.contextfunction replaced with @jinja2.pass_context * Replaced Multiple Instances Replaced instances of @jinja2.contextfunction with @jinja2.pass_context * Update jinja_helpers.py * Update jinja_helpers.py * Update jinja_helpers.py * Update jinja_helpers.py * Replaced Instance Replaced instance of jinja2.contextfunction with jinja2.pass_context * Fix merge * Update jinja_helpers.py * Update jinja_helpers.py Co-authored-by: Mathieu Pillard <diox@users.noreply.github.com>
This commit is contained in:
Родитель
c5e5efb5d3
Коммит
444f47a6b6
|
@ -223,7 +223,7 @@ jinja2.bccache.Bucket class api.html
|
|||
jinja2.lexer.TokenStream.skip method extensions.html
|
||||
jinja2.clear_caches function api.html
|
||||
jinja2.runtime.Context.get_exported method api.html
|
||||
jinja2.contextfunction function api.html
|
||||
jinja2.pass_context function api.html
|
||||
escaped function templates.html
|
||||
jinja2.lexer.Token.test method extensions.html
|
||||
jinja2.lexer.TokenStream.eos attribute extensions.html
|
||||
|
|
|
@ -6,7 +6,7 @@ from .. import acl
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def check_ownership(
|
||||
context, obj, require_owner=False, require_author=False, ignore_disabled=True
|
||||
):
|
||||
|
@ -20,6 +20,6 @@ def check_ownership(
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def action_allowed(context, permission):
|
||||
return acl.action_allowed(context['request'], permission)
|
||||
|
|
|
@ -6,18 +6,18 @@ from olympia.accounts import utils
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def login_link(context):
|
||||
return utils.default_fxa_login_url(context['request'])
|
||||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def register_link(context):
|
||||
return utils.default_fxa_register_url(context['request'])
|
||||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def fxa_config(context):
|
||||
return utils.fxa_config(context['request'])
|
||||
|
|
|
@ -5,7 +5,7 @@ from django_jinja import library
|
|||
|
||||
@library.global_function
|
||||
@library.render_with('addons/impala/listing/sorter.html')
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def impala_addon_listing_header(
|
||||
context,
|
||||
url_base,
|
||||
|
|
|
@ -93,7 +93,7 @@ def url(viewname, *args, **kwargs):
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def drf_url(context, viewname, *args, **kwargs):
|
||||
"""Helper for DjangoRestFramework's ``reverse`` in templates."""
|
||||
request = context.get('request')
|
||||
|
@ -174,7 +174,7 @@ def numberfmt(num, format=None):
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def page_title(context, title):
|
||||
title = smart_str(title)
|
||||
base_title = gettext('Add-ons for {0}').format(amo.FIREFOX.pretty)
|
||||
|
@ -249,7 +249,7 @@ def timeuntil(time):
|
|||
|
||||
@library.global_function
|
||||
@library.render_with('amo/recaptcha.html')
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def recaptcha(context, form):
|
||||
d = dict(context.items())
|
||||
d.update(form=form)
|
||||
|
@ -277,7 +277,7 @@ def loc(s):
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def remora_url(context, url, lang=None, app=None, prefix=''):
|
||||
"""Wrapper for urlresolvers.remora_url"""
|
||||
if lang is None:
|
||||
|
@ -293,7 +293,7 @@ def remora_url(context, url, lang=None, app=None, prefix=''):
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def hasOneToOne(context, obj, attr):
|
||||
try:
|
||||
getattr(obj, attr)
|
||||
|
|
|
@ -22,7 +22,7 @@ library.global_function(acl.check_addon_ownership)
|
|||
|
||||
@library.global_function
|
||||
@library.render_with('devhub/addons/listing/items.html')
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def dev_addon_listing_items(context, addons, src=None, notes=None):
|
||||
if notes is None:
|
||||
notes = {}
|
||||
|
@ -30,7 +30,7 @@ def dev_addon_listing_items(context, addons, src=None, notes=None):
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def dev_page_title(context, title=None, addon=None):
|
||||
"""Wrapper for devhub page titles."""
|
||||
if addon:
|
||||
|
@ -42,7 +42,7 @@ def dev_page_title(context, title=None, addon=None):
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def docs_page_title(context, title=None):
|
||||
"""Wrapper for docs page titles."""
|
||||
devhub = gettext('Add-on Documentation :: Developer Hub')
|
||||
|
|
|
@ -36,7 +36,7 @@ def version_status(addon, version):
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def queue_tabnav(context):
|
||||
"""Returns tuple of tab navigation for the queue pages.
|
||||
|
||||
|
@ -112,7 +112,7 @@ def queue_tabnav(context):
|
|||
|
||||
@library.global_function
|
||||
@library.render_with('reviewers/includes/reviewers_score_bar.html')
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def reviewers_score_bar(context, types=None, addon_type=None):
|
||||
user = context.get('user')
|
||||
|
||||
|
@ -130,7 +130,7 @@ def reviewers_score_bar(context, types=None, addon_type=None):
|
|||
|
||||
@library.global_function
|
||||
@library.render_with('reviewers/includes/files_view.html')
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def all_files(context, version):
|
||||
return new_context(
|
||||
dict(
|
||||
|
@ -179,7 +179,7 @@ def get_position(addon):
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def is_expired_lock(context, lock):
|
||||
return lock.expiry < datetime.datetime.now()
|
||||
|
||||
|
@ -190,7 +190,7 @@ def code_manager_url(page, addon_id, version_id, base_version_id=None):
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def check_review_delete(context, rating):
|
||||
return user_can_delete_rating(context['request'], rating)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from olympia.addons.models import Addon
|
|||
|
||||
|
||||
@library.global_function
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def report_menu(context, request, report, obj):
|
||||
"""Renders navigation for the various statistic reports."""
|
||||
if isinstance(obj, Addon):
|
||||
|
|
|
@ -56,7 +56,7 @@ def truncate(s, length=255, killwords=True, end='...'):
|
|||
|
||||
@library.global_function
|
||||
@library.render_with('translations/trans-menu.html')
|
||||
@jinja2.contextfunction
|
||||
@jinja2.pass_context
|
||||
def l10n_menu(context, default_locale='en-us', remove_locale_url=''):
|
||||
"""Generates the locale menu for zamboni l10n."""
|
||||
default_locale = default_locale.lower()
|
||||
|
|
Загрузка…
Ссылка в новой задаче