Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions kitsune/bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
'mobile/landings/get-involved': (
'less/mobile/landings/get-involved.less',
),
'badges': (
'less/badges.less',
),
},
'js': {
'common': (
Expand Down
1 change: 1 addition & 0 deletions kitsune/kbadge/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BADGER_BADGE_PAGE_SIZE = 12
87 changes: 50 additions & 37 deletions kitsune/kbadge/templates/badger/award_detail.html
Original file line number Diff line number Diff line change
@@ -1,54 +1,67 @@
{% extends "base.html" %}

{% set styles=('badges',) %}

{% block content %}
<h1>Award detail</h1>
<div class="grid_6">
<h2>
{% trans badge_name=_(badge.title, 'DB: badger.Badge.title') %}
Awarded badge: {{ badge_name }}
{% endtrans %}
</h2>

<section class="award">
<dl class="award">
<dt>Awarded to:</dt>
<dd class="awarded_to"><a href="{{ award.user.get_absolute_url() }}"
class="username">{{ award.user }}</a></dd>
<dl class="badge-details" data-slug="{{ badge.slug }}">
{% if badge.image %}
<dt>{{ _('Image:') }}</dt>
<dd class="image"><a href="{{ badge.get_absolute_url() }}" class="image"><img src="{{ badge.image.url }}" width="256" height="256" /></a></dd>
{% endif %}

{% if award.description %}
<dt>Explanation:</dt>
<dd class="description">{{ award.description }}</dd>
{% if badge.description %}
<dt>{{ _('Description:') }}</dt>
<dd class="description">{{ _(badge.description, 'DB: badger.Badge.description') }}</dd>
{% endif %}

{% if award.creator %}
<dt>Awarded by:</dt>
<dd><a href="{{ award.creator.get_absolute_url() }}"
class="username">{{ award.creator }}</a></dd>
{% if badge.creator %}
<dt>{{ _('Creator:') }}</dt>
<dd><a href="{{ profile_url(badge.creator) }}">{{ badge.creator }}</a></dd>
{% endif %}

<dt>Issued on:</dt>
<dd>{{ award.created }}</dd>
</dl>
</section>
<dt>{{ _('Created:') }}</dt>
<dd>{{ datetimeformat(badge.created) }}</dd>

<section class="badge">
<h2>Badge</h2>
<dt>{{ _('Modified:') }}</dt>
<dd>{{ datetimeformat(badge.modified) }}</dd>
</dl>
</div>

<dl class="badge" data-slug="{{ badge.slug }}">
<dt>Title:</dt>
<dd class="title">{{ badge.title }}</dd>
<div class="grid_6">
<h2>{{ _('Award details') }}</h2>
<dl class="badge-details">
<dt>{{ _('Awarded to:') }}</dt>
<dd class="awarded_to">
<a href="{{ profile_url(award.user) }}">
<img src="{{ profile_avatar(award.user) }}" alt="" title="{{ award.user }}">
<br>{{ award.user }}
</a>
</dd>

{% if award and award.image %}
<dt>Image:</dt>
<dd class="image"><a href="{{ badge.get_absolute_url() }}" class="image"><img src="{{ award.image.url }}" width="256" height="256" /></a></dd>
{% elif badge.image %}
<dt>Image:</dt>
<dd class="image"><a href="{{ badge.get_absolute_url() }}" class="image"><img src="{{ badge.image.url }}" width="256" height="256" /></a></dd>
{% if award.description %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the award doesn't have a description, should it fallback to the badge description?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it shouldn't. The award "description" (which I think is poorly named) is the reason the person was awarded the award. The badge "description" is what the badge is about. I don't think the two things are the same plus I'm pretty sure this page already shows the badge description.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, if it already shows the badge description then we are good to go. 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and yes it does i see now... i just lost myself in my sea of comments.

<dt>{{ _('Explanation:') }}</dt>
<dd class="description">{{ award.description }}</dd>
{% endif %}

{% if badge.description %}
<dt>Description:</dt>
<dd class="description">{{ badge.description }}</dd>
{% if award.creator %}
<dt>{{ _('Awarded by:') }}</dt>
<dd>
<a href="{{ profile_url(award.creator) }}">
<img src="{{ profile_avatar(award.creator) }}" alt="" title="{{ award.creator }}">
{{ award.creator }}
</a>
</dd>
{% endif %}

<dt>Created:</dt>
<dd>{{ badge.created }}</dd>

<dt>Modified:</dt>
<dd>{{ badge.modified }}</dd>
<dt>{{ _('Issued on:') }}</dt>
<dd>{{ datetimeformat(award.created) }}</dd>
</dl>
</section>
</div>
{% endblock %}
77 changes: 49 additions & 28 deletions kitsune/kbadge/templates/badger/awards_list.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,58 @@
{% extends "base.html" %}

{% set styles=('badges',) %}

{% block content %}
<section class="awards_list">
<div class="grid_12">
{% if badge %}
<h2>Awards for {{ badge }}</h2>
{% trans badge_name=_(badge.title, 'DB: badger.Badge.title') %}
<h2>Recently awarded &quot;{{ badge_name }}&quot; badges</h2>
{% endtrans %}
{% else %}
<h2>Recent Awards</h2>
<h2>{{ _('Recently awarded badges') }}</h2>
{% endif %}
</div>

<ul>
{% for award in award_list %}
{% if award.image %}
{% set award_image = award.image.url %}
{% elif award.badge.image %}
{% set award_image = award.badge.image.url %}
{% else %}
{% set award_image = STATIC_URL + 'kbadge/img/default-badge.png' %}
{% endif %}
<li>
<a href="{{ award.get_absolute_url() }}"><img src="{{ award_image }}"
alt="{{ award.badge.title }}" width="128" height="128" /></a>
<ul class="cf" id="awards-list">
{% for award in award_list %}
{% if award.image %}
{% set award_image = award.image.url %}
{% elif award.badge.image %}
{% set award_image = award.badge.image.url %}
{% else %}
{% set award_image = STATIC_URL + 'kbadge/img/default-badge.png' %}
{% endif %}
<li class="grid_4">
<a class="cf" href="{{ award.get_absolute_url() }}">
<div class="badge">
<img src="{{ award_image }}" alt="" title="{{ _(award.badge.title, 'DB: badger.Badge.title') }}">
<span>{{ _(award.badge.title, 'DB: badger.Badge.title') }}</span>
</div>
<div class="award">
{{ _('awarded to') }}
<br><img src="{{ profile_avatar(award.user) }}" alt="" title="{{ award.user }}">
<br>{{ award.user }}
</div>
<div class="meta">
{{ datetimeformat(award.created) }}
</div>
</a>
</li>
{% endfor %}
</ul>

<a href="{{ award.get_absolute_url() }}">
{# TODO: This is bad l10n, but it's a mockup. #}
<span class="badge_title">{{ award.badge.title }}</span>
<span class="relation">awarded to</span>
<span class="user">{{ award.user }}</span>
{% if award.description %}
<span class="award_description">{{ award.description }}</span>
{% endif %}
</a>
{% if is_paginated %}
<ol class="pagination cf">
{% if page_obj.has_previous %}
<li class="prev">
<a href="{{ pagination_base_url }}?page={{ page_obj.previous_page_number }}&sort={{current_sort}}" class="btn-page btn-page-prev">{{_('Previous')}}</a>
</li>
{% endif %}
{% if page_obj.has_next %}
<li class="next">
<a href="{{ pagination_base_url }}?page={{ page_obj.next_page_number }}&sort={{current_sort}}" class="btn-page btn-page-next">{{_('Next')}}</a>
</li>
{% endfor %}
</ul>
{# TODO: pagination here #}
</section>
{% endif %}
</ol>
{% endif %}
{% endblock %}
49 changes: 27 additions & 22 deletions kitsune/kbadge/templates/badger/badge_detail.html
Original file line number Diff line number Diff line change
@@ -1,45 +1,50 @@
{% extends "base.html" %}

{% block content %}
<section>
<h2>Badge detail</h2>

<dl class="badge" data-slug="{{ badge.slug }}">
<dt>Title:</dt>
<dd class="title">{{ badge.title }}</dd>
{% set styles=('badges',) %}

{% block content %}
<div class="grid_6">
<h2>
{% trans badge_name=_(badge.title, 'DB: badger.Badge.title') %}
Badge: {{ badge_name }}
{% endtrans %}
</h2>

<dl class="badge-details" data-slug="{{ badge.slug }}">
{% if badge.image %}
<dt>Image:</dt>
<dt>{{ _('Image:') }}</dt>
<dd class="image"><a href="{{ badge.get_absolute_url() }}" class="image"><img src="{{ badge.image.url }}" width="256" height="256" /></a></dd>
{% endif %}

{% if badge.description %}
<dt>Description:</dt>
<dd class="description">{{ badge.description }}</dd>
<dt>{{ _('Description:') }}</dt>
<dd class="description">{{ _(badge.description, 'DB: badger.Badge.description') }}</dd>
{% endif %}

<dt>Creator:</dt>
<dd><a href="{{ badge.creator.get_absolute_url() }}">{{ badge.creator }}</a></dd>
{% if badge.creator %}
<dt>{{ _('Creator:') }}</dt>
<dd><a href="{{ profile_url(badge.creator) }}">{{ badge.creator }}</a></dd>
{% endif %}

<dt>Created:</dt>
<dd>{{ badge.created }}</dd>
<dt>{{ _('Created:') }}</dt>
<dd>{{ datetimeformat(badge.created) }}</dd>

<dt>Modified:</dt>
<dd>{{ badge.modified }}</dd>
<dt>{{ _('Modified:') }}</dt>
<dd>{{ datetimeformat(badge.modified) }}</dd>
</dl>
</section>
</div>

{% if award_list %}
<section>
<h2>Recent awards</h2>
<ul>
<div class="grid_6">
<h2>{{ _('Recent awardees') }}</h2>
<ul class="awardees">
{% for award in award_list %}
<li>
<a href="{{ award.get_absolute_url() }}">{{ award.user }}</a>
<a href="{{ award.get_absolute_url() }}"><img src="{{ profile_avatar(award.user) }}" alt="" title="{{ award.user }}"></a>
</li>
{% endfor %}
</ul>
</section>
</div>
{% endif %}

{% endblock %}
6 changes: 3 additions & 3 deletions kitsune/kbadge/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def test_list_with_awards(self):

resp = self.client.get(reverse('badger.awards_list'), follow=True)
eq_(200, resp.status_code)
self.assertContains(resp, a1.description)
self.assertContains(resp, a1.user.username)
self.assertContains(resp, a1.get_absolute_url())
self.assertContains(resp, a2.description)
self.assertContains(resp, a2.user.username)
self.assertContains(resp, a2.get_absolute_url())
self.assertContains(resp, a3.description)
self.assertContains(resp, a3.user.username)
self.assertContains(resp, a3.get_absolute_url())


Expand Down
Loading