Skip to content

Commit 7483381

Browse files
committed
Remove external_url and display_url calls
1 parent d8bccba commit 7483381

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

udata_front/tests/views/test_oembed.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_oembed_for_dataset(self, api):
2929
'''It should fetch a dataset in the oembed format.'''
3030
dataset = DatasetFactory()
3131

32-
url = url_for('api.oembed', url=dataset.external_url)
32+
url = url_for('api.oembed', url=dataset.url_for())
3333

3434
response = api.get(url, headers={'Origin': 'http://localhost'})
3535
assert200(response)
@@ -49,7 +49,7 @@ def test_oembed_for_dataset_with_organization(self, api):
4949
organization = OrganizationFactory()
5050
dataset = DatasetFactory(organization=organization)
5151

52-
url = url_for('api.oembed', url=dataset.external_url)
52+
url = url_for('api.oembed', url=dataset.url_for())
5353

5454
response = api.get(url, headers={'Origin': 'http://localhost'})
5555
assert200(response)
@@ -91,7 +91,7 @@ def test_oembed_for_reuse(self, api):
9191
'''It should fetch a reuse in the oembed format.'''
9292
reuse = ReuseFactory()
9393

94-
url = url_for('api.oembed', url=reuse.external_url)
94+
url = url_for('api.oembed', url=reuse.url_for())
9595
response = api.get(url, headers={'Origin': 'http://localhost'})
9696
assert200(response)
9797
assert_cors(response)
@@ -109,7 +109,7 @@ def test_oembed_for_org(self, api):
109109
'''It should fetch an organization in the oembed format.'''
110110
org = OrganizationFactory()
111111

112-
url = url_for('api.oembed', url=org.external_url)
112+
url = url_for('api.oembed', url=org.url_for())
113113
response = api.get(url, headers={'Origin': 'http://localhost'})
114114
assert200(response)
115115
assert_cors(response)
@@ -145,7 +145,7 @@ def test_oembed_with_an_unknown_url(self, api):
145145
def test_oembed_with_port_in_https_url(self, api):
146146
'''It should works on HTTPS URLs with explicit port.'''
147147
dataset = DatasetFactory()
148-
url = dataset.external_url.replace('http://local.test/',
148+
url = dataset.url_for().replace('http://local.test/',
149149
'https://local.test:443/')
150150
api_url = url_for('api.oembed', url=url)
151151

@@ -154,7 +154,7 @@ def test_oembed_with_port_in_https_url(self, api):
154154
def test_oembed_does_not_support_xml(self, api):
155155
'''It does not support xml format.'''
156156
dataset = DatasetFactory()
157-
url = url_for('api.oembed', url=dataset.external_url, format='xml')
157+
url = url_for('api.oembed', url=dataset.url_for(), format='xml')
158158
response = api.get(url, headers={'Origin': 'http://localhost'})
159159
assert_status(response, 501)
160160
assert_cors(response)
@@ -213,7 +213,7 @@ def test_oembeds_dataset_api_get(self, api):
213213
assert data['type'] == 'rich'
214214
assert data['version'] == '1.0'
215215
assert dataset.title in data['html']
216-
assert dataset.external_url in data['html']
216+
assert dataset.url_for() in data['html']
217217
assert 'placeholders/default.png' in data['html']
218218
assert mdstrip(dataset.description, 110) in data['html']
219219

@@ -228,7 +228,7 @@ def test_oembeds_dataset_api_get_with_organization(self, api):
228228
assert200(response)
229229
data = response.json[0]
230230
assert organization.name in data['html']
231-
assert organization.external_url in data['html']
231+
assert organization.url_for() in data['html']
232232

233233
def test_oembeds_dataset_api_get_without_references(self, api):
234234
'''It should fail at fetching an oembed without a dataset.'''

udata_front/theme/gouvfr/templates/dataset/display.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
{% block extra_head %}
3030
{% cache cache_duration, 'dataset-extra-head', dataset.id|string, g.lang_code, dataset.last_modified|string %}
3131
<link rel="canonical" href="{{ url_for('datasets.show', dataset=dataset) }}" />
32-
<link rel="alternate" type="application/json+oembed" href="{{ url_for('api.oembed', url=dataset.external_url) }}"
32+
<link rel="alternate" type="application/json+oembed" href="{{ url_for('api.oembed', url=dataset.url_for()) }}"
3333
title="{{ dataset.title | urlencode }}" />
3434
{% endcache %}
3535
{% endblock %}

udata_front/theme/gouvfr/templates/embed-dataset.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,26 @@
167167
</style>
168168
<article class="dataset-card" id="{{ item_reference }}">
169169
<h4 class="udata-title" data-tooltip="{{ _('Download from ') }}{{ config.SERVER_NAME }}">
170-
<a href="{{ item.external_url or item.url }}" title="{{ item.full_title or item.title }}">
170+
<a href="{{ item.url_for() or item.url }}" title="{{ item.full_title or item.title }}">
171171
{{ item.title|mdstrip(80) }}
172172
</a>
173173
</h4>
174174
<div class="udata-content">
175175
<p class="udata-source">
176176
{% if item.organization %}
177-
<a href="{{ item.organization.external_url }}" data-tooltip="{{ _('Producer') }}">
177+
<a href="{{ item.organization.url_for() }}" data-tooltip="{{ _('Producer') }}">
178178
<img src="{{ item.organization.logo(70, external=True)|placeholder(external=True) }}"
179179
alt="{{ item.organization.name }}"
180180
height="70" width="70">
181181
</a>
182182
{% elif item.owner %}
183-
<a href="{{ item.owner.external_url }}" data-tooltip="{{ _('Uploader') }}">
183+
<a href="{{ item.owner.url_for() }}" data-tooltip="{{ _('Uploader') }}">
184184
<img src="{{ item.owner|avatar_url(70, external=True) }}"
185185
alt="{{ item.owner.fullname }}"
186186
height="70" width="70">
187187
</a>
188188
{% else %}
189-
<a href="{{ item.external_url }}">
189+
<a href="{{ item.url_for() }}">
190190
<img src="{{ ''|placeholder(external=True) }}"
191191
alt=""
192192
height="70" width="70">
@@ -203,7 +203,7 @@ <h4 class="udata-title" data-tooltip="{{ _('Download from ') }}{{ config.SERVER_
203203
</div>
204204
<aside class="udata-meta">
205205
<p class="udata-code" data-tooltip="{{ _('Add to your own website') }}">
206-
<a href="{{ item.external_url or item.url }}" class="integrate" data-label="{{ _('Close') }}">{{ _('Embed') }}</a>
206+
<a href="{{ item.url_for() or item.url }}" class="integrate" data-label="{{ _('Close') }}">{{ _('Embed') }}</a>
207207
</p>
208208
{% if item.temporal_coverage %}
209209
<p class="udata-calendar" data-tooltip="{{ _('Temporal coverage') }}">
@@ -223,7 +223,7 @@ <h4 class="udata-title" data-tooltip="{{ _('Download from ') }}{{ config.SERVER_
223223
</p>
224224
{% elif item.territory %}
225225
<p class="udata-marker" data-tooltip="{{ _('Territory') }}">
226-
<a href="{{ item.territory.external_url }}">
226+
<a href="{{ item.territory.url_for() }}">
227227
{{ item.territory.name }}
228228
</a>
229229
</p>

udata_front/theme/gouvfr/templates/home.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<div class="fr-col-12 fr-col-md-6 text-align-center-md">
2020
<a
2121
class="mw-100 inline-flex items-center fr-raw-link fr-text--sm fr-m-0 fr-py-1v fr-px-3v border text-blue-400 border-blue-400 rounded-xs bg-white text-overflow-ellipsis"
22-
href="{{ last_post.display_url }}"
22+
href="{{ last_post.url_for() }}"
2323
>
2424
<span aria-hidden="true" class="fr-icon-newspaper-line fr-icon--sm fr-mr-1w"></span>
2525
<span class="fr-text--bold fr-mb-0">{{ _('News') }}</span>
@@ -407,7 +407,7 @@ <h3 class="text-grey-500 font-800 fs-xxxl fr-m-0">{{last_post.name}}</h3>
407407
<div class="fr-col-auto">
408408
<a
409409
class="fr-btn"
410-
href="{{ last_post.display_url }}"
410+
href="{{ last_post.url_for() }}"
411411
>
412412
{{_('Read the article')}}
413413
</a>

udata_front/theme/gouvfr/templates/post/display.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ <h2 class="fr-h2">{{ _('Actions') }}</h2>
117117
<li class="fr-col-12 fr-col-md-3 text-align-center-md">
118118
{% if previous_post %}
119119
<a
120-
href="{{ previous_post.display_url }}"
120+
href="{{ previous_post.url_for() }}"
121121
class="fr-btn fr-btn--secondary fr-icon-arrow-left-s-line fr-btn--icon-left"
122122
>
123123
{{ _('Previous post') }}
@@ -132,7 +132,7 @@ <h2 class="fr-h2">{{ _('Actions') }}</h2>
132132
<li class="fr-col-12 fr-col-md-3 text-align-right text-align-center-md">
133133
{% if next_post %}
134134
<a
135-
href="{{ next_post.display_url }}"
135+
href="{{ next_post.url_for() }}"
136136
class="fr-btn fr-btn--secondary fr-icon-arrow-right-s-line fr-btn--icon-right"
137137
>
138138
{{ _('Next post') }}

udata_front/theme/gouvfr/templates/post/search-result.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="fr-card__body">
44
<div class="fr-card__content">
55
<h3 class="fr-card__title">
6-
<a href="{{ post.display_url }}">
6+
<a href="{{ post.url_for() }}">
77
{{ post.name }}
88
</a>
99
</h3>

udata_front/theme/gouvfr/templates/reuse/display.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
{% block extra_head %}
2626
{% cache cache_duration, 'reuse-extra-head', reuse.id|string, g.lang_code, reuse.last_modified|string %}
2727
<link rel="canonical" href="{{ url_for('reuses.show', reuse=reuse) }}" />
28-
<link rel="alternate" type="application/json+oembed" href="{{ url_for('api.oembed', url=reuse.external_url) }}"
28+
<link rel="alternate" type="application/json+oembed" href="{{ url_for('api.oembed', url=reuse.url_for()) }}"
2929
title="{{ reuse.title | urlencode }}" />
3030
{% endcache %}
3131
{% endblock %}

udata_front/views/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def on_form_error(self, form):
208208
return self.render(form=form)
209209

210210
def get_success_url(self, obj):
211-
return obj.display_url
211+
return obj.url_for()
212212

213213
def post(self, **kwargs):
214214
context = self.get_context()

0 commit comments

Comments
 (0)