[IMP] website_(profile, slides): use badge level image as default badge image

Before this commit, if no image was set on the badge, no image was shown when
displaying the badge.

After this commit, if a badge level is set on the badge and no image is set,
the badge level image will be used for the badge.

This fix / improvement is applied twice

  * when displaying an user profile, its received badges;
  * when displaying current user achievements in eLearning;

Task ID 1981399
PR #43577
This commit is contained in:
David Beguin
2020-04-16 10:26:32 +00:00
committed by Thibault Delavallée
parent 16e492860b
commit 45f7463e7a
2 changed files with 15 additions and 5 deletions
@@ -367,10 +367,19 @@
<div class="card">
<div class="card-body p-2 pr-3">
<div class="media align-items-center">
<img width="38" height="38" t-att-src="website.image_url(badge.badge_id, 'image_128')" class="o_object_fit_cover mr-0"/>
<div class="media-body col-md-10 p-0">
<h6 class="my-0 text-truncate" t-field="badge.badge_id.name"/>
</div>
<img t-if="not badge.badge_id.image_1920 and badge.badge_id.level"
width="38" height="38"
t-attf-src="/website_profile/static/src/img/badge_#{badge.badge_id.level}.svg"
class="o_object_fit_cover mr-0"
t-att-alt="badge.badge_id.name"/>
<img t-else=""
width="38" height="38"
t-att-src="website.image_url(badge.badge_id, 'image_128')"
class="o_object_fit_cover mr-0"
t-att-alt="badge.badge_id.name"/>
<div class="media-body col-md-10 p-0">
<h6 class="my-0 pl-1 text-truncate" t-field="badge.badge_id.name"/>
</div>
</div>
</div>
</div>
@@ -505,7 +505,8 @@
<div t-attf-class="d-flex mb-3 align-items-center #{'o_wslides_entry_muted' if not challenge_done else ''}">
<img class="mr-2"
style="max-height: 36px;"
t-att-src="website.image_url(challenge.reward_id, 'image_128')"
t-att-src="website.image_url(challenge.reward_id, 'image_128') if challenge.reward_id.image_1920 else
'/website_profile/static/src/img/badge_%s.svg' % (challenge.reward_id.level)"
t-att-alt="challenge.reward_id.name"/>
<div class="flex-grow-1">
<b class="text_small_caps" t-esc="challenge.reward_id.name"/><br/>