highlight "Collections I've Made" sidebar nav link for only my collections (bug 723041)
This commit is contained in:
Родитель
38e81be115
Коммит
de7b98a617
|
@ -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):
|
||||
|
|
Загрузка…
Ссылка в новой задаче