Hide apps from AMO devhub feeds (bug 728070)

This commit is contained in:
Kumar McMillan 2012-02-20 16:02:07 -06:00
Родитель 439ee256af
Коммит f8e8ffaf31
3 изменённых файлов: 29 добавлений и 4 удалений

Просмотреть файл

@ -18,8 +18,8 @@ class ActivityFeedRSS(Feed):
def items(self, key):
if key.addon:
addons = key.addon
else: # We are showing all the add-ons.
addons = key.user.addons.all()
else: # We are showing all the add-ons (excluding apps).
addons = key.user.addons.exclude(type=amo.ADDON_WEBAPP)
return (ActivityLog.objects.for_addons(addons)
.exclude(action__in=amo.LOG_HIDE_DEVELOPER))[:20]

Просмотреть файл

@ -77,6 +77,20 @@ class TestActivity(HubTest):
eq_(doc('.subscribe-feed').attr('href')[:-32],
reverse('devhub.feed_all') + '?privaterss=')
def test_ignore_apps_on_dashboard(self):
self.addon.update(type=amo.ADDON_WEBAPP)
self.log_creates(1)
rp = self.client.get(reverse('devhub.addons'))
doc = pq(rp.content)
eq_(doc('li.item').text(), None)
def test_ignore_apps_in_feed(self):
self.addon.update(type=amo.ADDON_WEBAPP)
self.log_creates(1)
rp = self.get_response()
doc = pq(rp.content)
eq_(doc('.item').text(), None)
def test_items(self):
self.log_creates(10)
doc = self.get_pq()
@ -189,6 +203,15 @@ class TestActivity(HubTest):
eq_(r['content-type'], 'application/rss+xml')
eq_(len(pq(r.content)('item')), 5)
def test_rss_ignores_apps(self):
self.addon.update(type=amo.ADDON_WEBAPP)
self.log_creates(1)
# This will give us a new RssKey
self.get_response()
key = RssKey.objects.get()
rp = self.get_response(privaterss=key.key)
eq_(pq(rp.content)('item').text(), None)
def test_logged_out(self):
self.client.logout()
r = self.get_response()

Просмотреть файл

@ -112,8 +112,9 @@ def dashboard(request, webapp=False):
addons, filter = addon_listing(request, webapp=webapp)
addons = amo.utils.paginate(request, addons, per_page=10)
blog_posts = _get_posts()
all_addons = request.amo_user.addons.exclude(type=amo.ADDON_WEBAPP)
data = dict(addons=addons, sorting=filter.field, filter=filter,
items=_get_items(None, request.amo_user.addons.all())[:4],
items=_get_items(None, all_addons)[:4],
sort_opts=filter.opts, rss=_get_rss_feed(request),
blog_posts=blog_posts, timestamp=int(time.time()),
webapp=webapp)
@ -239,7 +240,8 @@ def feed(request, addon_id=None):
p = urlquote(request.get_full_path())
return http.HttpResponseRedirect('%s?to=%s' % (url, p))
else:
addons_all = request.amo_user.addons.all()
# We exclude apps on AMO.
addons_all = request.amo_user.addons.exclude(type=amo.ADDON_WEBAPP)
if addon_id:
addon = get_object_or_404(Addon.objects.id_or_slug(addon_id))