kill old webapps views and move over report abuse (bug 733126)
This commit is contained in:
Родитель
36a5314656
Коммит
4df1ef9d51
|
@ -9,6 +9,7 @@ import amo
|
|||
import amo.tests
|
||||
from amo.urlresolvers import reverse
|
||||
from users.models import UserProfile
|
||||
from mkt.webapps.models import Webapp
|
||||
|
||||
|
||||
@mock.patch.object(settings, 'WEBAPPS_RECEIPT_KEY',
|
||||
|
@ -51,3 +52,13 @@ class TestInstall(amo.tests.TestCase):
|
|||
res = self.client.post(self.url)
|
||||
content = json.loads(res.content)
|
||||
assert content.get('receipt'), content
|
||||
|
||||
|
||||
class TestReportAbuse(amo.tests.TestCase):
|
||||
fixtures = ['webapps/337141-steamcube']
|
||||
|
||||
def test_page(self):
|
||||
self.webapp = Webapp.objects.get(id=337141)
|
||||
self.url = reverse('detail.abuse', args=[self.webapp.app_slug])
|
||||
r = self.client.get(self.url)
|
||||
eq_(r.status_code, 200)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from django.conf.urls.defaults import patterns, url
|
||||
|
||||
import addons.views
|
||||
from . import views
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url('^$', views.detail, name='detail'),
|
||||
url('^abuse$', addons.views.report_abuse, name='detail.abuse'),
|
||||
url('^record$', views.record, name='detail.record'),
|
||||
)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from django.shortcuts import get_object_or_404
|
||||
|
||||
import jingo
|
||||
|
||||
from addons.models import Addon
|
||||
|
@ -6,6 +8,7 @@ from addons.decorators import (addon_view_factory, can_be_purchased,
|
|||
from amo.decorators import json_view, login_required, post_required, write
|
||||
from reviews.forms import ReviewForm
|
||||
from reviews.models import Review
|
||||
from sharing.views import share as share_redirect
|
||||
from mkt.webapps.models import Installed
|
||||
|
||||
|
||||
|
|
|
@ -71,22 +71,3 @@ class TestPremium(PaidAppMixin, amo.tests.TestCase):
|
|||
self.setup_paid()
|
||||
eq_(self.free, list(Webapp.objects.top_free()))
|
||||
eq_(self.paid, list(Webapp.objects.top_paid()))
|
||||
|
||||
|
||||
class TestReportAbuse(WebappTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestReportAbuse, self).setUp()
|
||||
self.abuse_url = reverse('apps.abuse', args=[self.webapp.app_slug])
|
||||
|
||||
def test_page(self):
|
||||
r = self.client.get(self.abuse_url)
|
||||
eq_(r.status_code, 200)
|
||||
doc = pq(r.content)
|
||||
eq_(doc('title').text(), 'Report abuse for woo :: Apps Marketplace')
|
||||
expected = [
|
||||
('Apps Marketplace', reverse('apps.home')),
|
||||
('Apps', reverse('apps.list')),
|
||||
(unicode(self.webapp.name), self.url),
|
||||
]
|
||||
amo.tests.check_links(expected, doc('#breadcrumbs a'))
|
||||
|
|
|
@ -1,46 +1,7 @@
|
|||
from django.conf.urls.defaults import include, patterns, url
|
||||
from django.conf.urls.defaults import patterns
|
||||
|
||||
from . import views
|
||||
from addons import views as addons_views
|
||||
from reviews.urls import review_patterns
|
||||
|
||||
APP_SLUG = r"""(?P<app_slug>[^/<>"']+)"""
|
||||
|
||||
|
||||
# These will all start with /app/<app_slug>/
|
||||
detail_patterns = patterns('',
|
||||
url('^$', addons_views.addon_detail, name='apps.detail'),
|
||||
url('^more$', addons_views.addon_detail, name='apps.detail_more'),
|
||||
url('^share$', views.share, name='apps.share'),
|
||||
url('^abuse$', addons_views.report_abuse, name='apps.abuse'),
|
||||
url('^contribute/$', addons_views.contribute, name='apps.contribute'),
|
||||
url('^contribute/(?P<status>cancel|complete)$', addons_views.paypal_result,
|
||||
name='apps.paypal'),
|
||||
|
||||
# TODO(andym): generate these instead of copying them around.
|
||||
url('^purchase/$', addons_views.purchase, name='apps.purchase'),
|
||||
url(r'purchase/start$', addons_views.paypal_start,
|
||||
name='apps.purchase.start'),
|
||||
url('^purchase/error/$', addons_views.purchase_error,
|
||||
name='apps.purchase.error'),
|
||||
url('^purchase/thanks/$', addons_views.purchase_thanks,
|
||||
name='apps.purchase.thanks'),
|
||||
url('^purchase/(?P<status>cancel|complete)$',
|
||||
addons_views.purchase_complete, name='apps.purchase.finished'),
|
||||
|
||||
('^reviews/', include(review_patterns('apps'))),
|
||||
)
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url('^$', views.app_home, name='apps.home'),
|
||||
url('^search/$', 'search.views.app_search', name='apps.search'),
|
||||
|
||||
# Review spam.
|
||||
url('^reviews/spam/$', 'reviews.views.spam', name='apps.reviews.spam'),
|
||||
|
||||
url('^apps/(?P<category>[^/]+)?$', views.app_list, name='apps.list'),
|
||||
|
||||
# URLs for a single app.
|
||||
#('^app/%s/' % APP_SLUG, include(detail_patterns)),
|
||||
)
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
from django.shortcuts import get_object_or_404, redirect
|
||||
|
||||
import jingo
|
||||
from mobility.decorators import mobile_template
|
||||
from tower import ugettext_lazy as _lazy
|
||||
|
||||
import amo
|
||||
from amo.helpers import loc
|
||||
from amo.utils import paginate
|
||||
import addons.views
|
||||
import search.views
|
||||
|
||||
from addons.models import Category
|
||||
from browse.views import CategoryLandingFilter
|
||||
from sharing.views import share as share_redirect
|
||||
from .models import Webapp
|
||||
|
||||
TYPE = amo.ADDON_WEBAPP
|
||||
|
||||
|
||||
def es_app_list(request):
|
||||
ctx = search.views.app_search_query(request)
|
||||
return jingo.render(request, 'webapps/listing.html', ctx)
|
||||
|
||||
|
||||
# TODO(cvan): Make a mobile apps homepage when we know what we want.
|
||||
#@mobile_template('webapps/{mobile/}home.html')
|
||||
def app_home(request):
|
||||
if request.MOBILE:
|
||||
return redirect('apps.list')
|
||||
|
||||
src = 'cb-btn-home'
|
||||
dl_src = 'cb-dl-home'
|
||||
|
||||
ctx = {
|
||||
'section': amo.ADDON_SLUGS[TYPE],
|
||||
'addon_type': TYPE,
|
||||
'free': Webapp.objects.top_free()[:18],
|
||||
'paid': Webapp.objects.top_paid()[:18],
|
||||
'src': src,
|
||||
'dl_src': dl_src,
|
||||
}
|
||||
return jingo.render(request, 'webapps/home.html', ctx)
|
||||
|
||||
|
||||
class AppCategoryLandingFilter(CategoryLandingFilter):
|
||||
|
||||
opts = (('downloads', _lazy(u'Most Popular')),
|
||||
('rating', _lazy(u'Highest Rated')),
|
||||
('featured', _lazy(u'Featured')))
|
||||
|
||||
|
||||
class AppFilter(addons.views.BaseFilter):
|
||||
opts = (('downloads', _lazy(u'Weekly Downloads')),
|
||||
('free', loc(u'Top Free')),
|
||||
('paid', loc(u'Top Paid')),
|
||||
('rating', _lazy(u'Highest Rated')))
|
||||
extras = (('created', _lazy(u'Newest')),
|
||||
('name', _lazy(u'Name')),
|
||||
('price', loc(u'Price')))
|
||||
|
||||
|
||||
def app_listing(request):
|
||||
qs = Webapp.objects.listed()
|
||||
filter = AppFilter(request, qs, 'sort', default='downloads', model=Webapp)
|
||||
return filter.qs, filter
|
||||
|
||||
|
||||
@mobile_template('browse/{mobile/}extensions.html')
|
||||
def app_list(request, category=None, template=None):
|
||||
if category is not None:
|
||||
q = Category.objects.filter(type=TYPE)
|
||||
category = get_object_or_404(q, slug=category)
|
||||
|
||||
#sort = request.GET.get('sort')
|
||||
# TODO: Uncomment this when we have apps category landing pages.
|
||||
#if not sort and not request.MOBILE and category and category.count > 4:
|
||||
# return category_landing(request, category, TYPE,
|
||||
# AppCategoryLandingFilter)
|
||||
|
||||
addons, filter = app_listing(request)
|
||||
sorting = filter.field
|
||||
src = 'cb-btn-%s' % sorting
|
||||
dl_src = 'cb-dl-%s' % sorting
|
||||
|
||||
if category:
|
||||
addons = addons.filter(categories__id=category.id)
|
||||
|
||||
addons = paginate(request, addons, count=addons.count())
|
||||
ctx = {'section': amo.ADDON_SLUGS[TYPE], 'addon_type': TYPE,
|
||||
'category': category, 'addons': addons, 'filter': filter,
|
||||
'sorting': sorting, 'sort_opts': filter.opts, 'src': src,
|
||||
'dl_src': dl_src}
|
||||
return jingo.render(request, template, ctx)
|
||||
|
||||
|
||||
def share(request, app_slug):
|
||||
webapp = get_object_or_404(Webapp, app_slug=app_slug)
|
||||
return share_redirect(request, webapp, webapp.name, webapp.summary)
|
Загрузка…
Ссылка в новой задаче