Skip to content

Commit 8e6d218

Browse files
committed
Fix the deprecations for old action URLs
This deprecation should be issued when the placeholder mark (:) appears in the action URL string.
1 parent 5c634af commit 8e6d218

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

CHANGES.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Release date: -
2222
- Introduce a new and better way to pass table action URLs to support the usage of ``Flask``'s path converters
2323
(`#146 <https://github.com/greyli/bootstrap-flask/pull/146>`__).
2424

25-
2625
1.7.0
2726
-----
2827

flask_bootstrap/templates/bootstrap/table.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% from 'bootstrap/utils.html' import render_icon, arg_url_for %}
22

33
{% macro deprecate_placeholder_url() %}
4-
{{ warn('Passing an URL with primary key palceholder for view_url/edit_url/delete_url/custom_actions is deprecated. You will need to pass an fixed URL or an URL tuple to URL arguments, see the docs for more details (https://bootstrap-flask.readthedocs.io/en/stable/macros.html#render-table). The support to URL string will be removed in version 2.0.') }}
4+
{{ warn('Passing an URL with primary key palceholder for view_url/edit_url/delete_url/custom_actions is deprecated. You will need to pass an fixed URL or an URL tuple to URL arguments, see the docs for more details (https://bootstrap-flask.readthedocs.io/en/stable/macros.html#render-table). The support to URL string will be removed in version 2.0.', stacklevel=2) }}
55
{% endmacro %}
66

77
{% macro build_url(endpoint, model, pk, url_tuples) %}
@@ -94,10 +94,10 @@
9494
{% for (action_name, action_icon, action_url) in custom_actions %}
9595
{% if ':primary_key' in action_url | join('') %}
9696
{% set action_pk_placeholder = ':primary_key' %}
97-
{% set _ = deprecate_placeholder_url() %}
9897
{% endif %}
9998
<a class="action-icon text-decoration-none"
10099
{% if action_url is string %}
100+
{% if ':' in action_url %}{% set _ = deprecate_placeholder_url() %}{% endif %}
101101
href="{{ action_url | replace(action_pk_placeholder, row[primary_key]) }}"
102102
{% else %}
103103
href="{{ build_url(action_url[0], model, row[primary_key], action_url[1]) | trim }}"
@@ -108,10 +108,10 @@
108108
{% if view_url %}
109109
{% if ':primary_key' in view_url | join('') %}
110110
{% set action_pk_placeholder = ':primary_key' %}
111-
{% set _ = deprecate_placeholder_url() %}
112111
{% endif %}
113112
<a class="action-icon text-decoration-none"
114113
{% if view_url is string %}
114+
{% if ':' in view_url %}{% set _ = deprecate_placeholder_url() %}{% endif %}
115115
href="{{ view_url | replace(action_pk_placeholder, row[primary_key]) }}"
116116
{% else %}
117117
href="{{ build_url(view_url[0], model, row[primary_key], view_url[1]) | trim }}"
@@ -123,10 +123,10 @@
123123
{% if edit_url -%}
124124
{% if ':primary_key' in edit_url | join('') %}
125125
{% set action_pk_placeholder = ':primary_key' %}
126-
{% set w = deprecate_placeholder_url() %}
127126
{% endif %}
128127
<a class="action-icon text-decoration-none"
129128
{% if edit_url is string %}
129+
{% if ':' in edit_url %}{% set _ = deprecate_placeholder_url() %}{% endif %}
130130
href="{{ edit_url | replace(action_pk_placeholder, row[primary_key]) }}"
131131
{% else %}
132132
href="{{ build_url(edit_url[0], model, row[primary_key], edit_url[1]) | trim }}"
@@ -138,10 +138,10 @@
138138
{% if delete_url %}
139139
{% if ':primary_key' in delete_url | join('') %}
140140
{% set action_pk_placeholder = ':primary_key' %}
141-
{% set _ = deprecate_placeholder_url() %}
142141
{% endif %}
143142
<form style="display:inline"
144143
{% if delete_url is string %}
144+
{% if ':' in delete_url %}{% set _ = deprecate_placeholder_url() %}{% endif %}
145145
action="{{ delete_url | replace(action_pk_placeholder, row[primary_key]) }}"
146146
{% else %}
147147
action="{{ build_url(delete_url[0], model, row[primary_key], delete_url[1]) | trim }}"

0 commit comments

Comments
 (0)