mirror of https://github.com/zulip/zulip.git
Always allow registration if attempting to register for a non-MIT realm.
(imported from commit 00489ab74c376a4ffb23ad661699ef31c6c06818)
This commit is contained in:
parent
87d7ec57ee
commit
724dce78e4
|
@ -26,6 +26,9 @@ urlpatterns = patterns('',
|
|||
url(r'^activity$', 'zephyr.views.get_activity'),
|
||||
|
||||
# Registration views, require a confirmation ID.
|
||||
url(r'^accounts/home/', 'zephyr.views.accounts_home'),
|
||||
url(r'^accounts/send_confirm/(?P<email>[\S]+)?', 'django.views.generic.simple.direct_to_template',
|
||||
{'template': 'zephyr/accounts_send_confirm.html'}, name='send_confirm'),
|
||||
url(r'^accounts/register/', 'zephyr.views.accounts_register'),
|
||||
url(r'^accounts/do_confirm/(?P<confirmation_key>[\w]+)', 'confirmation.views.confirm'),
|
||||
|
||||
|
@ -66,13 +69,6 @@ urlpatterns = patterns('',
|
|||
url(r'^notify_pointer_update$', 'zephyr.views.notify_pointer_update'),
|
||||
)
|
||||
|
||||
if settings.ALLOW_REGISTER:
|
||||
urlpatterns += patterns('',
|
||||
url(r'^accounts/home/', 'zephyr.views.accounts_home'),
|
||||
url(r'^accounts/send_confirm/(?P<email>[\S]+)?', 'django.views.generic.simple.direct_to_template',
|
||||
{'template': 'zephyr/accounts_send_confirm.html'}, name='send_confirm'),
|
||||
)
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns += patterns('',
|
||||
url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
|
||||
|
|
|
@ -10,24 +10,20 @@ autofocus('#email');
|
|||
</script>
|
||||
|
||||
<div class="pitch">
|
||||
<p>You’re not using your Zip drive anymore.</p>
|
||||
<p>You’re not calling your parents from the pay phone at school, asking
|
||||
to be picked up because you stayed late to go to the computer club
|
||||
meeting.</p>
|
||||
<p>You haven’t watched Saved by the Bell in a while.</p>
|
||||
<p>So why are you still using IRC?</p>
|
||||
<br/>
|
||||
<p>Discover a better alternative for group communication at work.</p>
|
||||
</div>
|
||||
<div class="signup">
|
||||
<p class="lead">Get started now, for free</p>
|
||||
<form class="form-inline" id="email_signup" action="{% url zephyr.views.accounts_home%}" method="post">
|
||||
<p class="lead">Let's get started…</p>
|
||||
<form class="form-inline" id="email_signup" action="{% url zephyr.views.accounts_home %}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="text" class="email required" placeholder="Enter your work email address"
|
||||
id="email" name="email"/>
|
||||
<input type="submit" class="btn btn-primary btn-large" value="Sign up"/>
|
||||
</form>
|
||||
<div id="errors"></div>
|
||||
{% if form.email.errors %}
|
||||
{% for error in form.email.errors %}
|
||||
<div class="alert alert-error">{{ error }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
<div class="alert alert-pitch" id="company-email">Please use your
|
||||
company email address to sign up. Otherwise, we won’t be able to
|
||||
|
|
|
@ -14,12 +14,8 @@ hence the name.
|
|||
{% block content %}
|
||||
<div class="navbar">
|
||||
<ul class="nav pull-right">
|
||||
{% if full_navbar %}
|
||||
<li><a href="#">Learn More</a></li>
|
||||
<li><a href="#">Pricing</a></li>
|
||||
<li><a href="https://blog.humbughq.com/">Blog</a></li>
|
||||
{% endif %}
|
||||
<li><a href="/accounts/login/?next=/">Log in</a></li>
|
||||
<li><a href="{% url zephyr.views.accounts_home %}">Register</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
|
|
|
@ -2,6 +2,10 @@ from django import forms
|
|||
from django.core import validators
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from humbug import settings
|
||||
from models import Realm
|
||||
|
||||
def is_unique(value):
|
||||
try:
|
||||
|
@ -17,6 +21,19 @@ def is_active(value):
|
|||
except User.DoesNotExist:
|
||||
pass
|
||||
|
||||
SIGNUP_STRING = '<a href="http://get.humbughq.com/">Sign up</a> to find out when Humbug is ready for you.'
|
||||
|
||||
def has_valid_realm(value):
|
||||
try:
|
||||
Realm.objects.get(domain=value.split("@")[-1])
|
||||
except Realm.DoesNotExist:
|
||||
raise ValidationError(mark_safe(u'Registration is not currently available for your domain. ' + SIGNUP_STRING))
|
||||
|
||||
def isnt_mit(value):
|
||||
if "@mit.edu" in value:
|
||||
raise ValidationError(mark_safe(u'Humbug for MIT is by invitation only. ' + SIGNUP_STRING))
|
||||
|
||||
|
||||
class UniqueEmailField(forms.EmailField):
|
||||
default_validators = [validators.validate_email, is_unique]
|
||||
|
||||
|
@ -26,4 +43,8 @@ class RegistrationForm(forms.Form):
|
|||
terms = forms.BooleanField(required=True)
|
||||
|
||||
class HomepageForm(forms.Form):
|
||||
email = UniqueEmailField()
|
||||
if settings.ALLOW_REGISTER:
|
||||
email = UniqueEmailField()
|
||||
else:
|
||||
validators = UniqueEmailField.default_validators + [has_valid_realm, isnt_mit]
|
||||
email = UniqueEmailField(validators=validators)
|
||||
|
|
|
@ -141,7 +141,9 @@ def accounts_home(request):
|
|||
is_unique(email)
|
||||
except ValidationError:
|
||||
return HttpResponseRedirect(reverse('django.contrib.auth.views.login') + '?email=' + urllib.quote_plus(email))
|
||||
return render_to_response('zephyr/accounts_home.html',
|
||||
else:
|
||||
form = HomepageForm()
|
||||
return render_to_response('zephyr/accounts_home.html', {'form': form},
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
@login_required(login_url = settings.HOME_NOT_LOGGED_IN)
|
||||
|
|
Loading…
Reference in New Issue