Fixes and tweaks for profiles and awards list
* Added by-badge awards list view URL * Recent awards listed on badge detail page * Showing user names as unicode() * Using user.get_absolute_url() everywhere for profile links
This commit is contained in:
Родитель
11e624dfc6
Коммит
4442680cf6
|
@ -10,7 +10,7 @@
|
|||
|
||||
{% block content %}
|
||||
<section class="awards_list">
|
||||
<h2>Awards for {{user}}</h2>
|
||||
<h2>Awards for {{ user }}</h2>
|
||||
{% include "badger/includes/awards_list.html" %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
|
|
@ -11,7 +11,11 @@
|
|||
{% block content %}
|
||||
|
||||
<section class="awards_list">
|
||||
<h2>Awards</h2>
|
||||
{% if badge %}
|
||||
<h2>Awards for {{ badge }}</h2>
|
||||
{% else: %}
|
||||
<h2>Recent Awards</h2>
|
||||
{% endif %}
|
||||
{% include "badger/includes/awards_list.html" %}
|
||||
</section>
|
||||
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
<h2>Badge detail</h2>
|
||||
{% include "badger/includes/badge_full.html" %}
|
||||
|
||||
{% if awards %}
|
||||
{% if award_list %}
|
||||
<h2>Recent awards</h2>
|
||||
<ul class="awards">
|
||||
{% for award in awards %}
|
||||
{% include "badger/includes/awards_list.html" %}
|
||||
<nav><ul>
|
||||
<li>
|
||||
{% include "badger/includes/award_as_user.html" %}
|
||||
<a href="{{ url('badger.views.awards_list', badge.slug) }}">More...</a>
|
||||
<a href="{{ url('badger.feeds.awards_by_badge', 'atom', badge.slug) }}"><img src="{{MEDIA_URL}}/img/feed-icon-14x14.png" /></a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</ul></nav>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
<li>
|
||||
<a href="{{ url('badger.views.badges_list') }}">More...</a>
|
||||
<a href="{{ url('badger_multiplayer.feeds.badges_recent', 'atom') }}"><img src="{{MEDIA_URL}}/img/feed-icon-14x14.png" /></a>
|
||||
</a>
|
||||
</li>
|
||||
</ul></nav>
|
||||
</section>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% set user = award.user %}
|
||||
<div class="award by_user">
|
||||
<a href="{{award.get_absolute_url()}}" class="username">{{ user.username }}</a>
|
||||
<a href="{{award.get_absolute_url()}}" class="username">{{ user }}</a>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<dl class="award">
|
||||
<dt>Awarded to:</dt>
|
||||
<dd><a href="{{url('badger.views.awards_by_user', user.username)}}"
|
||||
class="username">{{ user.username }}</a></dd>
|
||||
<dd><a href="{{ award.user.get_absolute_url() }}"
|
||||
class="username">{{ award.user }}</a></dd>
|
||||
<dt>Awarded by:</dt>
|
||||
<dd><a href="{{url('badger.views.awards_by_user', user.username)}}"
|
||||
<dd><a href="{{ award.creator.get_absolute_url() }}"
|
||||
class="username">{{ award.creator }}</a></dd>
|
||||
<dt>Issued on:</dt>
|
||||
<dd>{{ award.created }}</dd>
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
<dt>Description:</dt>
|
||||
<dd class="description">{{ badge.description }}</dd>
|
||||
{% endif %}
|
||||
<dt>Creator:</dt>
|
||||
<dd><a href="{{ badge.creator.get_absolute_url() }}">{{ badge.creator }}</a></dd>
|
||||
<dt>Created:</dt>
|
||||
<dd>{{ badge.created }}</dd>
|
||||
<dt>Modified:</dt>
|
||||
|
|
|
@ -11,26 +11,28 @@ urlpatterns = patterns('badger.views',
|
|||
url(r'^$', 'badges_list', name='badger.badges_list'),
|
||||
url(r'^awards/?', 'awards_list',
|
||||
name='badger.awards_list'),
|
||||
url(r'^detail/(?P<slug>[^/]+)/awards/(?P<id>[^\.]+)\.json$', 'award_detail',
|
||||
url(r'^badge/(?P<slug>[^/]+)/awards/?$', 'awards_list',
|
||||
name='badger.awards_list_for_badge'),
|
||||
url(r'^badge/(?P<slug>[^/]+)/awards/(?P<id>[^\.]+)\.json$', 'award_detail',
|
||||
kwargs=dict(format="json"),
|
||||
name='badger.award_detail_json'),
|
||||
url(r'^detail/(?P<slug>[^/]+)/awards/(?P<id>[^/]+)/?$', 'award_detail',
|
||||
url(r'^badge/(?P<slug>[^/]+)/awards/(?P<id>[^/]+)/?$', 'award_detail',
|
||||
name='badger.award_detail'),
|
||||
url(r'^detail/(?P<slug>[^/]+);award', 'award_badge',
|
||||
url(r'^badge/(?P<slug>[^/]+);award', 'award_badge',
|
||||
name='badger.award_badge'),
|
||||
url(r'^detail/(?P<slug>[^\.]+)\.json$', 'detail',
|
||||
url(r'^badge/(?P<slug>[^\.]+)\.json$', 'detail',
|
||||
kwargs=dict(format="json"),
|
||||
name='badger.detail_json'),
|
||||
url(r'^detail/(?P<slug>[^/]+)/?$', 'detail',
|
||||
url(r'^badge/(?P<slug>[^/]+)/?$', 'detail',
|
||||
name='badger.detail'),
|
||||
url(r'^detail/(?P<slug>[^/]+)/awards/?$', 'awards_by_badge',
|
||||
url(r'^badge/(?P<slug>[^/]+)/awards/?$', 'awards_by_badge',
|
||||
name='badger.awards_by_badge'),
|
||||
url(r'^users/(?P<username>[^/]+)/awards/?$', 'awards_by_user',
|
||||
name='badger.awards_by_user'),
|
||||
|
||||
url(r'^feeds/(?P<format>[^/]+)/awards/?$',
|
||||
AwardsRecentFeed(), name="badger.feeds.awards_recent"),
|
||||
url(r'^feeds/(?P<format>[^/]+)/detail/(?P<slug>[^/]+)/awards/?$',
|
||||
url(r'^feeds/(?P<format>[^/]+)/badge/(?P<slug>[^/]+)/awards/?$',
|
||||
AwardsByBadgeFeed(), name="badger.feeds.awards_by_badge"),
|
||||
url(r'^feeds/(?P<format>[^/]+)/users/(?P<username>[^/]+)/awards/?$',
|
||||
AwardsByUserFeed(), name="badger.feeds.awards_by_user"),
|
||||
|
|
|
@ -48,6 +48,7 @@ MAX_RECENT = 9
|
|||
|
||||
|
||||
def home(request):
|
||||
"""Badger home page"""
|
||||
return render_to_response('badger/home.html', dict(
|
||||
badge_list=Badge.objects.order_by('-modified').all()[:MAX_RECENT],
|
||||
award_list=Award.objects.order_by('-modified').all()[:MAX_RECENT],
|
||||
|
@ -55,7 +56,7 @@ def home(request):
|
|||
|
||||
|
||||
def badges_list(request):
|
||||
"""Badger index page"""
|
||||
"""Badges list page"""
|
||||
queryset = Badge.objects.order_by('-modified').all()
|
||||
return object_list(request, queryset,
|
||||
paginate_by=BADGE_PAGE_SIZE, allow_empty=True,
|
||||
|
@ -77,7 +78,7 @@ def detail(request, slug, format="html"):
|
|||
return resp
|
||||
else:
|
||||
return render_to_response('badger/badge_detail.html', dict(
|
||||
badge=badge, awards=awards,
|
||||
badge=badge, award_list=awards,
|
||||
), context_instance=RequestContext(request))
|
||||
|
||||
|
||||
|
@ -105,10 +106,20 @@ def award_badge(request, slug):
|
|||
|
||||
|
||||
@require_GET
|
||||
def awards_list(request):
|
||||
queryset = Award.objects.order_by('-modified').all()
|
||||
def awards_list(request, slug=None):
|
||||
queryset = Award.objects
|
||||
if not slug:
|
||||
badge = None
|
||||
else:
|
||||
badge = get_object_or_404(Badge, slug=slug)
|
||||
queryset = queryset.filter(badge=badge)
|
||||
queryset = queryset.order_by('-modified').all()
|
||||
|
||||
return object_list(request, queryset,
|
||||
paginate_by=BADGE_PAGE_SIZE, allow_empty=True,
|
||||
extra_context=dict(
|
||||
badge=badge
|
||||
),
|
||||
template_object_name='award',
|
||||
template_name='badger/awards_list.html')
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче