From: Scott Torborg Date: Thu, 5 Nov 2009 07:28:05 +0000 (-1000) Subject: added interface to edit email address X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=5a2b93f758a19dc3c354c636903a4944b6aff305;p=bluechips.git added interface to edit email address --- diff --git a/bluechips/controllers/user.py b/bluechips/controllers/user.py new file mode 100644 index 0000000..c586643 --- /dev/null +++ b/bluechips/controllers/user.py @@ -0,0 +1,41 @@ +""" +Calculate the current state of the books +""" + +import logging + +from bluechips.lib.base import * + +import sqlalchemy +from sqlalchemy import orm + +from pylons import request +from pylons.decorators import validate + +from formencode import validators, Schema + +log = logging.getLogger(__name__) + + +class EmailSchema(Schema): + "Validate email updates." + allow_extra_fields = False + new_email = validators.Email() + + +class UserController(BaseController): + def index(self): + return render('/user/index.mako') + + @validate(schema=EmailSchema(), form='index') + def update(self): + new_email = self.form_result['new_email'] + if new_email == '': + new_email = None + request.environ['user'].email = new_email + meta.Session.commit() + if new_email is None: + h.flash("Removed email address.") + else: + h.flash("Updated email address to '%s'." % new_email) + return h.redirect_to('/') diff --git a/bluechips/public/css/main.css b/bluechips/public/css/main.css index f3440c6..c55df6c 100644 --- a/bluechips/public/css/main.css +++ b/bluechips/public/css/main.css @@ -29,7 +29,7 @@ a:visited { text-align: center; } #nav td { - padding: 5px 20px; + padding: 5px 15px; } table { border-collapse: collapse; @@ -42,6 +42,9 @@ div.block { padding: 0 10px; border-bottom: 1px solid #bbb; } +table.form { + margin-bottom: 10px; +} table.form th { text-align: right; } diff --git a/bluechips/public/icons/user.png b/bluechips/public/icons/user.png new file mode 100644 index 0000000..795a416 Binary files /dev/null and b/bluechips/public/icons/user.png differ diff --git a/bluechips/templates/base.mako b/bluechips/templates/base.mako index f194e20..e44a9ee 100644 --- a/bluechips/templates/base.mako +++ b/bluechips/templates/base.mako @@ -44,6 +44,12 @@ History + + + + User + + diff --git a/bluechips/templates/user/index.mako b/bluechips/templates/user/index.mako new file mode 100644 index 0000000..c293252 --- /dev/null +++ b/bluechips/templates/user/index.mako @@ -0,0 +1,14 @@ +<%inherit file="/base.mako"/> + +

Email Notifications

+ +

Enter an email address below if you wish to be notified of any updates to transactions involving you. Leave blank to not receive notifications.

+
+ + + + + + +
${h.text('new_email', request.environ['user'].email, size=48)}
+