Skip to content

Commit

Permalink
Make sure personas details page renders.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Wenzel committed Apr 16, 2010
1 parent 3c3a476 commit 4a81401
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 3 deletions.
148 changes: 148 additions & 0 deletions apps/addons/fixtures/addons/persona.json
@@ -0,0 +1,148 @@
[
{
"pk": 637432,
"model": "translations.translation",
"fields": {
"localized_string_clean": null,
"created": "2009-10-20 21:58:03",
"locale": "en-US",
"modified": null,
"id": 590130,
"localized_string": "Personas are lightweight, easy-to-install and easy-to-change \"skins\" for your Firefox web browser."
}
},
{
"pk": 637431,
"model": "translations.translation",
"fields": {
"localized_string_clean": null,
"created": "2009-10-20 21:58:03",
"locale": "en-US",
"modified": null,
"id": 590129,
"localized_string": "Personas"
}
},
{
"pk": 637430,
"model": "translations.translation",
"fields": {
"localized_string_clean": null,
"created": "2009-10-20 21:58:03",
"locale": "en-US",
"modified": null,
"id": 590128,
"localized_string": "Persona"
}
},
{
"pk": 638181,
"model": "translations.translation",
"fields": {
"localized_string_clean": "Persona Description clean",
"created": "2009-10-20 21:58:25",
"locale": "en-US",
"modified": null,
"id": 590879,
"localized_string": "Persona Description"
}
},
{
"pk": 9,
"model": "addons.addontype",
"fields": {
"description": 590130,
"name_plural": 590129,
"modified": "2009-10-20 21:58:03",
"name": 590128,
"created": "2009-10-20 21:58:03"
}
},
{
"pk": 638180,
"model": "translations.translation",
"fields": {
"localized_string_clean": null,
"created": "2009-10-20 21:58:25",
"locale": "en-US",
"modified": null,
"id": 590878,
"localized_string": "My Persona"
}
},
{
"pk": 15663,
"model": "addons.addon",
"fields": {
"dev_agreement": 0,
"eula": null,
"last_updated": "2009-03-30 23:17:40",
"view_source": 0,
"enable_thankyou": 0,
"total_downloads": 0,
"developer_comments": null,
"inactive": 0,
"average_daily_downloads": 0,
"show_beta": 1,
"the_future": null,
"trusted": 0,
"locale_disambiguation": null,
"binary": 0,
"guid": null,
"weekly_downloads": 0,
"support_url": null,
"paypal_id": "",
"average_rating": 0,
"wants_contributions": 0,
"average_daily_users": 55,
"bayesian_rating": 0.0,
"share_count": 0,
"get_satisfaction_company": null,
"homepage": null,
"support_email": null,
"public_stats": 0,
"status": 4,
"privacy_policy": null,
"description": 590879,
"default_locale": "en-US",
"target_locale": null,
"prerelease": 0,
"thankyou_note": null,
"admin_review": 0,
"external_software": 0,
"highest_status": 0,
"get_satisfaction_product": null,
"name": 590878,
"created": "2009-03-30 23:17:40",
"type": 9,
"icon_type": "",
"annoying": 0,
"modified": "2009-03-30 23:17:40",
"summary": null,
"suggested_amount": null,
"site_specific": 0,
"total_reviews": 0,
"the_reason": null,
"nomination_date": null
}
},
{
"pk": 559,
"model": "addons.persona",
"fields": {
"display_username": "My Persona",
"popularity": 0,
"license": null,
"footer": "My_Persona_footer.png",
"movers": null,
"author": "Persona Author",
"submit": "2009-03-30 20:55:48",
"accentcolor": "8d8d97",
"header": "My_Persona_header.png",
"textcolor": "ffffff",
"approve": "2009-03-30 23:17:40",
"persona_id": 813,
"addon": 15663
}
}
]
3 changes: 2 additions & 1 deletion apps/addons/models.py
Expand Up @@ -434,7 +434,8 @@ def json_data(self):
'name': unicode(addon.name),
'accentcolor': hexcolor(self.accentcolor),
'textcolor': hexcolor(self.textcolor),
'category': unicode(addon.categories.all()[0].name),
'category': (unicode(addon.categories.all()[0].name) if
addon.categories.all() else ''),
'author': (addon.listed_authors[0].display_name if
addon.listed_authors else self.author),
'description': unicode(addon.description),
Expand Down
9 changes: 8 additions & 1 deletion apps/addons/tests/test_views.py
Expand Up @@ -50,7 +50,7 @@ def test_filter_opts(self):


class TestDetailPage(test_utils.TestCase):
fixtures = ['base/addons', 'addons/listed']
fixtures = ['base/addons', 'addons/listed', 'addons/persona']

def tearDown(self):
"""Return URL prefixer to default."""
Expand All @@ -59,11 +59,18 @@ def tearDown(self):

def test_anonymous_user(self):
"""Does the page work for an anonymous user?"""
# extensions
response = self.client.get(reverse('addons.detail', args=[3615]),
follow=True)
eq_(response.status_code, 200)
eq_(response.context['addon'].id, 3615)

# personas
response = self.client.get(reverse('addons.detail', args=[15663]),
follow=True)
eq_(response.status_code, 200)
eq_(response.context['addon'].id, 15663)

def test_inactive_addon(self):
"""Do not display disabled add-ons."""
myaddon = Addon.objects.get(id=3615)
Expand Down
4 changes: 3 additions & 1 deletion apps/addons/views.py
Expand Up @@ -34,10 +34,12 @@ def addon_detail(request, addon_id):
"""Add-ons details page dispatcher."""
addon = get_object_or_404(Addon.objects.valid(), id=addon_id)
# addon needs to have a version and be valid for this app.
if addon.current_version and addon.type_id in request.APP.types:
if addon.type_id in request.APP.types:
if addon.type_id == amo.ADDON_PERSONA:
return persona_detail(request, addon)
else:
if not addon.current_version:
raise http.Http404
return extension_detail(request, addon)
else:
raise http.Http404
Expand Down

0 comments on commit 4a81401

Please sign in to comment.