highlight "Collections I've Made" sidebar nav link for only my collections (bug 723041)

This commit is contained in:
Chris Van 2012-02-07 11:58:50 -08:00
Родитель 38e81be115
Коммит de7b98a617
2 изменённых файлов: 18 добавлений и 4 удалений

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

@ -1031,7 +1031,7 @@ class TestMobileCollections(TestMobile):
self.assertTemplateUsed(r, 'bandwagon/impala/collection_listing.html')
class TestMine(amo.tests.TestCase):
class TestUserListing(amo.tests.TestCase):
fixtures = ['base/users']
def setUp(self):
@ -1041,6 +1041,16 @@ class TestMine(amo.tests.TestCase):
def test_mine(self):
r = self.client.get(reverse('collections.mine'), follow=True)
self.assertRedirects(r, reverse('collections.user', args=['admin']))
eq_(r.context['page'], 'mine')
assert '#p-mine' in pq(r.content)('style').text(), (
"'Collections I've Made' sidebar link should be highlighted.")
def test_not_mine(self):
self.client.logout()
r = self.client.get(reverse('collections.user', args=['admin']))
eq_(r.context['page'], 'user')
assert '#p-mine' not in pq(r.content)('style').text(), (
"'Collections I've Made' sidebar link shouldn't be highlighted.")
def test_favorites(self):
r = self.client.get(reverse('collections.mine', args=['favorites']),

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

@ -145,14 +145,18 @@ def user_listing(request, username):
author = get_object_or_404(UserProfile, username=username)
qs = (Collection.objects.filter(author__username=username)
.order_by('-created'))
if not (request.user.is_authenticated() and
request.amo_user.username == username):
mine = (request.user.is_authenticated() and
request.amo_user.username == username)
if mine:
page = 'mine'
else:
page = 'user'
qs = qs.filter(listed=True)
collections = paginate(request, qs)
votes = get_votes(request, collections.object_list)
return render(request, 'bandwagon/user_listing.html',
dict(collections=collections, collection_votes=votes,
page='mine', author=author, filter=get_filter(request)))
page=page, author=author, filter=get_filter(request)))
class CollectionAddonFilter(BaseFilter):