]> asedeno.scripts.mit.edu Git - bluechips.git/commitdiff
added interface to edit email address
authorScott Torborg <scott@crookedmedia.com>
Thu, 5 Nov 2009 07:28:05 +0000 (21:28 -1000)
committerScott Torborg <scott@crookedmedia.com>
Thu, 5 Nov 2009 07:28:05 +0000 (21:28 -1000)
bluechips/controllers/user.py [new file with mode: 0644]
bluechips/public/css/main.css
bluechips/public/icons/user.png [new file with mode: 0644]
bluechips/templates/base.mako
bluechips/templates/user/index.mako [new file with mode: 0644]

diff --git a/bluechips/controllers/user.py b/bluechips/controllers/user.py
new file mode 100644 (file)
index 0000000..c586643
--- /dev/null
@@ -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('/')
index f3440c6f903968dd180d497c7b1047e2fa5debfa..c55df6c37b6477276078435654f8bd7b9aa6e50b 100644 (file)
@@ -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 (file)
index 0000000..795a416
Binary files /dev/null and b/bluechips/public/icons/user.png differ
index f194e2001c90d6113e7019123cda634edc5cb37a..e44a9ee148441d25e668f784c9d19de33091e955 100644 (file)
               <span>History</span>
             </a>
           </td>
+          <td>
+            <a href="${h.url_for(controller='user', action='index', id=None)}">
+              <img src="/icons/user.png" alt="">
+              <span>User</span>
+            </a>
+          </td>
         </tr>
       </table>
     </div>
diff --git a/bluechips/templates/user/index.mako b/bluechips/templates/user/index.mako
new file mode 100644 (file)
index 0000000..c293252
--- /dev/null
@@ -0,0 +1,14 @@
+<%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>