From 9909eeab360ccd63bf997fcaabe81e2e9f89597b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 25 Jan 2010 23:32:48 +0200 Subject: [PATCH] Added activate method. --- scribeengine/controllers/admin.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scribeengine/controllers/admin.py b/scribeengine/controllers/admin.py index c192834..c40b922 100644 --- a/scribeengine/controllers/admin.py +++ b/scribeengine/controllers/admin.py @@ -69,6 +69,29 @@ class AdminController(BaseController): Session.commit() h.redirect_to('/') + def activate(self, id=None): + activation_code = request.GET.get('code') + if not activation_code: + h.flash.set_message(u'Your activation code was missing or ' + u'incorrect. Please check your activation e-mail.', u'error') + h.redirect_to(h.url_for(action=u'register')) + if not id: + h.flash.set_message(u'Your username was missing or incorrect. ' + u'Please check your activation e-mail.', u'error') + h.redirect_to(h.url_for(action=u'register')) + user = Session.get(User)\ + .filter_by(email=id)\ + .filter_by(activation_key=activation_code)\ + .first() + if not user: + h.flash.set_message(u'Your username or activation code is ' + u'incorrect. Please check your activation e-mail.', u'error') + h.redirect_to(h.url_for(action=u'register')) + user.activation_key = None + Session.add(user) + Session.commit() + return render(u'/admin/activate.mako') + def login(self): c.page_title = u'Login' return render(u'/admin/login.mako')