From 176c18a69279afb31c44991024722951efec48ef Mon Sep 17 00:00:00 2001 From: Chris Van Date: Tue, 13 Mar 2012 18:40:42 -0700 Subject: [PATCH] clean up webapps crap --- apps/addons/models.py | 5 +---- .../addons/includes/button_data_attributes.html | 2 +- .../templates/browse/impala/base_listing.html | 1 - apps/search/tests/test_views.py | 4 +--- lib/settings_base.py | 1 + mkt/webapps/models.py | 14 +++++++++++++- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/apps/addons/models.py b/apps/addons/models.py index cd65fd11cd..d2b08670a3 100644 --- a/apps/addons/models.py +++ b/apps/addons/models.py @@ -1458,8 +1458,6 @@ class AddonType(amo.models.ModelBase): type = amo.ADDON_SLUGS[self.id] except KeyError: return None - if type == 'apps': - return reverse('apps.list') return reverse('browse.%s' % type) @@ -1536,8 +1534,7 @@ class Category(amo.models.ModelBase): type = amo.ADDON_SLUGS[self.type] except KeyError: type = amo.ADDON_SLUGS[amo.ADDON_EXTENSION] - view = 'apps.list' if type == 'apps' else 'browse.%s' % type - return reverse(view, args=[self.slug]) + return reverse('browse.%s' % type, args=[self.slug]) @staticmethod def transformer(addons): diff --git a/apps/addons/templates/addons/includes/button_data_attributes.html b/apps/addons/templates/addons/includes/button_data_attributes.html index 291426be2f..4efe75afc6 100644 --- a/apps/addons/templates/addons/includes/button_data_attributes.html +++ b/apps/addons/templates/addons/includes/button_data_attributes.html @@ -20,5 +20,5 @@ data-manifest-url="{% if (addon.is_premium() and addon.has_purchased(amo_user)) or (not addon.is_premium()) -%} {{ addon.manifest_url }} {%- endif %}" - data-record-url="{{ url('detail.record', addon.app_slug) }}" + data-record-url="{{ addon.get_detail_url('record') }}" {% endif %} diff --git a/apps/browse/templates/browse/impala/base_listing.html b/apps/browse/templates/browse/impala/base_listing.html index 45848bd89c..c26c4e37b5 100644 --- a/apps/browse/templates/browse/impala/base_listing.html +++ b/apps/browse/templates/browse/impala/base_listing.html @@ -45,7 +45,6 @@ {% set base_crumb = { 'extensions': (url('browse.extensions'), _('Extensions')), 'themes': (url('browse.themes'), _('Themes')), - 'apps': (url('apps.list'), _('Apps')) }.get(section, 'extensions') %} {% if section == 'extensions' %} diff --git a/apps/search/tests/test_views.py b/apps/search/tests/test_views.py index fa5acda9da..a57d5ebd65 100644 --- a/apps/search/tests/test_views.py +++ b/apps/search/tests/test_views.py @@ -2,12 +2,11 @@ import json import urlparse -from django.conf import settings from django.http import QueryDict from django.test import client from jingo.helpers import datetime as datetime_filter -from mock import Mock, patch +from mock import Mock from nose import SkipTest from nose.tools import eq_ from pyquery import PyQuery as pq @@ -26,7 +25,6 @@ from search.views import DEFAULT_NUM_PERSONAS from tags.models import Tag from versions.compare import num as vnum, version_int as vint, MAXVERSION from versions.models import ApplicationsVersions -from mkt.webapps.tests.test_views import PaidAppMixin def test_parse_bad_type(): diff --git a/lib/settings_base.py b/lib/settings_base.py index 840b637334..084505ea28 100644 --- a/lib/settings_base.py +++ b/lib/settings_base.py @@ -375,6 +375,7 @@ INSTALLED_APPS = ( 'translations', 'users', 'versions', + 'mkt.webapps', 'zadmin', 'cake', diff --git a/mkt/webapps/models.py b/mkt/webapps/models.py index 0fd22588ef..4925b1e809 100644 --- a/mkt/webapps/models.py +++ b/mkt/webapps/models.py @@ -5,6 +5,7 @@ from urllib import urlencode import urlparse from django.conf import settings +from django.core.urlresolvers import NoReverseMatch from django.db import models from django.dispatch import receiver @@ -88,7 +89,18 @@ class Webapp(Addon): self.update(slug='app-%s' % self.id) def get_url_path(self, more=False): - return reverse('detail', args=[self.app_slug]) + # We won't have to do this when Marketplace absorbs all apps views, + # but for now pretend you didn't see this. + try: + return reverse('detail', args=[self.app_slug]) + except NoReverseMatch: + # Fall back to old details page until the views get ported. + return super(Webapp, self).get_url_path(more=more) + + def get_detail_url(self, action=None): + # Reverse URLs for 'detail', 'details.record', etc. + return reverse(('detail.%s' % action) if action else 'detail', + args=[self.app_slug]) def get_dev_url(self, action='edit', args=None, prefix_only=False): # Either link to the "new" Marketplace Developer Hub or the old one.