porting /versions page (bug 565479)
This commit is contained in:
Родитель
c516e4bf53
Коммит
c597d571c8
|
@ -180,62 +180,7 @@
|
|||
|
||||
{% if not addon.is_selfhosted() and version %}
|
||||
<h3 id="releasenotes">{{ _('Release Notes', 'addons_display_release_notes') }}</h3>
|
||||
<div class="article">
|
||||
{# TODO reverse URL #}
|
||||
{% set base = remora_url('/addons/versions/{0}'|f(addon.id)) %}
|
||||
<p><a href="{{ base }}#version-{{ version.version }}"
|
||||
title="{{ _('Permanent link to this version') }}">
|
||||
{{ _('Version {0}', 'addon_display_header_version')|f(version.version) }}</a>
|
||||
—
|
||||
<span title="{{ version.created|isotime }}">{{
|
||||
version.created|datetime }}</span>
|
||||
{% if version.has_files %}
|
||||
—
|
||||
{{ _('{0} KB')|f(version.all_files[0].size|int|numberfmt) }}
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
<div class="prose userinput">
|
||||
<p id="release-notes"{{ version.releasenotes|locale_html }}>
|
||||
{{ version.releasenotes|nl2br }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{# License #}
|
||||
{% if version.license %}
|
||||
<h5 id="license">
|
||||
{{ _('Source Code License') }}
|
||||
{# TODO reverse URL #}
|
||||
<a href="{{ remora_url('/pages/developer_faq#license') }}">
|
||||
{{ _("What's this?", 'addons_display_a_license_what') }}
|
||||
</a>
|
||||
</h5>
|
||||
{# TODO reverse URL #}
|
||||
<p>
|
||||
<a href="{{ remora_url('/versions/license/{0}'|f(version.id)) }}">
|
||||
{{ version.license.name }}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<ul class="further-navigation">
|
||||
{% if addon.view_source and user.is_authenticated() and
|
||||
version.has_files %}
|
||||
<li>
|
||||
{# TODO reverse URL #}
|
||||
<a href="{{ remora_url('/files/browse/{0}'|f(version.all_files[0].pk)) }}">
|
||||
{{ _('View the source') }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if not addon.is_selfhosted() %}
|
||||
<li>
|
||||
{# TODO reverse URL #}
|
||||
<a href="{{ remora_url('/addons/versions/{0}'|f(addon.id)) }}">
|
||||
{{ _('View All Versions') }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div> <!-- Release Notes -->
|
||||
{{ version_detail(addon, version, src="addon-detail-version") }}
|
||||
{% endif %}
|
||||
|
||||
</div>{# /primary #}
|
||||
|
|
|
@ -23,6 +23,7 @@ detail_patterns = patterns('',
|
|||
|
||||
('^reviews/', include('reviews.urls')),
|
||||
('^statistics/', include('stats.urls')),
|
||||
('^versions/', include('versions.urls')),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -156,3 +156,8 @@ class TestRedirects(test.TestCase):
|
|||
url, code = r.redirect_chain[-1]
|
||||
eq_(code, 301)
|
||||
assert url.endswith('/en-US/firefox/extensions/woo/?sort=rating')
|
||||
|
||||
def test_addons_versions(self):
|
||||
r = self.client.get('/addons/versions/4', follow=True)
|
||||
self.assertRedirects(r, '/en-US/firefox/addon/4/versions/',
|
||||
status_code=301)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import jingo
|
||||
import jinja2
|
||||
|
||||
from addons.helpers import new_context
|
||||
|
||||
|
||||
@jingo.register.inclusion_tag('versions/version.html')
|
||||
@jinja2.contextfunction
|
||||
def version_detail(context, addon, version, src,
|
||||
show_versions_link=True, itemclass='article'):
|
||||
return new_context(**locals())
|
|
@ -0,0 +1,61 @@
|
|||
{# addon, version, request #}
|
||||
<div class="version {{ itemclass }}">
|
||||
{% set versions_url = url('addons.versions', addon.id) %}
|
||||
<h4><a href="{{ versions_url }}#version-{{ version.version }}"
|
||||
title="{{ _('Permanent link to this version') }}">
|
||||
{{ _('Version {0}', 'addon_display_header_version')|f(version.version) }}</a>
|
||||
—
|
||||
<span title="{{ version.created|isotime }}">{{
|
||||
version.created|datetime }}</span>
|
||||
{% if version.has_files %}
|
||||
—
|
||||
<span>{{ _('{0} KB')|f(version.all_files[0].size|int|numberfmt) }}</span>
|
||||
{% endif %}
|
||||
</h4>
|
||||
|
||||
{{ install_button(addon, version=version) }}
|
||||
|
||||
{% if addon.compatible_apps %}
|
||||
<h5>{{ _('Works with:') }}</h5>
|
||||
<ul>
|
||||
{% for compat in addon.compatible_apps.values() %}
|
||||
<li>{{ compat }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
<div class="prose userinput" {{ version.releasenotes|locale_html }}>
|
||||
{{ version.releasenotes|nl2br }}
|
||||
</div>
|
||||
|
||||
{# License #}
|
||||
{% if version.license %}
|
||||
<h5>
|
||||
{{ _('Source Code License') }}
|
||||
{# TODO reverse URL #}
|
||||
<a href="{{ remora_url('/pages/developer_faq#license') }}">
|
||||
{{ _("What's this?", 'addons_display_a_license_what') }}
|
||||
</a>
|
||||
</h5>
|
||||
{# TODO reverse URL #}
|
||||
<a href="{{ remora_url('/versions/license/{0}'|f(version.id)) }}">
|
||||
{{ version.license.name }}</a>
|
||||
{% endif %}
|
||||
|
||||
<ul class="further-navigation">
|
||||
{% if addon.view_source and request.user.is_authenticated() and version.has_files %}
|
||||
<li>
|
||||
{# TODO reverse URL #}
|
||||
<a href="{{ remora_url('/files/browse/{0}'|f(version.all_files[0].pk)) }}">
|
||||
{{ _('View the source') }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if show_versions_link and not addon.is_selfhosted() %}
|
||||
<li>
|
||||
<a href="{{ version_url }}">
|
||||
{{ _('View All Versions') }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,42 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{# L10n: {0} is an add-on name. #}
|
||||
{% block title %}{{ page_title('{0} :: Versions')|f(addon.name) }}{% endblock %}
|
||||
|
||||
{% block bodyclass %}versions inverse{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="primary">
|
||||
<header>
|
||||
{{ breadcrumbs([(addon.type_url(), amo.ADDON_TYPES[addon.type]),
|
||||
(url('addons.detail', addon.id), addon.name),
|
||||
(None, _('Versions'))]) }}
|
||||
{# L10n: {0} is an add-on name. #}
|
||||
<hgroup>
|
||||
<h2>{{ _('{0} Version History')|f(addon.name) }}</h2>
|
||||
{% with cnt=versions.paginator.count %}
|
||||
{# L10n: {0} is a number. #}
|
||||
<h3>{{ ngettext('{0} Version', '{0} Versions', cnt)|f(cnt) }}</h3>
|
||||
{% endwith %}
|
||||
</hgroup>
|
||||
</header>
|
||||
<div class="warning">
|
||||
<strong>{{ _('Be careful with old versions!') }}</strong>
|
||||
<p>{% trans url=url('addons.detail', addon.id) %}
|
||||
These versions are displayed for reference and testing purposes.
|
||||
You should always use the <a href="{{ url }}">latest version</a> of an add-on.
|
||||
{% endtrans %}</p>
|
||||
</div>
|
||||
<div class="featured listing">
|
||||
<div class="featured-inner">
|
||||
{% for version in versions.object_list %}
|
||||
{{ version_detail(addon, version, show_versions_link=False,
|
||||
src="version-history", itemclass="item") }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="listing-footer">
|
||||
{{ versions|paginator }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -0,0 +1,7 @@
|
|||
from django.conf.urls.defaults import patterns, url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url('^$', views.versions_list, name='addons.versions'),
|
||||
)
|
|
@ -0,0 +1,18 @@
|
|||
from django.shortcuts import get_object_or_404
|
||||
|
||||
import jingo
|
||||
|
||||
import amo
|
||||
from addons.models import Addon
|
||||
from versions.models import Version
|
||||
|
||||
|
||||
def versions_list(request, addon_id):
|
||||
addon = get_object_or_404(Addon.objects.valid(), pk=addon_id)
|
||||
qs = (addon.versions.filter(files__status__in=amo.VALID_STATUSES)
|
||||
.distinct().order_by('-created'))
|
||||
versions = amo.utils.paginate(request, qs)
|
||||
versions.object_list = list(versions.object_list)
|
||||
Version.transformer(versions.object_list)
|
||||
return jingo.render(request, 'versions/version_list.html',
|
||||
{'addon': addon, 'versions': versions})
|
3
urls.py
3
urls.py
|
@ -71,6 +71,9 @@ urlpatterns = patterns('',
|
|||
('^personas/film and tv/?$',
|
||||
lambda r: redirect('browse.personas', 'film-and-tv', permanent=True)),
|
||||
|
||||
('^addons/versions/(\d+)/?$',
|
||||
lambda r, id: redirect('addons.versions', id, permanent=True)),
|
||||
|
||||
# Firefox Cup page, /firefoxcup
|
||||
('^firefoxcup/', include('firefoxcup.urls'))
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче