collections directory (bug 574292)
This commit is contained in:
Родитель
75c9dee1bc
Коммит
ac8298b3e5
|
@ -8,6 +8,14 @@ from amo.helpers import login_link
|
||||||
from cake.urlresolvers import remora_url
|
from cake.urlresolvers import remora_url
|
||||||
|
|
||||||
|
|
||||||
|
@register.inclusion_tag('bandwagon/collection_listing_items.html')
|
||||||
|
@jinja2.contextfunction
|
||||||
|
def collection_listing_items(context, collections):
|
||||||
|
c = dict(context.items())
|
||||||
|
c['collections'] = collections
|
||||||
|
return c
|
||||||
|
|
||||||
|
|
||||||
@register.function
|
@register.function
|
||||||
def user_collection_list(collections=[], heading=''):
|
def user_collection_list(collections=[], heading=''):
|
||||||
"""list of collections, as used on the user profile page"""
|
"""list of collections, as used on the user profile page"""
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% set titles = {
|
||||||
|
'featured': _('Featured Collections'),
|
||||||
|
'popular': _('Popular Collections'),
|
||||||
|
'rating': _('Highest Rated Collections'),
|
||||||
|
'created': _('Recently Added Collections'),
|
||||||
|
} %}
|
||||||
|
{% set base_url = url('collections.list') %}
|
||||||
|
|
||||||
|
{% block title %}{{ page_title(titles[filter.field]) }}{% endblock %}
|
||||||
|
|
||||||
|
{% block extrahead %}{{ category_arrow(filter.field, prefix='p') }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="primary">
|
||||||
|
<header>
|
||||||
|
{{ breadcrumbs([(base_url, _('Collections')),
|
||||||
|
(None, filter.title)]) }}
|
||||||
|
<h2>{{ titles[filter.field] }}</h2>
|
||||||
|
</header>
|
||||||
|
<div class="featured listing">
|
||||||
|
{{ addon_listing_header(base_url, filter.opts, filter.field,
|
||||||
|
show_unreviewed=False) }}
|
||||||
|
<div class="featured-inner">
|
||||||
|
{% cache collections.object_list %}
|
||||||
|
{{ collection_listing_items(collections.object_list) }}
|
||||||
|
{% endcache %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="secondary">
|
||||||
|
<div class="other-categories highlight">
|
||||||
|
<h3>{{ _('Collections') }}</h3>
|
||||||
|
<ul>
|
||||||
|
{% for key, title in filter.opts %}
|
||||||
|
<li id="p-{{ key }}">
|
||||||
|
<a href="{{ base_url|urlparams(sort=key) }}">{{ title }}</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% if request.user.is_authenticated() %}
|
||||||
|
<ul>
|
||||||
|
<li><a href="#TODO-WATCHING">{{ _("Collections I'm Watching") }}</a></li>
|
||||||
|
<li><a href="#TODO-MINE">{{ _("Collections I've Made") }}</a></li>
|
||||||
|
<li><a href="#TODO-FAV">{{ _("My Favorite Add-ons") }}</a></li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3>{{ _('Create a New Collection') }}</h3>
|
||||||
|
<p>{% trans %}
|
||||||
|
Collections make it easy to keep track of favorite add-ons and share your
|
||||||
|
perfectly customized browser with others.
|
||||||
|
{% endtrans %}</p>
|
||||||
|
<a href="{{ url('collections.add') }}" class="button">
|
||||||
|
{{ _('Create a Collection') }}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3>{{ _('Add-on Collector') }}</h3>
|
||||||
|
<p>{% trans app=request.APP.pretty %}
|
||||||
|
Get updates on watched collections or manage your own collections directly
|
||||||
|
from {{ app }} with this add-on.
|
||||||
|
{% endtrans %}</p>
|
||||||
|
<a href="{{ remora_url('/pages/collector') }}" class="more-info">
|
||||||
|
{{ _('Check out Add-on Collector') }}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,29 @@
|
||||||
|
{% for c in collections %}
|
||||||
|
<div class="item">
|
||||||
|
<div class="item-info">
|
||||||
|
<ul>
|
||||||
|
<li>{{ barometer(c) }}</li>
|
||||||
|
<li class="subscribers">
|
||||||
|
{# L10n: People "watch" collections to get notified of updates.
|
||||||
|
Like Twitter followers. #}
|
||||||
|
{% trans cnt=c.subscribers, num=c.subscribers|numberfmt %}
|
||||||
|
<strong>{{ num }}</strong> watcher
|
||||||
|
{% pluralize %}
|
||||||
|
<strong>{{ num }}</strong> watchers
|
||||||
|
{% endtrans %}
|
||||||
|
</li>
|
||||||
|
<li class="modified">
|
||||||
|
{{ _('Updated {0}')|f(c.modified|datetime) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<h3>
|
||||||
|
<a href="{{ c.get_url_path() }}">
|
||||||
|
<img class="icon" width="32" height="32" src="{{ c.icon_url }}">
|
||||||
|
{{ c.name }}
|
||||||
|
</a>
|
||||||
|
<span>{{ _('by {0}')|f(c.author|user_link)|safe }}</span>
|
||||||
|
</h3>
|
||||||
|
<blockquote>{{ c.description }}</blockquote>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
|
@ -1,4 +1,5 @@
|
||||||
from django import http
|
from django import http
|
||||||
|
from django.db.models import Q
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
|
|
||||||
import jingo
|
import jingo
|
||||||
|
@ -23,8 +24,31 @@ def legacy_redirect(self, uuid):
|
||||||
return redirect(c.get_url_path())
|
return redirect(c.get_url_path())
|
||||||
|
|
||||||
|
|
||||||
|
class CollectionFilter(BaseFilter):
|
||||||
|
opts = (('featured', _lazy('Featured')),
|
||||||
|
('popular', _lazy('Popular')),
|
||||||
|
('rating', _lazy('Highest Rated')),
|
||||||
|
('created', _lazy('Recently Added')))
|
||||||
|
|
||||||
|
def filter(self, field):
|
||||||
|
qs = self.base_queryset
|
||||||
|
if field == 'featured':
|
||||||
|
return qs.filter(type=amo.COLLECTION_FEATURED)
|
||||||
|
elif field == 'followers':
|
||||||
|
return qs.order_by('-weekly_subscribers')
|
||||||
|
elif field == 'rating':
|
||||||
|
return qs.order_by('-rating')
|
||||||
|
else:
|
||||||
|
return qs.order_by('-created')
|
||||||
|
|
||||||
|
|
||||||
def collection_listing(request):
|
def collection_listing(request):
|
||||||
return http.HttpResponse()
|
app = Q(application=request.APP.id) | Q(application=None)
|
||||||
|
base = Collection.objects.listed().filter(app)
|
||||||
|
filter = CollectionFilter(request, base, key='sort', default='popular')
|
||||||
|
collections = amo.utils.paginate(request, filter.qs)
|
||||||
|
return jingo.render(request, 'bandwagon/collection_listing.html',
|
||||||
|
{'collections': collections, 'filter': filter})
|
||||||
|
|
||||||
|
|
||||||
def user_listing(request, username):
|
def user_listing(request, username):
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
CREATE INDEX type_idx ON collections (collection_type);
|
||||||
|
CREATE INDEX watcher_idx ON collections (weekly_subscribers);
|
||||||
|
CREATE INDEX rating_idx ON collections (rating);
|
||||||
|
CREATE INDEX created_idx ON collections (created);
|
Загрузка…
Ссылка в новой задаче