From 0797f5799c5a0282981362ebe495e04b6127ddc8 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 25 Jan 2010 20:39:00 +0200 Subject: [PATCH] Added registration link. Added smtp transport. --- development.ini | 1 + run-server | 2 +- scribeengine/controllers/admin.py | 9 ++++++--- scribeengine/model/tables.py | 8 ++++---- scribeengine/public/styles/style.css | 4 ++++ scribeengine/templates/admin/login.mako | 1 + scribeengine/templates/admin/register.mako | 2 +- 7 files changed, 18 insertions(+), 9 deletions(-) diff --git a/development.ini b/development.ini index db85be5..0e738fe 100644 --- a/development.ini +++ b/development.ini @@ -43,6 +43,7 @@ security.salt = secretsalt mail.on = false mail.manager = immediate +mail.transport = smtp mail.smtp.server = mail.mydomain.com mail.smtp.username = mymailusername mail.smtp.password = mymailpassword diff --git a/run-server b/run-server index 534e752..42cca5b 100755 --- a/run-server +++ b/run-server @@ -1 +1 @@ -/home/raoul/VirtualEnv/ScribeEngine/trunk/bin/paster serve development.ini --reload +/home/raoul/VirtualEnv/ScribeEngine/registration/bin/paster serve development.ini --reload diff --git a/scribeengine/controllers/admin.py b/scribeengine/controllers/admin.py index 8d1148f..c192834 100644 --- a/scribeengine/controllers/admin.py +++ b/scribeengine/controllers/admin.py @@ -90,11 +90,14 @@ class AdminController(BaseController): log.debug('Logging in as "%s" with password "%s"', c.form_values[u'email'], c.form_values[u'password']) user = Session.query(User).filter_by(email=c.form_values[u'email']).first() password = utils.hash_password(c.form_values[u'password']) - log.debug(user) if not user or user.password != password: log.debug('Username or password are incorrect.') h.flash.set_message(u'Your username or password are incorrect.', u'error') - h.redirect_to('/admin/login') + h.redirect_to(h.url_for(action=u'login')) + elif user and user.activation_key is not None: + log.debug('Unactivated account.') + h.flash.set_message(u'Your account has not yet been activated. Please check your e-mail for a link to activate your account.', u'error') + h.redirect_to(h.url_for(action=u'login')) elif user and user.password == password: log.debug('Logged in successfully.') redirect_url = str(session.get(u'redirect_url', u'/')) @@ -109,7 +112,7 @@ class AdminController(BaseController): del session[u'REMOTE_USER'] session.save() h.flash.set_message(u'There was a problem logging you in.', u'error') - h.redirect_to('/admin/login') + h.redirect_to(h.url_for(action=u'login')) def logout(self): del session[u'REMOTE_USER'] diff --git a/scribeengine/model/tables.py b/scribeengine/model/tables.py index af15ec9..9ef1c4b 100644 --- a/scribeengine/model/tables.py +++ b/scribeengine/model/tables.py @@ -100,10 +100,10 @@ users_table = Table(u'users', metadata, Column(u'email', Unicode(200), nullable=False, index=True), Column(u'password', Unicode(64), nullable=False), Column(u'nick', Unicode(50), nullable=False, index=True), - Column(u'first_name', Unicode(100)), - Column(u'last_name', Unicode(100)), - Column(u'homepage', Unicode(200)), - Column(u'activation_key', Unicode(40)) + Column(u'first_name', Unicode(100), default=u''), + Column(u'last_name', Unicode(100), default=u''), + Column(u'homepage', Unicode(200), default=u''), + Column(u'activation_key', Unicode(40), default=None) ) # Definition of the "variables" table diff --git a/scribeengine/public/styles/style.css b/scribeengine/public/styles/style.css index 827903a..0b0f76f 100644 --- a/scribeengine/public/styles/style.css +++ b/scribeengine/public/styles/style.css @@ -404,6 +404,10 @@ fieldset { margin-bottom: 1em; } +#register-now { + margin-left: 1em; +} + /* Message areas */ #form-errors { diff --git a/scribeengine/templates/admin/login.mako b/scribeengine/templates/admin/login.mako index ba5841d..2817dfc 100644 --- a/scribeengine/templates/admin/login.mako +++ b/scribeengine/templates/admin/login.mako @@ -15,6 +15,7 @@
+ No account? Register now!
diff --git a/scribeengine/templates/admin/register.mako b/scribeengine/templates/admin/register.mako index d3edd7d..503b474 100644 --- a/scribeengine/templates/admin/register.mako +++ b/scribeengine/templates/admin/register.mako @@ -22,7 +22,7 @@
- +