diff --git a/scribeengine/controllers/account.py b/scribeengine/controllers/account.py index 04da535..97a14e2 100644 --- a/scribeengine/controllers/account.py +++ b/scribeengine/controllers/account.py @@ -37,7 +37,7 @@ log = logging.getLogger(__name__) class AccountController(BaseController): def index(self): - h.redirect_to('/account/login') + h.redirect_to(h.url_for(controller=u'account', action=u'login')) def register(self): c.page_title = u'Register' @@ -95,11 +95,11 @@ class AccountController(BaseController): 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')) + h.redirect_to(h.url_for(controller=u'account', 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')) + h.redirect_to(h.url_for(controller=u'account', action=u'register')) user = Session.query(User)\ .filter_by(id=id)\ .filter_by(activation_key=activation_code)\ @@ -115,7 +115,7 @@ class AccountController(BaseController): h.flash.set_message(u'Your account has been activated! Please log in ' u'with your e-mail address and the password you typed in during ' u'registration.', u'success') - h.redirect_to(h.url_for(action=u'login')) + h.redirect_to(h.url_for(controller=u'account', action=u'login')) def login(self): c.page_title = u'Login' @@ -141,11 +141,11 @@ class AccountController(BaseController): 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(h.url_for(action=u'login')) + h.redirect_to(h.url_for(controller=u'account', 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')) + h.redirect_to(h.url_for(controller=u'account', action=u'login')) elif user and user.password == password: log.debug('Logged in successfully.') redirect_url = str(session.get(u'redirect_url', u'/')) @@ -160,7 +160,7 @@ class AccountController(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(h.url_for(action=u'login')) + h.redirect_to(h.url_for(controller=u'account', action=u'login')) def logout(self): del session[u'REMOTE_USER'] diff --git a/scribeengine/controllers/post.py b/scribeengine/controllers/post.py index a3fbc2a..f0359f4 100644 --- a/scribeengine/controllers/post.py +++ b/scribeengine/controllers/post.py @@ -43,19 +43,19 @@ class PostController(BaseController): @authenticate(u'Add Posts') def new(self): - c.page_title = 'New Post' + c.page_title = u'New Post' return render(u'/post/new.mako') @authenticate(u'Edit My Posts') def edit(self, id=None): if id is None: - h.redirect_to('/post/new') + h.redirect_to(h.url_for(controller=u'post', action=u'new')) c.post = Session.query(Post).get(id) if len(c.post.tags): c.post.tags_list = u', '.join([tag.name for tag in c.post.tags]) else: c.post.tags_list = u'' - c.page_title = 'Edit Post: %s' % c.post.title + c.page_title = u'Edit Post: %s' % c.post.title return render(u'/post/edit.mako') @authenticate(u'Edit My Posts') @@ -87,9 +87,9 @@ class PostController(BaseController): Session.add(post) Session.commit() if c.form_values[u'action'] == u'Save Draft': - h.redirect_to(h.url_for(action=u'draft')) + h.redirect_to(h.url_for(controller=u'post', action=u'draft')) else: - h.redirect_to(str('/archive/%s/%s' % (post.created.strftime('%Y/%m/%d'), post.url))) + h.redirect_to(h.url_for_post(post)) def draft(self): posts = Session.query(Post)\ diff --git a/scribeengine/lib/helpers.py b/scribeengine/lib/helpers.py index b751c7a..1e02a6d 100644 --- a/scribeengine/lib/helpers.py +++ b/scribeengine/lib/helpers.py @@ -80,12 +80,12 @@ def teaser(text): def url_for_post(post): #TODO: this is hard coded. return url_for( - controller='blog', - action='view', + controller=u'blog', + action=u'view', year=post.created.strftime('%Y'), month=post.created.strftime('%m'), day=post.created.strftime('%d'), url=post.url - ) + ) flash = Flash() diff --git a/scribeengine/templates/account/login.mako b/scribeengine/templates/account/login.mako new file mode 100644 index 0000000..ed11b2c --- /dev/null +++ b/scribeengine/templates/account/login.mako @@ -0,0 +1,22 @@ +<%inherit file="/base.mako"/> + <%include file="/flash.mako"/> +
You must be logged in to post a comment.
+You must be logged in to post a comment.
% else: