show stats dashboard link only for add-on authors (bug 690451)

This commit is contained in:
Chris Van 2011-12-15 15:30:20 -08:00
Родитель 0381eeb91f
Коммит 6579c0cf5b
2 изменённых файлов: 27 добавлений и 11 удалений

Просмотреть файл

@ -1,4 +1,5 @@
{% extends "impala/base_shared.html" %}
{% set is_author = request.check_ownership(addon, require_owner=False) %}
{% block title %}{{ page_title(addon.name) }}{% endblock %}
{% block js %}{% include("amo/recaptcha_js.html") %}{% endblock %}
@ -44,11 +45,11 @@
{% endif %}
{% if cnt %}
<div id="{{ cnt_id }}">
{% if webapp %}
{{ cnt_pretty }}
{% else %}
{% if not webapp and is_author %}
<a class="stats" title="{{ _('View statistics') }}"
href="{{ url('stats.overview', addon.slug) }}">{{ cnt_pretty }}</a>
{% else %}
{{ cnt_pretty }}
{% endif %}
</div>
{% endif %}
@ -60,7 +61,7 @@
{{ sharing_widget(addon) }}
{% endif %}
</div>
{% if request.check_ownership(addon, require_owner=False) %}
{% if is_author %}
<p><a href="{{ addon.get_dev_url() }}" class="button developer prominent"><span>{{ _('Manage') }}</span></a></p>
{% if waffle.switch('marketplace') and addon.is_premium() and not addon.is_webapp() %}
<p><a href="{{ url('downloads.latest', addon.slug) }}" class="button developer prominent"><span>{{ _('Download') }}</span></a></p>

Просмотреть файл

@ -1127,10 +1127,10 @@ class TestImpalaDetailPage(amo.tests.TestCase):
eq_(self.addon.show_adu(), True)
eq_(doc('#weekly-downloads').length, 0)
# Check that ADU links to statistics dashboard.
adu = doc('#daily-users a')
eq_(adu.attr('href'),
reverse('stats.overview', args=[self.addon.slug]))
adu = doc('#daily-users')
# Check that ADU does not link to statistics dashboard.
eq_(adu.find('a').length, 0)
# Check formatted count.
eq_(adu.text().split()[0], numberfmt(self.addon.average_daily_users))
@ -1139,16 +1139,25 @@ class TestImpalaDetailPage(amo.tests.TestCase):
self.addon.update(average_daily_users=0)
eq_(self.get_pq()('#daily-users').length, 0)
def test_extension_stats(self):
self.client.login(username='del@icio.us', password='password')
# Check link to statistics dashboard for add-on authors.
eq_(self.get_pq()('#daily-users a.stats').attr('href'),
reverse('stats.overview', args=[self.addon.slug]))
def test_search_tool_downloads(self):
self.addon.update(type=amo.ADDON_SEARCH)
doc = self.get_pq()
eq_(self.addon.show_adu(), False)
eq_(doc('#daily-users').length, 0)
adu = doc('#daily-users')
# Check that ADU does not link to statistics dashboard.
eq_(adu.find('a').length, 0)
# Check that weekly downloads links to statistics dashboard.
dls = doc('#weekly-downloads a')
eq_(dls.attr('href'),
reverse('stats.overview', args=[self.addon.slug]))
dls = doc('#weekly-downloads')
# Check formatted count.
eq_(dls.text().split()[0], numberfmt(self.addon.weekly_downloads))
@ -1157,6 +1166,12 @@ class TestImpalaDetailPage(amo.tests.TestCase):
self.addon.update(weekly_downloads=0)
eq_(self.get_pq()('#weekly-downloads').length, 0)
def test_search_tool_stats(self):
self.client.login(username='del@icio.us', password='password')
# Check link to statistics dashboard for add-on authors.
eq_(self.get_pq()('#daily-users a.stats').attr('href'),
reverse('stats.overview', args=[self.addon.slug]))
def test_perf_warning(self):
eq_(self.addon.ts_slowness, None)
eq_(self.get_pq()('.performance-note').length, 0)