model.Transfer.debtor==request.environ['user'],
model.Transfer.creditor==request.environ['user'])).\
limit(10).all()
+ c.users = meta.Session.query(model.User.id, model.User)
return render('/status/index.mako')
Provides the BaseController class for subclassing.
"""
+
from decorator import decorator
-from pylons import request, tmpl_context as c
+from pylons import request, session, tmpl_context as c
from pylons.controllers import WSGIController
from pylons.i18n import _, ungettext, N_
-from pylons.templating import render_mako as render
+from pylons.templating import render_mako
+
+from mako.exceptions import TopLevelLookupException
import bluechips.lib.helpers as h
from bluechips import model
return func(*args, **kwargs)
return redirect_on_get_wrap
+def render(name, *args, **kwargs):
+ if 'iPhone' in request.user_agent:
+ if session.get('use_non_mobile'):
+ c.mobile_client = True
+ else:
+ try:
+ return render_mako('/mobile' + name, *args, **kwargs)
+ except TopLevelLookupException:
+ pass
+ return render_mako(name, *args, **kwargs)
__all__ = ['c', 'h', 'render', 'model', 'meta', '_', 'ungettext', 'N_',
'BaseController', 'update_sar', 'redirect_on_get']
--- /dev/null
+body {
+ width: auto;
+ font-size: 1em;
+}
+#tabs img {
+ width: 64px;
+ height: 64px;
+}
+#tabs a {
+ text-align: center;
+ display: block;
+ width: 98px;
+ float: left;
+ border-top: 1px solid #fff;
+ border-bottom: 1px solid #000;
+ padding: 5px 1px;
+}
+#tabs a.selected {
+ border: 1px solid #000;
+ border-bottom: 1px solid #fff;
+ padding: 5px 0;
+ -webkit-border-top-left-radius: 10px;
+ -webkit-border-top-right-radius: 10px;
+}
+#tabs:after {
+ content: ".";
+ display: block;
+ clear: both;
+ visibility: hidden;
+ line-height: 0;
+ height: 0;
+ margin-bottom: 10px;
+}
+div.tab {
+ display: none;
+}
+#tab-status {
+ display: block;
+}
--- /dev/null
+try {
+ console.log("init");
+} catch(e) {
+ console = { log: function() {} };
+}
+
+$(function() {
+ console.log("ready()");
+
+ $('#tabs a').click(function() {
+ $('div.tab').hide();
+ $('#tabs a').removeClass('selected');
+ $(this).addClass('selected');
+ $('#tab-' + $(this).attr('id')).show();
+ return false;
+ });
+
+ console.log("ready() done");
+});
+
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <title>${self.title()}</title>
+ ${h.stylesheet_link('/css/main.css')}
+ <link media="only screen and (max-device-width: 480px)" href="/css/mobile.css" type="text/css" rel="stylesheet">
+ <meta name="viewport" content="width = device-width, user-scalable=no">
+ <link rel="apple-touch-icon" href="/icons/apple-touch.png">
+ </head>
+ <body>
+ ${next.body()}
+ ${h.javascript_link('/js/jquery-1.3.2.js')}
+ ${h.javascript_link('/js/mobile.js')}
+ </body>
+</html>
+
+<%def name="title()">BlueChips
+% if c.title != '':
+ :: ${c.title}
+% endif
+</%def>
+
+<%def name="formatUser(user)">
+ % if user == request.environ['user']:
+ <strong>Me</strong>
+ % else:
+ ${user.name}
+ % endif
+</%def>
--- /dev/null
+<%inherit file="/mobile/base.mako"/>
+
+<h1>${c.code}</h1>
+
+<h2><a href="${h.url_for('/')}">Return</a>
--- /dev/null
+<%inherit file="/mobile/base.mako"/>
+
+<%!
+ from datetime import date
+%>
+
+<div id="tabs">
+ <a id="status" class="selected" href="#">
+ <img src="/icons/dashboard.png" alt="">
+ <span>Dashboard</span>
+ </a>
+ <a id="spend" href="#">
+ <img src="/icons/spend.png" alt="">
+ <span>Expense</span>
+ </a>
+ <a id="transfer" href="#">
+ <img src="/icons/transfer.png" alt="">
+ <span>Transfer</span>
+ </a>
+</div>
+
+<div id="tab-status" class="tab">
+ % for message in h.flash.pop_messages():
+ <div class="flash">${message | n}</div>
+ % endfor
+
+ % if len(c.settle) == 0:
+ <p>No need! The books are balanced!</p>
+ % else:
+ <p>To balance the books, the following transfers need to be made:</p>
+
+ <table id="balance">
+ <tr>
+ <th>From</th>
+ <th>To</th>
+ <th>Amount</th>
+ </tr>
+ % for transfer in c.settle:
+ <tr>
+ <td>${transfer[0].name}</td>
+ <td>${transfer[1].name}</td>
+ <td>${transfer[2]}</td>
+ </tr>
+ % endfor
+ </table>
+ % endif
+</div>
+
+<div id="tab-spend" class="tab">
+ <form action="${h.url_for(controller='spend', action='update')}" method="post">
+ ${h.auth_token_hidden_field()}
+ <table class="form">
+ <tr>
+ <th><label for="spender_id">Spender</label></th>
+ <td>${h.select('spender_id', [request.environ['user'].id], c.users)}</td>
+ </tr>
+ <tr>
+ <th><label for="amount">Amount</label></th>
+ <td>${h.currency('amount', 0, size=8)}</td>
+ </tr>
+ <tr>
+ <th><label for="date">Date</label></th>
+ <td>${h.text('date', date.today().strftime('%m/%d/%Y'), size=16)}</td>
+ </tr>
+ <tr>
+ <th><label for="description">Description</label></th>
+ <td>${h.text('description')}</td>
+ </tr>
+ </table>
+
+ <p>Change how an expenditure is split up.</p>
+
+ <table class="form">
+ % for ii, user_row in enumerate(c.users):
+ <%
+ user_id, user = user_row
+ if user.resident:
+ percent = 1
+ else:
+ percent = 0
+ %>
+ <tr>
+ <th><label for="shares-${ii}amount">${user.name}</label></th>
+ <td>
+ ${h.text('shares-%d.amount' % ii, percent)}
+ ${h.hidden('shares-%d.user_id' % ii, user.id)}
+ </td>
+ </tr>
+ % endfor
+ <tr>
+ <td colspan="2">
+ ${h.submit(None, 'Submit', class_="submitbutton")}
+ </td>
+ </tr>
+ </table>
+ </form>
+</div>
+
+<div id="tab-transfer" class="tab">
+ <form action="${h.url_for(controller='transfer', action='update')}" method="post">
+ ${h.auth_token_hidden_field()}
+ <table class="form">
+ <tr>
+ <th><label for="debtor_id">From</label></th>
+ <td>${h.select('debtor_id', request.environ['user'].id, c.users)}</td>
+ </tr>
+ <tr>
+ <th><label for="creditor_id">To</label></th>
+ <td>${h.select('creditor_id', None, c.users)}</td>
+ </tr>
+ <tr>
+ <th><label for="amount">Amount</label></th>
+ <td>${h.currency('amount', 0, size=8)}</td>
+ </tr>
+ <tr>
+ <th><label for="date">Date</label></th>
+ <td>${h.text('date', date.today().strftime('%m/%d/%Y'), size=16)}</td>
+ </tr>
+ <tr>
+ <th><label for="description">Description</label></th>
+ <td>${h.text('description')}</td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <input type="submit" value="Submit" />
+ </td>
+ </tr>
+ </table>
+ </form>
+</div>
<%inherit file="/base.mako"/>
-<%!
- from decimal import Decimal
-%>
-
<form action="${h.url_for(controller='spend', action='update', id=c.expenditure.id)}" method="post">
${h.auth_token_hidden_field()}
<table class="form">