Revert "migrate tag/:tag_name bug(581141)"
This reverts commit cddf05a211
.
This commit is contained in:
Родитель
b6fb9fde9f
Коммит
cf29770e12
|
@ -417,7 +417,9 @@ class Addon(amo.models.ModelBase):
|
|||
@amo.cached_property
|
||||
def tags_partitioned_by_developer(self):
|
||||
"Returns a tuple of developer tags and user tags for this addon."
|
||||
tags = self.tags.not_blacklisted()
|
||||
# TODO(davedash): We can't cache these tags until /tags/ are moved
|
||||
# into Zamboni.
|
||||
tags = self.tags.not_blacklisted().no_cache()
|
||||
if self.is_persona:
|
||||
return models.query.EmptyQuerySet(), tags
|
||||
user_tags = tags.exclude(addon_tags__user__in=self.listed_authors)
|
||||
|
|
|
@ -45,13 +45,9 @@ def url(viewname, *args, **kwargs):
|
|||
return urlresolvers.reverse(viewname, args=args, kwargs=kwargs)
|
||||
|
||||
|
||||
@register.function
|
||||
@register.filter
|
||||
def paginator(pager, render=True):
|
||||
if render:
|
||||
return Paginator(pager).render()
|
||||
else:
|
||||
return Paginator(pager)
|
||||
def paginator(pager):
|
||||
return Paginator(pager).render()
|
||||
|
||||
|
||||
@register.function
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
{% extends "browse/base_listing.html" %}
|
||||
|
||||
{% block title %}
|
||||
{% if not tag %}
|
||||
{{ page_title(_('Tag not found :: Tag')) }}
|
||||
{% else %}
|
||||
{# L10n: {0} is the name of the tag #}
|
||||
{{ page_title(_('{0} :: Tag')|f(tag.tag_text)) }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if not tag %}
|
||||
<header>
|
||||
{{ breadcrumbs([(None, _('Tags'))]) }}
|
||||
</header>
|
||||
<div class="featured listing no-results">
|
||||
<div class="featured-inner">
|
||||
<p class="addon-search-message">{{ _('No results found.') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<header>
|
||||
{{ breadcrumbs([(None, _('Tags'))]) }}
|
||||
{% set paginator = paginator(addons, render=False) %}
|
||||
<hgroup>
|
||||
<h2>{{ tag.tag_text }}</h2>
|
||||
<h3>
|
||||
{% trans begin=paginator.pager.start_index(), end=paginator.pager.end_index(),
|
||||
count=addons.paginator.count|numberfmt, tag_name=tag.tag_text %}
|
||||
Showing {{ begin }} - {{ end }} of {{ count }} results tagged with <strong>{{ tag_name }}</strong>
|
||||
{% endtrans %}
|
||||
</h3>
|
||||
</hgroup>
|
||||
</header>
|
||||
|
||||
<div class="featured listing">
|
||||
<div class="featured-inner">
|
||||
{% set url_base = url('browse.tag', tag.tag_text) %}
|
||||
{{ addon_listing_header(url_base, sort_opts, sorting, unreviewed) }}
|
||||
{{ addon_listing_items(addons.object_list,
|
||||
show_added_date=(sorting=='created')) }}
|
||||
<div class="listing-footer">
|
||||
{{ paginator.render() }}
|
||||
</div>
|
||||
</div> {# featured-inner #}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
|
@ -12,8 +12,6 @@ urlpatterns = patterns('',
|
|||
url('^themes/(?P<category>[^/]+)?$', views.themes,
|
||||
name='browse.themes'),
|
||||
|
||||
url('^tag/(?P<tag_name>.+)$', views.tag, name='browse.tag'),
|
||||
|
||||
url('^extensions/(?:(?P<category>[^/]+)/)?$', views.extensions,
|
||||
name='browse.extensions'),
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import product_details
|
|||
|
||||
import amo.utils
|
||||
from addons.models import Addon, Category
|
||||
from tags.models import Tag
|
||||
from amo.urlresolvers import reverse
|
||||
from addons.views import BaseFilter
|
||||
from translations.query import order_by_translation
|
||||
|
@ -108,27 +107,6 @@ class AddonFilter(BaseFilter):
|
|||
('rating', _lazy(u'Rating')))
|
||||
|
||||
|
||||
def tag(request, tag_name):
|
||||
|
||||
TYPE = amo.ADDON_EXTENSION
|
||||
addons = unreviewed = filter = None
|
||||
|
||||
tag = Tag.objects.filter(tag_text=tag_name)
|
||||
if tag:
|
||||
tag = tag.get()
|
||||
addons, filter, unreviewed = _listing(request, TYPE, tag=tag)
|
||||
addons = addons.filter(addon_tags__tag__id=tag.id)
|
||||
count = addons.with_index(addons='type_status_inactive_idx').count()
|
||||
addons = amo.utils.paginate(request, addons, count=count)
|
||||
|
||||
return jingo.render(request, 'browse/tag.html',
|
||||
{'tag': tag,
|
||||
'addons': addons,
|
||||
'unreviewed': unreviewed,
|
||||
'sorting': filter.field if filter else None,
|
||||
'sort_opts': filter.opts if filter else None})
|
||||
|
||||
|
||||
def themes(request, category=None):
|
||||
q = Category.objects.filter(application=request.APP.id,
|
||||
type=amo.ADDON_THEME)
|
||||
|
@ -158,7 +136,7 @@ def themes(request, category=None):
|
|||
'search_cat': search_cat})
|
||||
|
||||
|
||||
def _listing(request, addon_type, default='popular', tag=None):
|
||||
def _listing(request, addon_type, default='popular'):
|
||||
# Set up the queryset and filtering for themes & extension listing pages.
|
||||
status = [amo.STATUS_PUBLIC]
|
||||
|
||||
|
@ -170,12 +148,7 @@ def _listing(request, addon_type, default='popular', tag=None):
|
|||
if unreviewed:
|
||||
status.append(amo.STATUS_UNREVIEWED)
|
||||
|
||||
if tag is not None:
|
||||
qs = Addon.objects.listed(request.APP,
|
||||
*status).filter(type=addon_type,
|
||||
addon_tags__tag__id=tag.id)
|
||||
else:
|
||||
qs = Addon.objects.listed(request.APP, *status).filter(type=addon_type)
|
||||
qs = Addon.objects.listed(request.APP, *status).filter(type=addon_type)
|
||||
filter = AddonFilter(request, qs, 'sort', default)
|
||||
return filter.qs, filter, unreviewed
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче