summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico von Geyso <Nico.Geyso@FU-Berlin.de>2012-10-29 18:36:17 +0100
committerNico von Geyso <Nico.Geyso@FU-Berlin.de>2012-10-29 18:36:17 +0100
commit1b27fe03a87aad1ed693d6197633c7ade2e68a1f (patch)
tree774d5d69a2c10b03792d8e749548848d9508ccb2
parentc5823c2473a5301f4799e41717a21c8d5ab56466 (diff)
parent815df16283c6332c1c4ba9d129fd745cabf57315 (diff)
downloadweb-1b27fe03a87aad1ed693d6197633c7ade2e68a1f.tar.gz
web-1b27fe03a87aad1ed693d6197633c7ade2e68a1f.tar.bz2
web-1b27fe03a87aad1ed693d6197633c7ade2e68a1f.zip
Merge branch 'master' of ssh://git.spline.de/account-web
-rw-r--r--app.py7
-rw-r--r--default_settings.py4
-rw-r--r--forms.py6
-rw-r--r--templates/about.html4
-rw-r--r--templates/register.html1
-rw-r--r--utils.py5
6 files changed, 20 insertions, 7 deletions
diff --git a/app.py b/app.py
index bb4b072..6419571 100644
--- a/app.py
+++ b/app.py
@@ -113,6 +113,13 @@ def register_complete(token):
# populate request context and session
assert login_user(user.uid, user.password)
+ if app.config.get('MAIL_REGISTER_NOTIFY'):
+ send_mail(
+ app.config['MAIL_REGISTER_NOTIFY'],
+ u'[accounts] Neuer Benutzer %s erstellt' % username,
+ 'Benutzername: %s\nE-Mail: %s\n' % (username, mail)
+ )
+
flash(u'Benutzer erfolgreich angelegt.', 'success')
return redirect(url_for('settings'))
diff --git a/default_settings.py b/default_settings.py
index 2a74829..45491fa 100644
--- a/default_settings.py
+++ b/default_settings.py
@@ -7,8 +7,8 @@ SECRET_KEY = 'remember to change this to something more random and secret'
# CHANGE THIS! (e.g. os.urandom(32) )
PASSWORD_ENCRYPTION_KEY = '.\x14\xa7\x1b\xa2:\x1b\xb7\xbck\x1bD w\xab\x87a\xb4\xb7\xca\xf1\x06\xb0\x9f?q\x13\x05\x8dY\xe5<'
-MAIL_DEFAULT_SENDER = 'help-me-help-me-please@spline.de'
-MAIL_CONFIRM_SENDER = 'spline accounts <noreply@account.spline.de>'
+MAIL_DEFAULT_SENDER = 'spline accounts <noreply@accounts.spline.de>'
+MAIL_REGISTER_NOTIFY = None
SENDMAIL_COMMAND = '/usr/sbin/sendmail'
diff --git a/forms.py b/forms.py
index b14e612..516c8ca 100644
--- a/forms.py
+++ b/forms.py
@@ -19,6 +19,8 @@ class RegisterForm(Form):
NotRegexp(_username_exclude_re, message=u'Dieser Benutzername ist nicht erlaubt.'),
])
mail = TextField('E-Mail-Adresse', [validators.Email(), validators.Length(min=6, max=50)])
+ question = TextField('Hauptstadt von Deutschland?', [validators.AnyOf(('Berlin', 'berlin'),
+ message=u'Bitte beantworte die Frage.')])
def validate_username(form, field):
try:
@@ -30,7 +32,7 @@ class RegisterForm(Form):
raise ValidationError(Markup(u'Dieser Benutzername ist momentan nicht erlaubt. '
u'<a href="%s">Weitere Informationen</a>' % url_for('about')))
else:
- raise ValidationError(u'Dieser Benutzername ist schon vergeben')
+ raise ValidationError(u'Dieser Benutzername ist schon vergeben.')
def validate_mail(form, field):
#TODO
@@ -45,6 +47,8 @@ class AdminCreateAccountForm(RegisterForm):
else:
raise ValidationError(u'Dieser Benutzername ist schon vergeben')
+ question = None
+
class RegisterCompleteForm(Form):
password = PasswordField('Passwort', [validators.Required(),
diff --git a/templates/about.html b/templates/about.html
index 3056e97..ceb1fc8 100644
--- a/templates/about.html
+++ b/templates/about.html
@@ -25,8 +25,8 @@
</p>
<p>
Wenn du schon einen Benutzernamen in einem der alten Dienste hast, kannst
- du uns Bescheid sagen, dann erstellen wir dir von Hand einen Account.
-{# TODO: kontaktmöglichkeit #}
+ du uns <a href="mailto:accounts@spline.de">Bescheid sagen</a>, dann
+ erstellen wir dir von Hand einen Account.
</p>
<h2>Welche Dienste sind bisher dabei?</h2>
<ul>
diff --git a/templates/register.html b/templates/register.html
index e724e2f..7f56280 100644
--- a/templates/register.html
+++ b/templates/register.html
@@ -16,6 +16,7 @@
<form action="{{ url_for('register') }}" method="post" class="form-horizontal">
{{ render_field(form.username, autofocus="autofocus") }}
{{ render_field(form.mail) }}
+ {{ render_field(form.question) }}
{{ render_submit(value='E-Mail-Adresse bestätigen')}}
</form>
{%- endblock %}
diff --git a/utils.py b/utils.py
index 595f770..ca0fb16 100644
--- a/utils.py
+++ b/utils.py
@@ -20,7 +20,7 @@ from wtforms.validators import Regexp
-_username_re = re.compile(r'^[a-zA-Z][a-zA-Z0-9-]{1,15}')
+_username_re = re.compile(r'^[a-zA-Z][a-zA-Z0-9-]{1,15}$')
_username_exclude_re = re.compile(r'^(admin|root)')
# using http://flask.pocoo.org/docs/patterns/viewdecorators/
@@ -234,7 +234,8 @@ def url_for(endpoint, **values):
"""Wrap `flask.url_for` so that it always returns https links"""
#XXX: Drop this in favor of config.PREFERRED_URL_SCHEME when we require Flask 0.9
u = flask_url_for(endpoint, **values)
- if '_external' in values and u.startswith('http://'):
+ if '_external' in values and u.startswith('http://') \
+ and current_app.config['PREFERRED_URL_SCHEME'] == 'https':
return 'https://' + u[7:]
else:
return u