diff --git a/apps/addons/templates/addons/home.html b/apps/addons/templates/addons/home.html new file mode 100644 index 0000000000..3bf69af16b --- /dev/null +++ b/apps/addons/templates/addons/home.html @@ -0,0 +1,20 @@ +{% extends "base_side_categories.html" %} + +{% block site_stats %} + +{% endblock %} diff --git a/apps/addons/urls.py b/apps/addons/urls.py index 6b5eec5073..eafd75c199 100644 --- a/apps/addons/urls.py +++ b/apps/addons/urls.py @@ -13,6 +13,9 @@ detail_patterns = patterns('', urlpatterns = patterns('', + # The homepage. + url('^$', views.home, name='home'), + # URLs for a single add-on. ('^addon/(?P\d+)/', include(detail_patterns)), ) diff --git a/apps/addons/views.py b/apps/addons/views.py index db1b24116c..da8c01c502 100644 --- a/apps/addons/views.py +++ b/apps/addons/views.py @@ -1,6 +1,19 @@ from django import http +import jingo + +from stats.models import GlobalStat + # pylint: disable-msg: W0613 def addon_detail(request, addon_id): return http.HttpResponse('this is addon %s' % addon_id) + + +def home(request): + gs = GlobalStat.objects + downloads = gs.filter(name='addon_total_downloads').latest() + pings = gs.filter(name='addon_total_updatepings').latest() + + return jingo.render(request, 'addons/home.html', + {'downloads': downloads, 'pings': pings}) diff --git a/apps/amo/tests/test_redirects.py b/apps/amo/tests/test_redirects.py index cf4df40492..0d3c96b77e 100644 --- a/apps/amo/tests/test_redirects.py +++ b/apps/amo/tests/test_redirects.py @@ -4,7 +4,7 @@ from django import test class TestRedirects(test.TestCase): - fixtures = ['amo/test_redirects'] + fixtures = ['amo/test_redirects', 'base/global-stats'] def test_reviews(self): response = self.client.get('/reviews/display/4', follow=True) diff --git a/apps/amo/tests/test_views.py b/apps/amo/tests/test_views.py index e81842414e..50e5373bec 100644 --- a/apps/amo/tests/test_views.py +++ b/apps/amo/tests/test_views.py @@ -14,20 +14,8 @@ def test_404_no_app(): eq_(response.status_code, 404) -def test_heading(): - c = test.Client() - def title_eq(url, expected): - response = c.get(url, follow=True) - actual = PyQuery(response.content)('#title').text() - eq_(expected, actual) - - title_eq('/firefox', 'Add-ons for Firefox') - title_eq('/thunderbird', 'Add-ons for Thunderbird') - title_eq('/mobile', 'Mobile Add-ons for Firefox') - - class TestStuff(test_utils.TestCase): - fixtures = ['base/addons'] + fixtures = ['base/addons', 'base/global-stats'] def test_data_anonymous(self): def check(expected): @@ -50,3 +38,13 @@ class TestStuff(test_utils.TestCase): check(0) self.client.login(username='admin@mozilla.com', password='password') check(1) + + def test_heading(self): + def title_eq(url, expected): + response = self.client.get(url, follow=True) + actual = PyQuery(response.content)('#title').text() + eq_(expected, actual) + + title_eq('/firefox', 'Add-ons for Firefox') + title_eq('/thunderbird', 'Add-ons for Thunderbird') + title_eq('/mobile', 'Mobile Add-ons for Firefox') diff --git a/apps/cake/tests.py b/apps/cake/tests.py index e7f48adab7..b315a43df1 100644 --- a/apps/cake/tests.py +++ b/apps/cake/tests.py @@ -9,7 +9,7 @@ from cake.backends import SessionBackend class CakeTestCase(TestCase): - fixtures = ['cake/sessions.json'] + fixtures = ['cake/sessions.json', 'base/global-stats'] def test_login(self): """ diff --git a/templates/base.html b/templates/base.html index b3ecfe8493..6ed6b93603 100644 --- a/templates/base.html +++ b/templates/base.html @@ -34,7 +34,7 @@ {{ _('Mozilla') }}

- + {% block site_stats %}{% endblock %}