website/templates/shortcodes/gitea_clinic_doc_reviews.html

49 lines
1.9 KiB
HTML
Raw Normal View History

2022-04-26 12:58:39 +00:00
{% set data_doctors = load_data(path="data/clinic-doctors.toml") %}
{% set full_star = "★" %}
{% set empty_star = "☆" %}
<div class="clinic__doctors-container">
{# sorted by name #}
{% set data_doctors = data_doctors["doctors"] | sort(attribute="name") %}
{% for doctor in data_doctors %}
<div class="doctor__container">
{% set_global rating = 0 %}
{% set reviews_length = doctor["reviews"] | length %}
{% for review in doctor["reviews"] %}
{% set_global rating = rating + review["rating"] %}
{% endfor %}
{% set rating_fraction = rating % 1 %}
{% if rating == 5 %}
{% set_global rating_str = full_star ~ full_star ~ full_star ~ full_star ~ full_star %}
{% elif rating > 4 %}
{% set_global rating_str = full_star ~ full_star ~ full_star ~ full_star ~ empty_star %}
{% elif rating > 3 %}
{% set_global rating_str = full_star ~ full_star ~ full_star ~ empty_star ~ empty_star %}
{% elif rating > 2 %}
{% set_global rating_str = full_star ~ full_star ~ empty_star ~ empty_star ~ empty_star %}
{% elif rating > 1 %}
{% set_global rating_str = full_star ~ empty_star ~ empty_star ~ empty_star ~ empty_star %}
{% else %}
{% set_global rating_str = empty_star ~ empty_star ~ empty_star ~ empty_star %}
{% endif %}
{% if doctor["picture"] %}
{% set picture = doctor["picture"] %}
{% else %}
{% set picture = "/tmp-logo.png" %}
{% endif %}
{% set rating = rating / reviews_length %}
<img src="{{ get_url(path=picture, cachebust=true) }}" alt="" class="doctor__profile_photo">
<h3 class="doctor__name">{{ doctor["name"] }}</h3>
<div class="docutr__rating-container">
<p class="doctor_rating-stars">{{ rating_str }}</p>
<!--<p class="doctor_rating-value">{{ rating }}</p> -->
</div>
<a href='{{ doctor["website"] }}' class="doctor__contact">Get in touch</a>
2022-04-26 12:58:39 +00:00
</div>
{% endfor %}
</div>