Skip to content

Commit

Permalink
[bug 967045] Only show register form in AAQ or Get Involved.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlr committed Feb 12, 2014
1 parent 9e52e61 commit f7d846f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 48 deletions.
Expand Up @@ -15,7 +15,7 @@ <h3>{{ _('Sign up as a volunteer') }}</h3>
</form>
<a id="sign-up-contributor" class="btn btn-submit browserid-login" data-form="gi-browserid-form" data-next="{{ request.get_full_path() }}" href="#">{{ _('Sign me up') }}</a>
{% else %}
<a id="sign-up-contributor" class="btn btn-submit" href="{{ url('users.auth_contributor') }}">
<a id="sign-up-contributor" class="btn btn-submit" href="{{ url('users.registercontributor') }}">
{{ _('Sign me up') }}
</a>
{% endif %}
Expand Down
7 changes: 0 additions & 7 deletions kitsune/sumo/static/less/users.less
Expand Up @@ -417,13 +417,6 @@ article {
margin: 20px 0 0;
}

.login-question-prompt {
background: #fff;
font-size: 2em;
margin: 0 10px 20px;
text-align: center;
}

#password-rules,
#username-rules,
.browserid-signup span.helptext {
Expand Down
2 changes: 1 addition & 1 deletion kitsune/sumo/templates/includes/common_macros.html
Expand Up @@ -64,7 +64,7 @@
</li>
{% else %}
<li><a href="{{ url('users.auth') }}" class="sign-in register">
{{ _('Sign In / Register') }}
{{ _('Sign In') }}
</a></li>
{% endif %}
{% endif %}
Expand Down
1 change: 0 additions & 1 deletion kitsune/sumo/templates/mobile/base.html
Expand Up @@ -87,7 +87,6 @@
{% endif %}
{% else %}
<a href="{{ url('users.login') }}">{{ _('Sign in') }}</a>
<a href="{{ url('users.register') }}">{{ _('Register') }}</a>
{% endif %}
{% endif %}

Expand Down
29 changes: 12 additions & 17 deletions kitsune/users/templates/users/auth.html
Expand Up @@ -8,14 +8,6 @@
{% set classes = 'login register' %}

{% block content %}
<div class="grid_12 login-question-prompt">
{% if request.LANGUAGE_CODE in settings.AAQ_LANGUAGES %}
{% set ask_url = url('questions.aaq_step1') %}
{% else %}
{% set ask_url = url('wiki.document', 'get-community-support') %}
{% endif %}
<h1><a href="{{ ask_url }}">{{ _('Would you like to ask a question in the community support forum?') }}</a></h1>
</div>
{% if waffle.flag('browserid') %}
<div class="grid_12">
<article>
Expand All @@ -24,19 +16,22 @@ <h1>{{ _('You must be signed in to continue') }}</h1>
</article>
</div>
{% else %}
<div class="grid_6">
<div class="{% if contributor %}grid_6{% else %}grid_12{% endif %}">
<article id="login" class="main">
<h1>{{ _('Sign In') }}</h1>
{{ render_login(login_form, csrf=csrf(), next_url=next_url) }}
</article>
</div>
<div class="grid_6">
<article id="register" class="main">
<h1>{{ _('Register to be a Contributor') }}</h1>
<span>{{ _('You don\'t need to register to <a href="{url}">ask a question</a>.')|fe(url=url('questions.aaq_step1')) }}</span>
{% set action = url('users.registercontributor') if contributor else url('users.register') %}
{{ render_register(register_form, csrf=csrf(), action=action, contributor=contributor) }}
</article>
</div>
{% if contributor %}
{# Only show registration form to users coming from the Get Involved pages. #}
<div class="grid_6">
<article id="register" class="main">
<h1>{{ _('Register to be a Contributor') }}</h1>
<span>{{ _('You don\'t need to register to <a href="{url}">ask a question</a>.')|fe(url=url('questions.aaq_step1')) }}</span>
{% set action = url('users.registercontributor') if contributor else url('users.register') %}
{{ render_register(register_form, csrf=csrf(), action=action, contributor=contributor) }}
</article>
</div>
{% endif %}
{% endif %}
{% endblock %}
44 changes: 24 additions & 20 deletions kitsune/users/tests/test_views.py
Expand Up @@ -65,11 +65,12 @@ def test_new_user_smtp_error(self, get_current, send_messages):
get_current.return_value.domain = 'su.mo.com'

send_messages.side_effect = send_mail_raise_smtp
response = self.client.post(reverse('users.register', locale='en-US'),
{'username': 'newbie',
'email': 'newbie@example.com',
'password': 'foobar22',
'password2': 'foobar22'}, follow=True)
response = self.client.post(
reverse('users.registercontributor', locale='en-US'),
{'username': 'newbie',
'email': 'newbie@example.com',
'password': 'foobar22',
'password2': 'foobar22'}, follow=True)
self.assertContains(response, unicode(ERROR_SEND_EMAIL))
assert not User.objects.filter(username='newbie').exists()

Expand Down Expand Up @@ -169,30 +170,33 @@ def test_new_user_with_questions(self, get_current):

def test_duplicate_username(self):
u = user(save=True)
response = self.client.post(reverse('users.register', locale='en-US'),
{'username': u.username,
'email': 'newbie@example.com',
'password': 'foo',
'password2': 'foo'}, follow=True)
response = self.client.post(
reverse('users.registercontributor', locale='en-US'),
{'username': u.username,
'email': 'newbie@example.com',
'password': 'foo',
'password2': 'foo'}, follow=True)
self.assertContains(response, 'already exists')

def test_duplicate_email(self):
u = user(email='noob@example.com', save=True)
User.objects.create(username='noob', email='noob@example.com').save()
response = self.client.post(reverse('users.register', locale='en-US'),
{'username': 'newbie',
'email': u.email,
'password': 'foo',
'password2': 'foo'}, follow=True)
response = self.client.post(
reverse('users.registercontributor', locale='en-US'),
{'username': 'newbie',
'email': u.email,
'password': 'foo',
'password2': 'foo'}, follow=True)
self.assertContains(response, 'already exists')

def test_no_match_passwords(self):
u = user(save=True)
response = self.client.post(reverse('users.register', locale='en-US'),
{'username': u.username,
'email': u.email,
'password': 'testpass',
'password2': 'testbus'}, follow=True)
response = self.client.post(
reverse('users.registercontributor', locale='en-US'),
{'username': u.username,
'email': u.email,
'password': 'testpass',
'password2': 'testbus'}, follow=True)
self.assertContains(response, 'must match')

@mock.patch.object(Site.objects, 'get_current')
Expand Down
2 changes: 1 addition & 1 deletion kitsune/users/views.py
Expand Up @@ -143,7 +143,7 @@ def register(request, template, contributor=False):
return render(request, template + 'register.html', {
'form': form})

return user_auth(request, register_form=form)
return user_auth(request, register_form=form, contributor=contributor)


def register_contributor(request):
Expand Down

0 comments on commit f7d846f

Please sign in to comment.