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

Commit

Permalink
unleash consumer pages: a new home, a new hope (bug 743757)
Browse files Browse the repository at this point in the history
  • Loading branch information
cvan committed Apr 10, 2012
1 parent 1956ace commit 1a14fcb
Show file tree
Hide file tree
Showing 18 changed files with 193 additions and 84 deletions.
4 changes: 3 additions & 1 deletion apps/amo/urlresolvers.py
Expand Up @@ -10,6 +10,7 @@
from django.utils.translation.trans_real import parse_accept_lang_header

import jinja2
import waffle

import amo

Expand Down Expand Up @@ -134,7 +135,8 @@ def fix(self, path):
url_parts.append(locale)

# Temporarily force home page to /<locale>/developers/.
if settings.MARKETPLACE and not path.partition('/')[0]:
if (not waffle.switch_is_active('unleash-consumer') and
settings.MARKETPLACE and not path.partition('/')[0]):
url_parts.append('developers')

elif path.partition('/')[0] not in settings.SUPPORTED_NONAPPS:
Expand Down
3 changes: 2 additions & 1 deletion media/css/devreg/manage.less
Expand Up @@ -168,7 +168,8 @@
}

#slug_edit a {
font-size: 10px;
font-size: 11px;
font-weight: bold;
}

form .char-count,
Expand Down
5 changes: 5 additions & 0 deletions migrations/361-unleash-consumer.sql
@@ -0,0 +1,5 @@
INSERT INTO waffle_switch_mkt (name, active, note)
VALUES ('unleash-consumer', 0,
'This activates the consumer flow. No login. Home is really home, '
'not the Developer Hub. Stuff is pretty. This is for what you '
'have been waiting.');
14 changes: 12 additions & 2 deletions mkt/account/tests/test_views.py
Expand Up @@ -297,15 +297,16 @@ class TestProfileLinks(amo.tests.TestCase):

def setUp(self):
self.user = self.get_user()
# Authentication is required for now.
assert self.client.login(username=self.user.email, password='password')

def get_user(self):
return UserProfile.objects.get(username='31337')

def get_url(self):
return reverse('users.profile', args=[self.user.username])

def log_in(self):
assert self.client.login(username=self.user.email, password='password')

def test_id_or_username(self):
args = [self.user.id, self.user.username]
for arg in args:
Expand All @@ -321,6 +322,7 @@ def get_profile_links(self, id=None, username=None):

def test_viewing_my_profile(self):
# Me as (non-admin) viewing my own profile.
self.log_in()
links = self.get_profile_links(self.user.id)
eq_(links.length, 1)
eq_(links.eq(0).attr('href'), reverse('account.settings'))
Expand All @@ -332,11 +334,18 @@ def test_viewing_my_profile_as_other_user(self):
links = self.get_profile_links(self.user.id)
eq_(links.length, 0, 'No edit buttons should be shown.')

def test_viewing_my_profile_as_anonymous(self):
# Ensure no edit buttons are shown.
links = self.get_profile_links(self.user.id)
eq_(links.length, 0, 'No edit buttons should be shown.')

def test_viewing_other_profile(self):
self.log_in()
# Me as (non-admin) viewing someone else's my own profile.
eq_(self.get_profile_links(id=999).length, 0)

def test_viewing_my_profile_as_admin(self):
self.log_in()
# Me as (with admin) viewing my own profile.
GroupUser.objects.create(
group=Group.objects.create(rules='Users:Edit'), user=self.user)
Expand All @@ -346,6 +355,7 @@ def test_viewing_my_profile_as_admin(self):
eq_(links.eq(0).attr('href'), reverse('account.settings'))

def test_viewing_other_profile_as_admin(self):
self.log_in()
# Me as (with admin) viewing someone else's profile.
GroupUser.objects.create(
group=Group.objects.create(rules='Users:Edit'), user=self.user)
Expand Down
6 changes: 2 additions & 4 deletions mkt/account/urls.py
Expand Up @@ -29,12 +29,10 @@
name='account.purchases.receipt'),
))

users_patterns = decorate(login_required, patterns('',
users_patterns = patterns('',
# Keeping the same URL pattern since admin pages already know about this.
url(r'^(?:(?P<user_id>\d+)/)?edit$', views.admin_edit,
name='users.admin_edit'),

# TODO: Don't require authentication for this.
url(r'''(?P<username>[^/<>"']+)$''', views.profile,
name='users.profile'),
))
)
6 changes: 3 additions & 3 deletions mkt/account/views.py
Expand Up @@ -11,8 +11,8 @@
from access import acl
from addons.views import BaseFilter
import amo
from amo.decorators import (login_required, no_login_required,
permission_required, post_required, write)
from amo.decorators import (login_required, permission_required, post_required,
write)
from amo.utils import paginate
from market.models import PreApprovalUser
import paypal
Expand Down Expand Up @@ -174,6 +174,7 @@ def account_settings(request):


@write
@login_required
@permission_required('Users', 'Edit')
def admin_edit(request, user_id):
amouser = get_object_or_404(UserProfile, pk=user_id)
Expand Down Expand Up @@ -209,7 +210,6 @@ def delete_photo(request):
return http.HttpResponse()


@no_login_required
def profile(request, username):
if username.isdigit():
user = get_object_or_404(UserProfile, id=username)
Expand Down
18 changes: 10 additions & 8 deletions mkt/developers/helpers.py
Expand Up @@ -8,13 +8,15 @@
from jingo import register
from jingo.helpers import datetime
from tower import ugettext as _, ungettext as ngettext
import waffle

import amo
from amo.urlresolvers import reverse
from amo.helpers import breadcrumbs, impala_breadcrumbs, loc
from amo.helpers import breadcrumbs
from access import acl
from addons.helpers import new_context

from mkt.site.helpers import mkt_breadcrumbs

register.function(acl.check_addon_ownership)

Expand All @@ -41,7 +43,7 @@ def hub_page_title(context, title=None, addon=None):
@jinja2.contextfunction
def mkt_page_title(context, title, force_webapps=False):
title = smart_unicode(title)
base_title = loc('Mozilla Marketplace')
base_title = _('Mozilla Marketplace')
return u'%s | %s' % (title, base_title)


Expand All @@ -56,8 +58,7 @@ def docs_page_title(context, title=None):

@register.function
@jinja2.contextfunction
def hub_breadcrumbs(context, addon=None, items=None, add_default=False,
landing_galore=False):
def hub_breadcrumbs(context, addon=None, items=None, add_default=False):
"""
Wrapper function for ``breadcrumbs``. Prepends 'Developer Hub'
breadcrumbs.
Expand All @@ -72,18 +73,18 @@ def hub_breadcrumbs(context, addon=None, items=None, add_default=False,
**impala**
Whether to use the impala_breadcrumbs helper. Default is False.
"""
if landing_galore:
if waffle.switch_is_active('unleash-consumer'):
crumbs = [(reverse('mkt.developers.index'), _('Developer Hub'))]
else:
crumbs = [(reverse('mkt.developers.apps'), _('My Submissions'))]
if landing_galore:
if waffle.switch_is_active('unleash-consumer'):
title = _('My Submissions')
link = reverse('mkt.developers.apps')
else:
title = link = None

if addon:
if landing_galore:
if waffle.switch_is_active('unleash-consumer'):
if not addon and not items:
# We are at the end of the crumb trail.
crumbs.append((None, title))
Expand All @@ -101,7 +102,8 @@ def hub_breadcrumbs(context, addon=None, items=None, add_default=False,
if len(crumbs) == 1:
crumbs = []

return impala_breadcrumbs(context, crumbs, add_default)
return mkt_breadcrumbs(context, items=crumbs,
add_default=waffle.switch_is_active('unleash-consumer'))


@register.function
Expand Down
6 changes: 5 additions & 1 deletion mkt/developers/templates/developers/apps/edit/basic.html
Expand Up @@ -42,7 +42,11 @@ <h2>
{{ form.slug.errors }}
{% else %}
{{ settings.SITE_URL }}/&hellip;/{{ addon.app_slug if webapp else addon.slug }}
<em class="edit-addon-details">{{ loc('(Not Available Yet)') }}</em>
{% if waffle.switch('unleash-consumer') %}
<a href="{{ addon.get_url_path() }}">{{ _('View Listing') }}</em>
{% else %}
<em class="edit-addon-details">{{ loc('(Not Available Yet)') }}</em>
{% endif %}
{% endif %}
</td>
</tr>
Expand Down
10 changes: 10 additions & 0 deletions mkt/developers/templates/developers/base_impala.html
Expand Up @@ -20,3 +20,13 @@
<link rel="stylesheet" href="{{ media('css/legacy/nojs.css') }}">
</noscript>
{% endblock %}

{% block aux_nav %}
{% if waffle.switch('unleash-consumer') %}
<li class="nomenu">
<a class="return" href="{{ url('home') }}">{{ _('Back to Apps') }}</a>
</li>
{% else %}
{{ super() }}
{% endif %}
{% endblock %}
Expand Up @@ -21,6 +21,11 @@
(addon.get_dev_url('in_app_config'), _('Manage In-App Payments'))
) %}
{% endif %}
{% if waffle.switch('unleash-consumer') %}
{% do urls.append(
(addon.get_url_path(), _('View Listing'))
) %}
{% endif %}

<section class="secondary manage" role="complementary">
<div class="island" id="edit-addon-nav">
Expand Down
1 change: 1 addition & 0 deletions mkt/developers/templates/developers/skeleton_impala.html
Expand Up @@ -53,6 +53,7 @@
{% if not settings.READ_ONLY %}
{% include 'impala/user_login.html' %}
{% endif %}
{% block aux_nav %}{% endblock %}
</ul>
</nav>
{% block masthead %}
Expand Down

0 comments on commit 1a14fcb

Please sign in to comment.