show stats link when public (bug 690451)
This commit is contained in:
Родитель
58e90cd123
Коммит
a027e4e494
|
@ -45,7 +45,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if cnt %}
|
{% if cnt %}
|
||||||
<div id="{{ cnt_id }}">
|
<div id="{{ cnt_id }}">
|
||||||
{% if not webapp and is_author %}
|
{% if not webapp and (addon.public_stats or is_author) %}
|
||||||
<a class="stats" title="{{ _('View statistics') }}"
|
<a class="stats" title="{{ _('View statistics') }}"
|
||||||
href="{{ url('stats.overview', addon.slug) }}">{{ cnt_pretty }}</a>
|
href="{{ url('stats.overview', addon.slug) }}">{{ cnt_pretty }}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -1122,50 +1122,77 @@ class TestImpalaDetailPage(amo.tests.TestCase):
|
||||||
def get_pq(self):
|
def get_pq(self):
|
||||||
return pq(self.client.get(self.url).content)
|
return pq(self.client.get(self.url).content)
|
||||||
|
|
||||||
def test_extension_adu(self):
|
def test_adu_stats_private(self):
|
||||||
doc = self.get_pq()
|
eq_(self.addon.public_stats, False)
|
||||||
eq_(self.addon.show_adu(), True)
|
adu = self.get_pq()('#daily-users')
|
||||||
eq_(doc('#weekly-downloads').length, 0)
|
eq_(adu.length, 1)
|
||||||
|
|
||||||
adu = doc('#daily-users')
|
|
||||||
|
|
||||||
# Check that ADU does not link to statistics dashboard.
|
|
||||||
eq_(adu.find('a').length, 0)
|
eq_(adu.find('a').length, 0)
|
||||||
|
|
||||||
|
def test_adu_stats_public(self):
|
||||||
|
self.addon.update(public_stats=True)
|
||||||
|
eq_(self.addon.show_adu(), True)
|
||||||
|
adu = self.get_pq()('#daily-users')
|
||||||
|
|
||||||
|
# Check that ADU does link to public statistics dashboard.
|
||||||
|
eq_(adu.find('a').attr('href'),
|
||||||
|
reverse('stats.overview', args=[self.addon.slug]))
|
||||||
|
|
||||||
# Check formatted count.
|
# Check formatted count.
|
||||||
eq_(adu.text().split()[0], numberfmt(self.addon.average_daily_users))
|
eq_(adu.text().split()[0], numberfmt(self.addon.average_daily_users))
|
||||||
|
|
||||||
# Check if we hide when no ADU.
|
# Check if we hide link when there are no ADU.
|
||||||
self.addon.update(average_daily_users=0)
|
self.addon.update(average_daily_users=0)
|
||||||
eq_(self.get_pq()('#daily-users').length, 0)
|
eq_(self.get_pq()('#daily-users').length, 0)
|
||||||
|
|
||||||
def test_extension_stats(self):
|
def test_adu_stats_regular(self):
|
||||||
|
self.client.login(username='regular@mozilla.com', password='password')
|
||||||
|
# Should not be a link to statistics dashboard for regular users.
|
||||||
|
adu = self.get_pq()('#daily-users')
|
||||||
|
eq_(adu.length, 1)
|
||||||
|
eq_(adu.find('a').length, 0)
|
||||||
|
|
||||||
|
def test_adu_stats_admin(self):
|
||||||
self.client.login(username='del@icio.us', password='password')
|
self.client.login(username='del@icio.us', password='password')
|
||||||
# Check link to statistics dashboard for add-on authors.
|
# Check link to statistics dashboard for add-on authors.
|
||||||
eq_(self.get_pq()('#daily-users a.stats').attr('href'),
|
eq_(self.get_pq()('#daily-users a.stats').attr('href'),
|
||||||
reverse('stats.overview', args=[self.addon.slug]))
|
reverse('stats.overview', args=[self.addon.slug]))
|
||||||
|
|
||||||
def test_search_tool_downloads(self):
|
def test_downloads_stats_private(self):
|
||||||
self.addon.update(type=amo.ADDON_SEARCH)
|
self.addon.update(type=amo.ADDON_SEARCH)
|
||||||
doc = self.get_pq()
|
eq_(self.addon.public_stats, False)
|
||||||
|
adu = self.get_pq()('#weekly-downloads')
|
||||||
|
eq_(adu.length, 1)
|
||||||
|
eq_(adu.find('a').length, 0)
|
||||||
|
|
||||||
|
def test_downloads_stats_public(self):
|
||||||
|
self.addon.update(public_stats=True, type=amo.ADDON_SEARCH)
|
||||||
eq_(self.addon.show_adu(), False)
|
eq_(self.addon.show_adu(), False)
|
||||||
eq_(doc('#daily-users').length, 0)
|
dls = self.get_pq()('#weekly-downloads')
|
||||||
|
|
||||||
# Check that weekly downloads links to statistics dashboard.
|
# Check that weekly downloads links to statistics dashboard.
|
||||||
dls = doc('#weekly-downloads')
|
eq_(dls.find('a').attr('href'),
|
||||||
eq_(dls.find('a').length, 0)
|
reverse('stats.overview', args=[self.addon.slug]))
|
||||||
|
|
||||||
# Check formatted count.
|
# Check formatted count.
|
||||||
eq_(dls.text().split()[0], numberfmt(self.addon.weekly_downloads))
|
eq_(dls.text().split()[0], numberfmt(self.addon.weekly_downloads))
|
||||||
|
|
||||||
# Check if we hide when no weekly downloads.
|
# Check if we hide link when there are no weekly downloads.
|
||||||
self.addon.update(weekly_downloads=0)
|
self.addon.update(weekly_downloads=0)
|
||||||
eq_(self.get_pq()('#weekly-downloads').length, 0)
|
eq_(self.get_pq()('#weekly-downloads').length, 0)
|
||||||
|
|
||||||
def test_search_tool_stats(self):
|
def test_downloads_stats_regular(self):
|
||||||
|
self.addon.update(type=amo.ADDON_SEARCH)
|
||||||
|
self.client.login(username='regular@mozilla.com', password='password')
|
||||||
|
# Should not be a link to statistics dashboard for regular users.
|
||||||
|
dls = self.get_pq()('#weekly-downloads')
|
||||||
|
eq_(dls.length, 1)
|
||||||
|
eq_(dls.find('a').length, 0)
|
||||||
|
|
||||||
|
def test_downloads_stats_admin(self):
|
||||||
|
self.addon.update(public_stats=True, type=amo.ADDON_SEARCH)
|
||||||
self.client.login(username='del@icio.us', password='password')
|
self.client.login(username='del@icio.us', password='password')
|
||||||
# Check link to statistics dashboard for add-on authors.
|
# Check link to statistics dashboard for add-on authors.
|
||||||
eq_(self.get_pq()('#daily-users a.stats').attr('href'),
|
eq_(self.get_pq()('#weekly-downloads a.stats').attr('href'),
|
||||||
reverse('stats.overview', args=[self.addon.slug]))
|
reverse('stats.overview', args=[self.addon.slug]))
|
||||||
|
|
||||||
def test_perf_warning(self):
|
def test_perf_warning(self):
|
||||||
|
|
Загрузка…
Ссылка в новой задаче