Commits

Anonymous committed 32ffe11

mockups

Comments (0)

Files changed (8)

foodoptimizr/__init__.py

 def create_app(settings=None):
 
     app = Flask(__name__)
+    app.config.from_object(__name__)
+
     if settings:
         app.config.from_object(settings)
 
+    db.init_app(app)
+
     @app.before_request
     def authenticate():
         g.user = None

foodoptimizr/models.py

         elif day == "green":
             sins = self.item.green_sins
 
+        sins = sins or 0
+
         return sins * qty
 
 

foodoptimizr/static/css/foodoptimizr.css

+
+table {
+    border: 1pt solid #252626;
+}
+
+thead th {
+    background-color:#252626; 
+    color: #fff;
+    font-size: 12pt;
+    font-weight: bold;
+}
+
+td {
+    border-bottom: 1pt solid #252626;
+    font-weight: bold;
+}
+
+td a {
+    color: #252626;
+}
+
+div.header {
+    background-color:#73705D;
+    color: #fff;
+}
+
+div.header h1 {
+    color:#fff;
+    padding: 10px;
+}
+
+div.content {
+    min-height: 500px;
+}
+
+ul.topnav {
+    color: #fff;
+}
+
 ul.topnav {
     margin: 0;
     padding: 0;
+    text-align: right;
 }
 
 ul.topnav li {
     display:inline;
     margin-right: 30px;
 }
+
+ul.topnav a {
+    text-decoration: none;
+    color: #fff;
+    font-weight: bold;
+}
+
+div.navigation {
+    padding-top: 5px;
+    background-color:#252626; 
+    padding-bottom: 5px;
+    margin-bottom: 20px;
+    font-size: 12pt;
+    color: #fff;
+    font-weight:bold;
+}
+
+div.navigation a {
+    color: #fff;
+    text-decoration:none;
+    text-shadow: 5px 0px;
+    font-weight: bold;
+}
+
+div.navigation ul {
+    margin: 0;
+    padding:0;
+    padding-left: 10px;
+}
+
+div.navigation li {
+    display:inline;
+    margin-right: 30px;
+}
+
+div.navigation li.selected, div.calendar li.selected {
+    background-color: #9CA68F;
+    padding: 5px;
+}
+
+tr.red {
+   background-color: #f99; 
+}
+
+tr.green {
+   background-color: #9f9; 
+}
+
+div.calendar {
+    margin-bottom: 20px;
+    background-color:#151C24; 
+}
+
+div.calendar li.previous {
+    text-align: left;
+}
+
+div.calendar li.current {
+    text-align: center;
+    margin-left: 230px;
+}
+
+div.calendar li.following {
+    text-align: right;
+    margin-left: 230px;
+}
+
+

foodoptimizr/templates/add_food.html

+{% extends "layout.html" %}
+
+{% block content %}
+
+<form method="POST" action="" class="span-12 append-12">
+    <fieldset>
+        <label>Description</label><br>
+        <input type="text" size="50">
+    </fieldset>
+
+    <fieldset>
+        <legend>Sins</legend>
+        <label>Green days <input value="0" type="text" size="5"></label>
+        <label>Red days <input value="0" type="text" size="5"></label>
+    </fieldset>
+
+    <fieldset>
+        <legend>Healthy extra</legend>
+        <label>Healthy extra option A <input type="checkbox"></label><br>
+        <label>Healthy extra option B (green days) <input type="checkbox"></label><br>
+        <label>Healthy extra option B (red days) <input type="checkbox"></label><br>
+    </fieldset>
+    <div class="submit">
+        <input type="submit" value="Enter">
+    </div>
+</form>
+{% endblock %}

foodoptimizr/templates/index.html

 {% extends "layout.html" %}
 
 {% block content %}
-Welcome to the Food Optimizr application !
+
+<h2>Dan's diary</h2>
+
+<div class="span-24">
+    <div class="span-12">
+        <h3>Your current limit: <b>12</b> sins</h3>
+    </div>
+    <div class="span-12 last">
+        <h3>Your current weight: <b>120</b> kg</h3>
+    </div>
+</div>
+
+<div class="span-24 navigation calendar">
+    <ul>
+        <li class="previous">
+        	<a href="">&lt;&lt; October 2010</a>
+        </li>
+        <li class="current selected">
+        <a href-"">November 2010</a>
+        </li>
+        <li class="following">
+        	<a href="">December 2010 &gt;&gt;</a>
+        </li>
+    </ul>
+</div>
+
+<table>
+    <thead>
+        <tr>
+            <th>Date</th>
+            <th>Sins</th>
+            <th>Weigh-in (kg)</th>
+        </tr>
+    </thead>
+    <tbody>
+            {% for i in range(20) %}
+            <tr class="{{ ('red', 'green')|random }}">
+                <td><a href="">{{ i + 1 }}.11.2010</a></td>          
+                <td>{{ range(15)|random }}</td>
+                <td>120</td>
+            </tr>
+            {% endfor %}
+    </tbody>
+</table>
+
+<div class="navigation calendar">
+    <ul>
+        <li class="previous">
+        	<a href="">&lt;&lt; October 2010</a>
+        </li>
+        <li class="current selected">
+        <a href-"">November 2010</a>
+        </li>
+        <li class="following">
+        	<a href="">December 2010 &gt;&gt;</a>
+        </li>
+    </ul>
+</div>
+
 {% endblock %}

foodoptimizr/templates/layout.html

 <html lang="en">
 <head>
 	<meta charset="UTF-8">
-	<title></title>
+	<title>foodoptimizr</title>
     <link rel="stylesheet" href="{{ url_for('.static', filename='css/blueprint/screen.css') }}" media="screen"/>
     <link rel="stylesheet" href="{{ url_for('.static', filename='css/blueprint/screen.css') }}" media="print" />
     <!--[if IE]><link rel="stylesheet" href="{{ url_for('.static', filename='css/blueprint/ie.css') }}" /><![endif]--> 
             </div>
         </div><!-- end of header -->
 
+        <div class="span-24 navigation">
+            <ul>
+            	<li class="selected">
+            		<a href="">Calendar</a>
+            	</li>
+            	<li>
+            		<a href="">Make an entry</a>
+            	</li>
+                <li>
+                    <a href="{{ url_for('main.add_food') }}">Add a new food</a>
+                </li>
+               <li>
+                    <a href="">Add a new recipe</a>
+                </li>
+                <li>
+                    <input type="text" placeholder="Find a food">
+                </li>
+ 
+                <li>
+                    <input type="text" placeholder="Find a recipe">
+                </li>
+            </ul>
+        </div>
+
         <div class="span-24 content">
         {% block content %}
         {% endblock %}

foodoptimizr/views/main.py

     return render_template("index.html")
 
 
+@main.route("/add-food/")
+def add_food():
+    return render_template("add_food.html")
 from flaskext.testing import TestCase
 
 from foodoptimizr import create_app
-from foodoptimizr.models import db, Item
+from foodoptimizr.models import db, Item, Entry
 
 class Base(TestCase):
 
                     
     def test_calc_num_sins_red_day_red_item(self):
 
-        item = create_item(healthy_extra_a=True, red_sins=4.5)
+        item = self.create_item(healthy_extra_a=True, red_sins=4.5)
         entry = Entry(item=item, qty=1)
         assert entry.calc_num_sins("red") == 0
 
     def test_calc_num_sins_red_day_green_item(self):
 
-        item = create_item(healthy_extra_a=True, green_sins=4.5)
+        item = self.create_item(healthy_extra_a=True, green_sins=4.5)
         entry = Entry(item=item, qty=1)
         assert entry.calc_num_sins("red") == 4.5
 
     def test_calc_num_sins_green_day_red_item(self):
 
-        item = create_item(healthy_extra_a=True, red_sins=4.5)
+        item = self.create_item(healthy_extra_a=True, red_sins=4.5)
         entry = Entry(item=item, qty=1)
         assert entry.calc_num_sins("green") == 4.5
 
     def test_calc_num_sins_green_day_green_item(self):
 
-        item = create_item(healthy_extra_a=True, green_sins=4.5)
+        item = self.create_item(healthy_extra_a=True, green_sins=4.5)
         entry = Entry(item=item, qty=1)
         assert entry.calc_num_sins("green") == 0
 
     def test_calc_num_sins_red_day_green_item_with_healthy_extra_a(self):
 
-        item = create_item(healthy_extra_a=True, green_sins=4.5)
+        item = self.create_item(healthy_extra_a=True, green_sins=4.5)
         entry = Entry(item=item, qty=1)
         assert entry.calc_num_sins("red") == 0
 
     def test_calc_num_sins_red_day_red_item_with_healthy_extra_a(self):
 
-        item = create_item(healthy_extra_a=True, red_sins=4.5)
+        item = self.create_item(healthy_extra_a=True, red_sins=4.5)
         entry = Entry(item=item, qty=1)
         assert entry.calc_num_sins("red") == 0