Skip to content

Commit

Permalink
collection user pages (bug 588214)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Balogh committed Aug 19, 2010
1 parent 1282b34 commit a4b487e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
17 changes: 13 additions & 4 deletions apps/bandwagon/templates/bandwagon/collection_listing.html
Expand Up @@ -6,7 +6,11 @@
'rating': _('Highest Rated Collections'),
'created': _('Recently Added Collections'),
} %}
{% set base_url = url('collections.list') %}
{% if userpage %}
{% set base_url = url('collections.user', userpage) %}
{% else %}
{% set base_url = url('collections.list') %}
{% endif %}

{% block title %}{{ page_title(titles[filter.field]) }}{% endblock %}

Expand All @@ -15,8 +19,12 @@
{% block content %}
<div class="primary">
<header>
{{ breadcrumbs([(base_url, _('Collections')),
(None, filter.title)]) }}
{% set crumbs = [(url('collections.list'), _('Collections')),
(None, filter.title)] %}
{% if userpage %}
{% do crumbs.insert(1, (url('collections.user', userpage), userpage)) %}
{% endif %}
{{ breadcrumbs(crumbs) }}
<h2>{{ titles[filter.field] }}</h2>
</header>
<div class="featured listing">
Expand All @@ -42,7 +50,8 @@ <h3>{{ _('Collections') }}</h3>
</ul>
{% if request.user.is_authenticated() %}
<ul>
<li><a href="#TODO-MINE">{{ _("Collections I've Made") }}</a></li>
<li><a href="{{ url('collections.user', amo_user.username) }}">
{{ _("Collections I've Made") }}</a></li>
<li><a href="{{ url('collections.detail', amo_user.username, 'favorites') }}">
{{ _("My Favorite Add-ons") }}</a></li>
</ul>
Expand Down
16 changes: 11 additions & 5 deletions apps/bandwagon/views.py
Expand Up @@ -93,15 +93,17 @@ def filter(self, field):
return qs.order_by('-created')


def collection_listing(request):
def collection_listing(request, base=None, extra={}):
if base is None:
base = Collection.objects.listed()
app = Q(application=request.APP.id) | Q(application=None)
base = Collection.objects.listed().filter(app)
base = base.filter(app)
filter = CollectionFilter(request, base, key='sort', default='popular')
collections = amo.utils.paginate(request, filter.qs)
votes = get_votes(request, collections.object_list)
return jingo.render(request, 'bandwagon/collection_listing.html',
{'collections': collections, 'filter': filter,
'collection_votes': votes})
dict(collections=collections, filter=filter,
collection_votes=votes, **extra))


def get_votes(request, collections):
Expand All @@ -113,7 +115,11 @@ def get_votes(request, collections):


def user_listing(request, username):
return http.HttpResponse()
qs = Collection.objects.filter(author__username=username)
if not (request.user.is_authenticated() and
request.amo_user.username == username):
qs = qs.filter(listed=True)
return collection_listing(request, qs, extra={'userpage': username})


class CollectionAddonFilter(BaseFilter):
Expand Down

0 comments on commit a4b487e

Please sign in to comment.