Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
clean up users sidebar navigation on My Purchases page (bug 705052)
Browse files Browse the repository at this point in the history
  • Loading branch information
cvan committed Nov 29, 2011
1 parent 3fba39b commit f99685e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 17 deletions.
29 changes: 19 additions & 10 deletions apps/users/templates/users/includes/navigation.html
@@ -1,14 +1,23 @@
<div class="secondary">
{% set links = [
(_('My Profile'), amo_user.get_url_path()),
(_('Account Settings'), url('users.edit')),
] %}
{% if not webapp %}
{% do links.append((_('My Collections'), url('collections.mine'))) %}
{% if amo_user.favorite_addons %}
{% do links.append((_('My Favorites'),
url('collections.mine', 'favorites'))) %}
{% endif %}
{% endif %}
{% if waffle.switch('marketplace') %}
{% do links.append((_('My Purchases'), url('users.purchases'))) %}
{% endif %}
<div id="secondary-nav" class="secondary">
<h2>{{ _('My Account') }}</h2>
<ul>
<li><a href="{{ request.user.get_profile().get_url_path() }}">{{ _('My Profile') }}</a></li>
<li><a href="{{ url('users.edit') }}">{{ _('Account Settings') }}</a></li>
<li><a href="{{ url('collections.user', amo_user.username) }}">{{ _('My Collections') }}</a></li>
{% if amo_user.favorite_addons %}
<li><a href="{{ url('collections.detail', amo_user.username, 'favorites') }}">{{ _('My Favorites') }}</a></li>
{% endif %}
{% if waffle.switch('marketplace') %}
<li><a href="{{ url('users.purchases') }}">{{ _('My Purchases') }}</a></li>
{% endif %}
{% for title, link in links %}
<li><a href="{{ link }}"{% if request.path == link %} class="selected"{% endif %}>
{{ title }}</a></li>
{% endfor %}
</ul>
</div>
40 changes: 34 additions & 6 deletions apps/users/tests/test_views.py
Expand Up @@ -23,7 +23,7 @@
from amo.helpers import urlparams
from amo.pyquery_wrapper import PyQuery as pq
from amo.urlresolvers import reverse
from bandwagon.models import Collection, CollectionWatcher
from bandwagon.models import Collection, CollectionAddon, CollectionWatcher
from devhub.models import ActivityLog
from market.models import Price
from reviews.models import Review
Expand Down Expand Up @@ -611,7 +611,7 @@ def setUp(self):
self.data = {'username': 'jbalogh@mozilla.com', 'password': 'foo'}

def log_calls(self, obj):
return [ call[0][1] for call in obj.call_args_list ]
return [call[0][1] for call in obj.call_args_list]

def test_login_passes(self, log_login_attempt):
self.client.post(self.url, data=self.data)
Expand Down Expand Up @@ -1058,10 +1058,38 @@ def test_in_menu(self):
doc = pq(self.client.get(self.url).content)
assert 'My Purchases' in doc('li.account li').text()

def test_in_side_menu(self):
raise SkipTest
doc = pq(self.client.get(self.url).content)
assert 'My Purchases' in doc('div.secondary li').text()
def check_sidebar_links(self, expected):
r = self.client.get(self.url)
eq_(r.status_code, 200)
links = pq(r.content)('#secondary-nav ul a')
amo.tests.check_links(expected, links)
eq_(links.filter('.selected').attr('href'), self.url,
'"My Purchases" link should be selected.')

def test_in_sidebar(self):
# Populate this user's favorites.
c = Collection.objects.create(type=amo.COLLECTION_FAVORITES,
author=self.user.get_profile())
CollectionAddon.objects.create(addon=Addon.objects.all()[0],
collection=c)

expected = [
('My Profile', self.user.get_profile().get_url_path()),
('Account Settings', reverse('users.edit')),
('My Collections', reverse('collections.mine')),
('My Favorites', reverse('collections.mine', args=['favorites'])),
('My Purchases', self.url),
]
self.check_sidebar_links(expected)

@patch.object(settings, 'APP_PREVIEW', True)
def test_in_apps_sidebar(self):
expected = [
('My Profile', self.user.get_profile().get_url_path()),
('Account Settings', reverse('users.edit')),
('My Purchases', self.url),
]
self.check_sidebar_links(expected)

def test_not_purchase(self):
self.client.logout()
Expand Down
2 changes: 1 addition & 1 deletion templates/impala/base_shared.html
@@ -1,4 +1,4 @@
{% if webapp or settings.APP_PREVIEW %}
{% set WEBAPPS = True %}
{% set webapp, WEBAPPS = True, True %}
{% endif %}
{% extends "webapps/base.html" if WEBAPPS else "impala/base.html" %}

0 comments on commit f99685e

Please sign in to comment.