add combo templatetags in builtins (#37273)
This commit is contained in:
parent
f887b66ead
commit
57542ab058
|
@ -1,4 +1,4 @@
|
|||
{% load combo i18n %}
|
||||
{% load i18n %}
|
||||
{% block cell-content %}
|
||||
{% for tile in tiles %}
|
||||
{% with cell=tile.cell %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load i18n combo %}
|
||||
{% load i18n %}
|
||||
{% block cell-content %}
|
||||
<h2>{% trans "Informations related to your family" %}</h2>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load i18n combo %}
|
||||
{% load i18n %}
|
||||
{% if title %}<h2>{{ title }}</h2>{% endif %}
|
||||
<div>
|
||||
{% trans "Introduction" context "tipi" as tipi_intro %}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
{% load combo %}
|
||||
{% if entries|length %}
|
||||
<div class="pwa-navigation" id="pwa-navigation"
|
||||
{% if include_user_name %}data-pwa-user-name="{% skeleton_extra_placeholder user-name %}{{user.get_full_name}}{% end_skeleton_extra_placeholder %}"{% endif %}>
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
{% load combo %}
|
||||
|
||||
var applicationServerPublicKey = {{ pwa_vapid_public_key|as_json|safe }};
|
||||
var COMBO_PWA_USER_SUBSCRIPTION = false;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load combo gadjo static thumbnail %}
|
||||
{% load gadjo static thumbnail %}
|
||||
|
||||
/* global self, caches, fetch, URL, Response */
|
||||
'use strict';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load combo i18n %}
|
||||
{% load i18n %}
|
||||
{% block cell-content %}
|
||||
<h2>{% trans "New Form" %}</h2>
|
||||
{% for site_formdefs in all_formdefs.values %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load i18n combo %}
|
||||
{% load i18n %}
|
||||
{% block cell-content %}
|
||||
<h2>{% trans 'Current Drafts' %}</h2>
|
||||
{% for slug, forms in current_drafts.items %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load combo i18n %}
|
||||
{% load i18n %}
|
||||
{% block cell-content %}
|
||||
<h2>{% trans 'All Forms' %}</h2>
|
||||
{% for slug, forms in user_forms.items %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load combo i18n %}
|
||||
{% load i18n %}
|
||||
{% block cell-content %}
|
||||
<h2>{% trans 'Done Forms' %}</h2>
|
||||
{% for slug, forms in user_forms.items %}
|
||||
|
|
|
@ -43,7 +43,7 @@ class ProfileCell(JsonCellBase):
|
|||
@property
|
||||
def url(self):
|
||||
idp = list(settings.KNOWN_SERVICES.get('authentic').values())[0]
|
||||
return '{%% load combo %%}%sapi/users/{{ concerned_user|name_id }}/' % idp.get('url')
|
||||
return '%sapi/users/{{ concerned_user|name_id }}/' % idp.get('url')
|
||||
|
||||
def is_visible(self, user=None):
|
||||
if not user or user.is_anonymous:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
{% load combo %}
|
||||
{% if menuitems %}
|
||||
<ul>
|
||||
{% spaceless %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load combo gadjo i18n %}<!DOCTYPE html>
|
||||
{% load gadjo i18n %}<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "combo/page_template.html" %}
|
||||
{% load combo i18n %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block combo-content %}
|
||||
<div id="main-content">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load combo i18n %}
|
||||
{% load i18n %}
|
||||
{% if render %}
|
||||
{% if render_skeleton %}
|
||||
{{ skeleton }}
|
||||
|
|
|
@ -164,7 +164,7 @@ def render_cell(request, cell):
|
|||
# Cell can pass data through its own __dict__
|
||||
cell.modify_global_context(context, request)
|
||||
|
||||
template = engines['django'].from_string('{% load combo %}{% render_cell cell %}')
|
||||
template = engines['django'].from_string('{% render_cell cell %}')
|
||||
return HttpResponse(template.render(context, request), content_type='text/html')
|
||||
|
||||
|
||||
|
|
|
@ -118,6 +118,9 @@ TEMPLATES = [
|
|||
'django.contrib.messages.context_processors.messages',
|
||||
'combo.context_processors.template_vars',
|
||||
],
|
||||
'builtins': [
|
||||
'combo.public.templatetags.combo',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "combo/page_template.html" %}
|
||||
{% load combo i18n %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block combo-content %}
|
||||
<div id="main-content">
|
||||
|
|
|
@ -667,7 +667,7 @@ def test_page_cell_placeholder_restricted_visibility(app, admin_user):
|
|||
page = Page(title='Test', slug='test', template_name='standard')
|
||||
page.save()
|
||||
json_cell = JsonCell(page=page, placeholder='content', order=0, url='http://example.com')
|
||||
json_cell.template_string = '{% load combo %}{% placeholder "foobar" name="Foobar" %}'
|
||||
json_cell.template_string = '{% placeholder "foobar" name="Foobar" %}'
|
||||
json_cell.save()
|
||||
|
||||
TextCell(page=page, placeholder='foobar', text='<p>Public text</p>', order=0,
|
||||
|
|
|
@ -1166,7 +1166,7 @@ def test_page_cell_placeholder(app, admin_user):
|
|||
assert re.findall('data-placeholder-key="(.*)">', resp.text) == ['content', 'footer']
|
||||
|
||||
# check a placeholder within a cell is included
|
||||
cell.template_string = '{% load combo %}{% placeholder "foobar" name="Foobar" %}'
|
||||
cell.template_string = '{% placeholder "foobar" name="Foobar" %}'
|
||||
cell.save()
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
assert re.findall('data-placeholder-key="(.*)">', resp.text) == ['content', 'foobar', 'footer']
|
||||
|
|
|
@ -19,7 +19,7 @@ pytestmark = pytest.mark.django_db
|
|||
|
||||
|
||||
def test_strptime():
|
||||
t = Template('{% load combo %}{{ someday|strptime:"%Y-%m-%d"|date:"Y" }}')
|
||||
t = Template('{{ someday|strptime:"%Y-%m-%d"|date:"Y" }}')
|
||||
assert t.render(Context({'someday': '2015-04-15'})) == '2015'
|
||||
assert t.render(Context({'someday': 'foobar'})) == ''
|
||||
assert t.render(Context({'someday': None})) == ''
|
||||
|
@ -27,7 +27,7 @@ def test_strptime():
|
|||
assert t.render(Context({'someday': ['foo', 'bar']})) == ''
|
||||
|
||||
def test_parse_datetime():
|
||||
t = Template('{% load combo %}{{ someday|parse_datetime|date:"Y m d H i s T" }}')
|
||||
t = Template('{{ someday|parse_datetime|date:"Y m d H i s T" }}')
|
||||
expected = '2015 04 15 13 11 12 UTC'
|
||||
assert t.render(Context({'someday': '2015-04-15T13:11:12'})) == expected
|
||||
assert t.render(Context({'someday': '2015-04-15 13:11:12'})) == expected
|
||||
|
@ -45,7 +45,7 @@ def test_parse_datetime():
|
|||
assert t.render(Context({'someday': {'foo': 'bar'}})) == ''
|
||||
assert t.render(Context({'someday': ['foo', 'bar']})) == ''
|
||||
|
||||
t = Template('{% load combo %}{{ someday|parse_date|date:"Y m d" }}')
|
||||
t = Template('{{ someday|parse_date|date:"Y m d" }}')
|
||||
expected = '2015 04 15'
|
||||
assert t.render(Context({'someday': '2015-04-15'})) == expected
|
||||
assert t.render(Context({'someday': '2015-04-15T13:11:12Z'})) == ''
|
||||
|
@ -55,7 +55,7 @@ def test_parse_datetime():
|
|||
assert t.render(Context({'someday': {'foo': 'bar'}})) == ''
|
||||
assert t.render(Context({'someday': ['foo', 'bar']})) == ''
|
||||
|
||||
t = Template('{% load combo %}{{ someday|parse_time|date:"H i s" }}')
|
||||
t = Template('{{ someday|parse_time|date:"H i s" }}')
|
||||
expected = '13 11 12'
|
||||
assert t.render(Context({'someday': '13:11:12'})) == expected
|
||||
assert t.render(Context({'someday': '13:11:12Z'})) == expected
|
||||
|
@ -73,7 +73,7 @@ def test_parse_datetime():
|
|||
assert t.render(Context({'someday': ['foo', 'bar']})) == ''
|
||||
|
||||
def test_has_role():
|
||||
t = Template('{% load combo %}{{ request.user|has_role:"Role1" }}')
|
||||
t = Template('{{ request.user|has_role:"Role1" }}')
|
||||
|
||||
request = RequestFactory().get('/')
|
||||
user = User(username='foo', email='foo@example.net')
|
||||
|
@ -88,7 +88,7 @@ def test_has_role():
|
|||
user.save()
|
||||
assert t.render(context) == 'True'
|
||||
|
||||
t = Template('{% load combo %}{{ request.user|has_role:"Role2" }}')
|
||||
t = Template('{{ request.user|has_role:"Role2" }}')
|
||||
assert t.render(context) == 'False'
|
||||
group = Group(name='Role2')
|
||||
group.save()
|
||||
|
@ -106,7 +106,7 @@ def test_has_role():
|
|||
assert t.render(context) == 'False'
|
||||
|
||||
def test_get():
|
||||
t = Template('{% load combo %}{{ foo|get:"foo-bar" }}')
|
||||
t = Template('{{ foo|get:"foo-bar" }}')
|
||||
context = Context({'foo': {'foo-bar': 'hello'}})
|
||||
assert t.render(context) == 'hello'
|
||||
context = Context({'foo': {'bar-foo': 'hello'}})
|
||||
|
@ -114,18 +114,18 @@ def test_get():
|
|||
context = Context({'foo': None})
|
||||
assert t.render(context) == 'None'
|
||||
|
||||
t = Template('{% load combo %}{{ foo|get:"foo-bar"|default:"" }}')
|
||||
t = Template('{{ foo|get:"foo-bar"|default:"" }}')
|
||||
context = Context({'foo': {'rab': 'hello'}})
|
||||
assert t.render(context) == ''
|
||||
|
||||
t = Template('{% load combo %}{{ foo|get:key }}')
|
||||
t = Template('{{ foo|get:key }}')
|
||||
context = Context({'foo': {'foo-bar': 'hello'}, 'key': 'foo-bar'})
|
||||
assert t.render(context) == 'hello'
|
||||
|
||||
def test_split():
|
||||
t = Template('{% load combo %}{% for x in plop|split %}{{x}}<br>{% endfor %}')
|
||||
t = Template('{% for x in plop|split %}{{x}}<br>{% endfor %}')
|
||||
assert t.render(Context({'plop': 'ab cd ef'})) == 'ab<br>cd<br>ef<br>'
|
||||
t = Template('{% load combo %}{% for x in plop|split:"|" %}{{x}} {% endfor %}')
|
||||
t = Template('{% for x in plop|split:"|" %}{{x}} {% endfor %}')
|
||||
assert t.render(Context({'plop': 'ab|cd|ef'})) == 'ab cd ef '
|
||||
|
||||
def test_get_group():
|
||||
|
@ -136,7 +136,7 @@ def test_get_group():
|
|||
{'name': 'Chicago', 'population': '7,000,000', 'country': 'USA'},
|
||||
{'name': 'Tokyo', 'population': '33,000,000', 'country': 'Japan'},
|
||||
]})
|
||||
t = Template('{% load combo %}{% regroup cities by country as country_list %}'
|
||||
t = Template('{% regroup cities by country as country_list %}'
|
||||
'{% for c in country_list|get_group:"USA" %}{{c.name}},{% endfor %}')
|
||||
assert t.render(context) == 'New York,Chicago,'
|
||||
|
||||
|
|
Loading…
Reference in New Issue