[bug 967045] Only show register form in AAQ or Get Involved.

This commit is contained in:
Ricky Rosario 2014-02-06 12:12:14 -05:00
Родитель 9e52e617bd
Коммит f7d846fe72
7 изменённых файлов: 39 добавлений и 48 удалений

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

@ -15,7 +15,7 @@
</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 %}

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

@ -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 {

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

@ -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 %}

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

@ -87,7 +87,6 @@
{% endif %}
{% else %}
<a href="{{ url('users.login') }}">{{ _('Sign in') }}</a>
<a href="{{ url('users.register') }}">{{ _('Register') }}</a>
{% endif %}
{% endif %}

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

@ -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>
@ -24,19 +16,22 @@
</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 %}

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

@ -65,11 +65,12 @@ class RegisterTests(TestCase):
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()
@ -169,30 +170,33 @@ class RegisterTests(TestCase):
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')

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

@ -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):