Skip to content

Commit a2f7545

Browse files
committed
OKRS24-117 Update 'Related Links' section. Handle non-200 status codes
1 parent a38fa47 commit a2f7545

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

src/base/models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,9 @@ def get_preview(self) -> LinkPreview:
116116
:return: A dictionary containing information about the link preview, including title, description, and image.
117117
:rtype: dict
118118
"""
119-
return link_preview(self)
119+
try:
120+
return link_preview(self)
121+
except Exception:
122+
return {
123+
'description': _('No description available'),
124+
}

src/templates/signals/signal_detail.html

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,30 @@ <h5>Related links</h5>
227227
<div class="card">
228228
<div class="card-body padding-top-1rem">
229229
<div class="row">
230-
{% for link in signal.links.all %}
231-
{% if link.link_type != 'example_url' %}
232-
<div class="card col-2 related-link-card">
233-
<div class="card-body">
234-
<h5 class="card-title">{{ link.get_previerw.title }}</h5>
235-
<p class="card-text">{{ link.get_preview.description }}</p>
236-
<a href="{{ link.url }}">{{ link.url|truncatechars:50 }}</a>
237-
</div>
238-
</div>
239-
{% endif %}
240-
{% endfor %}
230+
<table class="table table-responsive">
231+
<thead>
232+
<tr>
233+
<th scope="col">Link Type</th>
234+
<th scope="col">Link Description</th>
235+
<th scope="col">URL</th>
236+
</tr>
237+
</thead>
238+
<tbody>
239+
{% for link in signal.links.all %}
240+
{% if link.link_type != 'example_url' %}
241+
<tr>
242+
<td>
243+
{{ link.get_link_type_display }}
244+
</td>
245+
<td>{{ link.get_preview.description }}</td>
246+
<td>
247+
<a href="{{ link.url }}">{{ link.url|truncatechars:50 }}</a>
248+
</td>
249+
</tr>
250+
{% endif %}
251+
{% endfor %}
252+
</tbody>
253+
</table>
241254
</div>
242255
</div>
243256
</div>

0 commit comments

Comments
 (0)