Commit 9f6e3416063cdcbb6195745be7b71dfe96c4a448

Sweet store is now timestamp aware

  - adding timestamp validation and display in UI
  - removed the interface to add posts manually
  • Diff rendering mode:
  • inline
  • side by side

swtr.py

3737
38def validateSweet(payload):38def validateSweet(payload):
39 for i in payload:39 for i in payload:
40 if len(i['who']) and len(i['what']) and len(i['where']) and len(i['how']):
41 pass
42 else:
40 try:
41 if len(i['who']) and len(i['what']) and len(i['where']) and\
42 len(i['how']) and len(i['created']):
43 pass
44 else:
45 return False
46 except KeyError:
43 return False47 return False
44 return True
48 return True
4549
46@app.before_request50@app.before_request
47def init_db():51def init_db():

templates/layout.html

11 <div class="page">11 <div class="page">
12 <h1>SWeeT Store</h1>12 <h1>SWeeT Store</h1>
13 <div class=metanav>13 <div class=metanav>
14 <a href="{{ url_for('show_entries') }}"> Home </a> |
14 {% if not session.logged_in %}15 {% if not session.logged_in %}
15 <a href="{{ url_for('login') }}">Log In</a>16 <a href="{{ url_for('login') }}">Log In</a>
16 {% else %}17 {% else %}
18 <a href="{{ url_for('user') }}"> Users </a> |
17 <a href="{{ url_for('serveUser') }}">Add User</a> |19 <a href="{{ url_for('serveUser') }}">Add User</a> |
18 <a href="{{ url_for('logout') }}">Log Out</a>20 <a href="{{ url_for('logout') }}">Log Out</a>
19 {% endif %}21 {% endif %}

templates/show_entries.html

1{% extends "layout.html" %}1{% extends "layout.html" %}
2{% block body %}2{% block body %}
3 {% if session.logged_in %}
4 <form action="{{ url_for('add_entry') }}" method="POST" class="add-entry">
5 <dl>
6 <dt>Who:</dt>
7 <dd><input type="text" name="who"></dd>
8 <dt>What:</dt>
9 <dd><input type="text" size="30" name="what"></dd>
10 <dt>Where:</dt>
11 <dd><input type="text" size="30" name="where"></dd>
12 <dt>How:</dt>
13 <dd><textarea name="how" rows="6" cols="40"></textarea></dd>
14 <dd><input type="submit" value=" Share "></dd>
15 </dl>
16 </form>
17 {% endif %}
18 <ul class="entries">3 <ul class="entries">
19 {% if entries|len > 0 %}4 {% if entries|len > 0 %}
20 {% for entry in entries %}5 {% for entry in entries %}
21 <li>6 <li>
22 @<b>{{ entry.who }}</b>7 @<b>{{ entry.who }}</b>
23 <b>#{{ entry.what }}</b> /{{ entry.where }} {{ entry.how|safe }}8 <b>#{{ entry.what }}</b> /{{ entry.where }} {{ entry.how|safe }}
9 {% if entry.created|len > 0 %}
10 <span><small>created: {{entry.created }}</small></span>
11 {% endif %}
24 <a class="pull-right" href={{ "/posts/" + entry.id }}>12 <a class="pull-right" href={{ "/posts/" + entry.id }}>
25 <i class="icon-share-alt"></i>13 <i class="icon-share-alt"></i>
26 </a>14 </a>