From 5a2b93f758a19dc3c354c636903a4944b6aff305 Mon Sep 17 00:00:00 2001 From: Scott Torborg Date: Wed, 4 Nov 2009 21:28:05 -1000 Subject: [PATCH] added interface to edit email address --- bluechips/controllers/user.py | 41 ++++++++++++++++++++++++++++ bluechips/public/css/main.css | 5 +++- bluechips/public/icons/user.png | Bin 0 -> 557 bytes bluechips/templates/base.mako | 6 ++++ bluechips/templates/user/index.mako | 14 ++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 bluechips/controllers/user.py create mode 100644 bluechips/public/icons/user.png create mode 100644 bluechips/templates/user/index.mako 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 0000000000000000000000000000000000000000..795a416457801ec11b45b74c19ed229891cb82e2 GIT binary patch literal 557 zcmV+|0@D47P)+^c9X2S*}=y#fCGSGC`w21cd`?w`qRBeUHhHU$I`a+q6=v zQT_h?9g-ZO(xIBpnvKYfMWsaK^5id?E=i|IbGvdopgQ^d`OW9edcJvYxo#noAn*6@ zVX|O&y?5X6-*LKdXtrlLpE%+vE1v)W0X9iQK~#9!?3M?QgD?z*F=dsu6uS4`8h~A=c{z9 zD%T+h>0Tl8Eqr>E&)fg#$sl6o!lh@q90RYwz~dOi1qLz4AS*D)zWM~>JrHL>TnFMx zl%EChX%zN@USUV-y>CG2aHo5s%75Mycf*tz2GBG)>Ima8nUap))K))wf4;)Fn)mf| z%h-g;sQ!?~`e?$;LS-<%(BnbH?9History + + + + 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)}
+
-- 2.45.2