diff --git a/development.ini b/development.ini
index f2463cf..21b96c1 100644
--- a/development.ini
+++ b/development.ini
@@ -42,6 +42,7 @@ paths.themes = %(here)s/themes
# Security settings
security.salt = secretsalt
+# Mail server settings
mail.on = false
mail.manager = immediate
mail.transport = smtp
@@ -49,6 +50,9 @@ mail.smtp.server = mail.mydomain.com
mail.smtp.username = mymailusername
mail.smtp.password = mymailpassword
+# Server-related settings
+server.timezone = 'Africa/Johannesburg'
+
# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
# Debug mode will enable the interactive debugging tool, allowing ANYONE to
# execute malicious code after an exception is raised.
diff --git a/scribeengine/controllers/account.py b/scribeengine/controllers/account.py
index 4166965..9df759a 100644
--- a/scribeengine/controllers/account.py
+++ b/scribeengine/controllers/account.py
@@ -55,6 +55,25 @@ class AccountController(BaseController):
message=u'You need to supply a valid e-mail address.')
}
+ def index_schema(self):
+ return {
+ 'account-nick': UnicodeString(not_empty=True,
+ messages={u'empty': u'You need to type in a nick.'}),
+ 'account-email': Email(not_empty=True,
+ messages={u'empty': u'You need to supply a valid e-mail address.'})
+ }
+
+ def index_POST(self):
+ try:
+ for key, value in c.form_values.iteritems():
+ setattr(c.current_user, key[8:], value)
+ Session.add(c.current_user)
+ Session.commit()
+ h.flash.set_message(u'Successfully updated your account.', u'success')
+ except:
+ h.flash.set_message(u'There was a problem updating your account.', u'error')
+ h.redirect_to(h.url_for(controller=u'account'))
+
def register(self):
c.page_title = u'Register'
return render(u'/account/register.mako')
diff --git a/scribeengine/controllers/blog.py b/scribeengine/controllers/blog.py
index 774c05f..da389c3 100644
--- a/scribeengine/controllers/blog.py
+++ b/scribeengine/controllers/blog.py
@@ -25,6 +25,7 @@ from datetime import datetime
from pprint import pformat
from sqlalchemy.sql import or_
+from pytz import timezone
from scribeengine.lib.base import *
from scribeengine.lib import utils
@@ -170,7 +171,10 @@ class BlogController(BaseController):
def calendar(self, year, month):
#c.calendar = Calendar(6)
#c.today = datetime.today()
- c.thismonth = datetime.now().replace(int(year), int(month))
+ server_tz = timezone(config.get(u'server.timezone', u'UTC'))
+ user_tz = c.current_user.timezone if c.current_user.timezone else u'UTC'
+ now = datetime.now(server_tz).astimezone(timezone(user_tz))
+ c.thismonth = now.replace(int(year), int(month))
c.prev_month = c.thismonth - monthdelta(1)
c.next_month = c.thismonth + monthdelta(1)
month_start = datetime(c.thismonth.year, c.thismonth.month, 1, 0, 0, 0, 0)
diff --git a/scribeengine/lib/base.py b/scribeengine/lib/base.py
index d166a30..e20f8f6 100644
--- a/scribeengine/lib/base.py
+++ b/scribeengine/lib/base.py
@@ -39,6 +39,7 @@ from pylons.templating import render_mako
from sqlalchemy.sql.expression import asc, desc
from formencode import Schema, Invalid
from monthdelta import monthdelta
+from pytz import timezone
from scribeengine.lib import helpers as h
from scribeengine.lib.validation import jsvalidate
@@ -57,9 +58,11 @@ class BaseController(WSGIController):
c.categories = Session.query(Category).order_by(Category.name.asc()).all()
c.pages = Session.query(Page).all()
c.calendar = Calendar(6)
- c.today = datetime.today()
+ server_tz = timezone(config.get(u'server.timezone', u'UTC'))
+ user_tz = c.current_user.timezone if c.current_user.timezone else u'UTC'
+ c.today = datetime.now(server_tz).astimezone(timezone(user_tz))
if not c.thismonth:
- c.thismonth = datetime.now()
+ c.thismonth = c.today #datetime.utcnow().astimezone(timezone(c.current_user.timezone))
c.prev_month = c.thismonth - monthdelta(1)
c.next_month = c.thismonth + monthdelta(1)
month_start = datetime(c.thismonth.year, c.thismonth.month, 1, 0, 0, 0, 0)
diff --git a/scribeengine/templates/account/index.mako b/scribeengine/templates/account/index.mako
index 36932d6..252a018 100644
--- a/scribeengine/templates/account/index.mako
+++ b/scribeengine/templates/account/index.mako
@@ -30,7 +30,11 @@