0001-misc-give-widget-templates-full-access-to-publisher-.patch
tests/templates/qommon/forms/widgets/select--test.html | ||
---|---|---|
2 | 2 |
{% block widget-control %} |
3 | 3 |
<!-- TEST TEMPLATE --> |
4 | 4 |
<!-- backoffice: {{ request.quixote_request.is_in_backoffice|pprint }} --> |
5 |
<!-- substitution variable: {{ example_url }} --> |
|
5 | 6 |
<select id="form_{{widget.name}}" name="{{widget.name}}" |
6 | 7 |
{% for attr in widget.attrs.items %}{{attr.0}}="{{attr.1}}"{% endfor %}> |
7 | 8 |
<option value="">---</option> |
tests/test_form_pages.py | ||
---|---|---|
4581 | 4581 |
# make sure request is available in context |
4582 | 4582 |
assert '<!-- backoffice: False -->' in resp.body |
4583 | 4583 | |
4584 |
# test for substitution variables being available |
|
4585 |
if not pub.site_options.has_section('variables'): |
|
4586 |
pub.site_options.add_section('variables') |
|
4587 |
pub.site_options.set('variables', 'example_url', 'http://remote.example.net/') |
|
4588 |
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd: |
|
4589 |
pub.site_options.write(fd) |
|
4590 |
resp = get_app(pub).get('/test/') |
|
4591 |
assert 'substitution variable: http://remote.example.net/' in resp.body |
|
4592 | ||
4584 | 4593 |
def test_form_status_appearance_keywords(pub): |
4585 | 4594 |
create_user(pub) |
4586 | 4595 |
formdef = create_formdef() |
wcs/qommon/form.py | ||
---|---|---|
128 | 128 |
self.rendered_title = lambda: safe(self.render_title(self.get_title())) |
129 | 129 |
self.rendered_error = lambda: safe(self.render_error(self.get_error())) |
130 | 130 |
self.rendered_hint = lambda: safe(self.render_hint(self.get_hint())) |
131 |
context = {'widget': self} |
|
131 |
if get_publisher(): |
|
132 |
context = get_publisher().substitutions.get_context_variables() |
|
133 |
else: |
|
134 |
context = {} |
|
135 |
context['widget'] = self |
|
132 | 136 |
template_names = get_template_names(self) |
133 | 137 |
return htmltext(render_template(template_names, context)) |
134 | 138 | |
135 |
- |