--- /dev/null
+"""
+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('/')
--- /dev/null
+<%inherit file="/base.mako"/>
+
+<h2>Email Notifications</h2>
+
+<p>Enter an email address below if you wish to be notified of any updates to transactions involving you. Leave blank to not receive notifications.</p>
+<form action="${h.url_for(controller='user', action='update')}" method="post">
+ <table class="form">
+ <tr>
+ <th><label for="new_email">Email</label></th>
+ <td>${h.text('new_email', request.environ['user'].email, size=48)}</td>
+ <td><input type="submit" value="Update" /></td>
+ </tr>
+ </table>
+</form>