Service pages improvements #152
2 changed files with 21 additions and 2 deletions
|
@ -83,6 +83,13 @@ class Service(ServalaModelMixin, models.Model):
|
|||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@property
|
||||
def featured_links(self):
|
||||
"""Return external links marked as featured."""
|
||||
if not self.external_links:
|
||||
return []
|
||||
return [link for link in self.external_links if link.get("featured")]
|
||||
|
||||
|
||||
def validate_dict(data, required_fields=None, allow_empty=True):
|
||||
if not data:
|
||||
|
|
|
@ -36,8 +36,20 @@
|
|||
<div class="card-body flex-grow-1">
|
||||
{% if service.description %}<p class="card-text">{{ service.description|urlize }}</p>{% endif %}
|
||||
</div>
|
||||
<div class="card-footer d-flex justify-content-between">
|
||||
<span></span>
|
||||
<div class="card-footer d-flex justify-content-between align-items-center gap-2">
|
||||
{% if service.featured_links %}
|
||||
{% with featured_link=service.featured_links.0 %}
|
||||
<a href="{{ featured_link.url }}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="btn btn-outline-primary">
|
||||
{{ featured_link.title }}
|
||||
<i class="bi bi-box-arrow-up-right ms-1"></i>
|
||||
</a>
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
<span></span>
|
||||
{% endif %}
|
||||
<a href="{{ service.slug }}/" class="btn btn-light-primary">{% translate "View Availability" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue