Skip to content

Commit

Permalink
feat(templates): url for helper;
Browse files Browse the repository at this point in the history
- Replaced url_for global with helper.
  • Loading branch information
JVickery-TBS committed Jul 28, 2023
1 parent 668d608 commit 857967c
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<p class="mrgn-tp-lg">{{ _('You are not logged in to the Open Government Registry.
Note that your login expires after 1 hour of inactivity.
Click on the log in button below to log in.') }}</p>
<p><a href="{% url_for 'user.login' %}" class="btn btn-primary">
<p><a href="{{ h.url_for('user.login') }}" class="btn btn-primary">
<span class="fa fa-sign-in"></span><span class="text">{{ _('Log in') }}</span>
</a></p>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion ckanext/canada/templates/internal/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ul class="list-inline">
{% block header_account_notlogged %}
<li>
<a href="{% url_for 'user.login' %}" class="btn btn-primary">
<a href="{{ h.url_for('user.login') }}" class="btn btn-primary">
<span class="fa fa-sign-in"></span>
<span class="text">{{ _('Log in') }}</span>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h2 id="prtable">{{_("Preview")}}</h2>

// closing form tag needed for py webtest lib
var form = $('<form></form>',{
action : "{% url_for 'recombinant.template', dataset_type=dataset_type, lang=h.lang(),owner_org=owner_org %}",
action : "{{ h.url_for('recombinant.template', dataset_type=dataset_type, lang=h.lang(), owner_org=owner_org) }}",
method : "post"
});

Expand Down
2 changes: 1 addition & 1 deletion ckanext/canada/templates/internal/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2 class="modal-title" id="modalLabel">{{ _('Your user sessions has timed out d
{{ _('If you are currently entering data on this page, you may lose it when submitted. To avoid this, you can click on the log in button below to log in again in a new tab without losing your progress and you can then keep working on this page. If you have any issues please contact <a href="mailto:[email protected]">[email protected]</a>.') | safe }}
</div>
<div class="modal-footer">
<a href="{% url_for 'user.login' %}" target="_blank" class="btn btn-default btn-sm">
<a href="{{ h.url_for('user.login') }}" target="_blank" class="btn btn-default btn-sm">
<span class="fa fa-sign-in"></span>
<span class="text">{{ _('Log in') }}</span>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{% set chromo = h.recombinant_get_chromo(resource.name) %}
{% if chromo.create_form %}
<a class="btn btn-default"
href="{% url_for
href="{{ h.url_for(
'canada.create_pd_record',
owner_org=pkg.owner_org,
resource_name=resource.name %}"><i class="glyphicon glyphicon-plus-sign"></i>
resource_name=resource.name) }}"><i class="glyphicon glyphicon-plus-sign"></i>
{{ _("Create Single Record") }}</a>
<h4>{{ _("Create and update multiple records") }}</h4>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions ckanext/canada/templates/internal/user/edit_user_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
<div class="form-actions">
{% block delete_button %}
{% if h.check_access('user_delete', {'id': data.id}) %}
<a class="btn btn-danger pull-left" href="{% url_for 'user_delete', id=data.id %}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this User?') }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
<a class="btn btn-danger pull-left" href="{{ h.url_for('user_delete', id=data.id) }}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this User?') }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endblock %}
{% block generate_button %}
{% if h.check_access('api_token_create', {'user': data.id}) %}
<a class="btn btn-warning mrgn-lft-md" href="{% url_for 'user.api_tokens', id=data.name %}">{% block generate_button_text %}{{ _('Create API Token') }}{% endblock %}</a>
<a class="btn btn-warning mrgn-lft-md" href="{{ h.url_for('user.api_tokens', id=data.name) }}">{% block generate_button_text %}{{ _('Create API Token') }}{% endblock %}</a>
{% endif %}
{% endblock %}
<button class="btn btn-primary mrgn-lft-md" type="submit" name="save">{{ _('Update Profile') }}</button>
Expand Down
2 changes: 1 addition & 1 deletion ckanext/canada/templates/internal/user/read_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<dt>{{ _('Organizations') }}</dt>
<dd><ul>
{% for org in h.user_organizations(user) %}
<li><a href="{% url_for org.type + '.read', id=org.name %}">{{cr.split_bilingual_field(org.title, h.lang())}}</a></li>
<li><a href="{{ h.url_for(org.type + '.read', id=org.name) }}">{{cr.split_bilingual_field(org.title, h.lang())}}</a></li>
{% endfor %}
</ul></dd>
</dl>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<section class="module module-narrow module-shallow simple-input" style="margin-bottom: 15px;">
<h2 class="wb-inv">{{ _('Search Users') }}</h2>
<form action="{% url_for 'user.index' %}" method="get" id="user-search-form">
<form action="{{ h.url_for('user.index') }}" method="get" id="user-search-form">
<div class="field">
<label for="field-user-search">{{ _('Search Users') }}</label>
<input id="field-user-search" value="{{ q }}" class="field form-control" name="q" placeholder="{{ _('Search Users') }}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block primary_content_inner %}
{% if res.datastore_active %}
<form> {# form required for button styling :-| #}
<a href="{% url_for 'canada.delete_datastore_table', id=pkg.id, resource_id=res.id %}"
<a href="{{ h.url_for('canada.delete_datastore_table', id=pkg.id, resource_id=res.id) }}"
class="btn btn-danger pull-left"
data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this DataStore table and Data Dictionary?') }}"
>{% block delete_datastore_button_text %}<i class="fa fa-remove"></i>{{ _('Delete DataStore table') }}{% endblock %}</a>
Expand Down
2 changes: 1 addition & 1 deletion ckanext/canada/templates/public/admin/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="form-actions">
{% set locale = h.dump_json({'content': _('Are you sure you want to reset the config?')}) %}
<button type="submit" class="btn btn-primary" name="save">{{ _('Update Config') }}</button>
<a href="{% url_for 'admin.reset_config' %}" class="btn btn-danger" data-module="confirm-action" data-module-i18n="{{ locale }}">{{ _('Reset') }}</a>
<a href="{{ h.url_for('admin.reset_config') }}" class="btn btn-danger" data-module="confirm-action" data-module-i18n="{{ locale }}">{{ _('Reset') }}</a>
</div>
</form>
</div>
Expand Down
12 changes: 6 additions & 6 deletions ckanext/canada/templates/public/macros/canada_read.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
<li>
<a class="btn btn-default btn-xs mrgn-bttm-sm mrgn-rght-sm" href="
{%- if client_lang == 'fr' -%}
{%- url_for pkg.type + '.search',
keywords_fra=tag.strip() -%}
{{ h.url_for(pkg.type + '.search',
keywords_fra=tag.strip()) }}
{%- else -%}
{%- url_for pkg.type + '.search',
keywords=tag.strip() -%}
{{ h.url_for(pkg.type + '.search',
keywords=tag.strip()) }}
{%- endif -%}
" title="{{ _('Keyword') ~ ' ' ~ tag.strip() }}">{{ tag.strip() }}</a>
</li>
Expand Down Expand Up @@ -138,8 +138,8 @@
{%- endmacro -%}


{#
Search Facet Formatters
{#
Search Facet Formatters
#}

{%- macro subject_label(subject, lang) -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% block form %}
<p>{{ _('Are you sure you want to delete member - {name}?').format(name=c.user_dict.name) }}</p>
<p class="form-actions">
<form action="{% url_for 'organization.member_delete', id=c.group_id %}" method="post">
<form action="{{ h.url_for('organization.member_delete', id=c.group_id) }}" method="post">
<input type="hidden" name="user" value="{{ c.user_id }}" />
<button class="btn" type="submit" name="cancel" >{{ _('Cancel') }}</button>
<button class="btn btn-primary" type="submit" name="delete" >{{ _('Confirm Delete') }}</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% block form %}
<p>{{ _('Are you sure you want to delete dataset - {name}?').format(name=c.pkg_dict.name) }}</p>
<p class="form-actions">
<form action="{% url_for c.pkg_dict.type + '.delete', id=c.pkg_dict.name %}" method="post">
<form action="{{ h.url_for(c.pkg_dict.type + '.delete', id=c.pkg_dict.name) }}" method="post">
<button class="btn btn-primary" type="submit" name="cancel" >{{ _('Cancel') }}</button>
<button class="btn btn-danger" type="submit" name="delete" >{{ _('Confirm Delete') }}</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% block form %}
<p>{{ _('Are you sure you want to delete resource - {name}?').format(name=h.resource_display_name(c.resource_dict)) }}</p>
<p class="form-actions">
<form action="{% url_for 'dataset_resource.delete', resource_id=c.resource_dict.id, id=c.pkg_id %}" method="post">
<form action="{{ h.url_for('dataset_resource.delete', resource_id=c.resource_dict.id, id=c.pkg_id) }}" method="post">
<button class="btn btn-danger" type="submit" name="cancel" >{{ _('Cancel') }}</button>
<button class="btn btn-primary" type="submit" name="delete" >{{ _('Confirm Delete') }}</button>
</form>
Expand Down
4 changes: 2 additions & 2 deletions ckanext/canada/templates/public/snippets/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ <h2 class="wb-inv">Sign-on information</h2>
{% else %}
{% block header_account_notlogged %}
{% if h.check_access('user_create') %}
<li><a href="{% url_for 'user.register', class_='sub' %}" class="btn btn-default">{{ _('Register') }}</a></li>
<li><a href="{{ h.url_for('user.register', class_='sub') }}" class="btn btn-default">{{ _('Register') }}</a></li>
{% endif %}
<li><a href="{% url_for 'user.login' %}" class="btn btn-primary">{{ _('Log in') }}</a></li>
<li><a href="{{ h.url_for('user.login') }}" class="btn btn-primary">{{ _('Log in') }}</a></li>
{% endblock %}
{% endif %}
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ <h2>{{ _('Language selection') }}</h2>
<div class="col-md-12">
<ul class="list-inline margin-bottom-none">
{% if h.lang() == 'fr' %}
<li><a lang="en" hreflang="en" href="{% url_for h.current_url(), locale='en' %}">English</a></li>
<li><a lang="en" hreflang="en" href="{{ h.url_for(h.current_url(), locale='en') }}">English</a></li>
{% else %}
<li><a lang="fr" hreflang="fr" href="{% url_for h.current_url(), locale='fr' %}">Français</a></li>
<li><a lang="fr" hreflang="fr" href="{{ h.url_for(h.current_url(), locale='fr') }}">Français</a></li>
{% endif %}
</ul>
</div>
Expand Down
4 changes: 2 additions & 2 deletions ckanext/canada/templates/public/user/edit_user_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
<div class="form-actions">
{% block delete_button %}
{% if h.check_access('user_delete', {'id': data.id}) %}
<a class="btn btn-danger pull-left" href="{% url_for 'user_delete', id=data.id %}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this User?') }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
<a class="btn btn-danger pull-left" href="{{ h.url_for('user_delete', id=data.id) }}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this User?') }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endblock %}
{% block generate_button %}
{% if h.check_access('api_token_create', {'user': data.id}) %}
<a class="btn btn-warning mrgn-lft-md" href="{% url_for 'user.api_tokens', id=data.name %}">{% block generate_button_text %}{{ _('Create API Token') }}{% endblock %}</a>
<a class="btn btn-warning mrgn-lft-md" href="{{ h.url_for('user.api_tokens', id=data.name) }}">{% block generate_button_text %}{{ _('Create API Token') }}{% endblock %}</a>
{% endif %}
{% endblock %}
<button class="btn btn-primary mrgn-lft-md" type="submit" name="save">{{ _('Update Profile') }}</button>
Expand Down
4 changes: 2 additions & 2 deletions ckanext/canada/templates/public/user/read.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h3>{{_('Organizations')}}</h3>
<ul>

{% for org in h.user_organizations(user) %}
<li><a href="{% url_for org.type + '.read', id=org.name %}">{{cr.split_bilingual_field(org.title, h.lang())}}</a></li>
<li><a href="{{ h.url_for(org.type + '.read', id=org.name) }}">{{cr.split_bilingual_field(org.title, h.lang())}}</a></li>
{% endfor %}
</ul>
{%- endblock -%}
{%- endblock -%}

0 comments on commit 857967c

Please sign in to comment.