Commit 9f6e3416063cdcbb6195745be7b71dfe96c4a448
Sweet store is now timestamp aware
- adding timestamp validation and display in UI
- removed the interface to add posts manually
| | | | 37 | | 37 | |
---|
38 | def validateSweet(payload): | 38 | def 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']): | | if len(i['who']) and len(i['what']) and len(i['where']) and len(i['how']): |
---|
41 | pass | | pass |
---|
42 | else: | | 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 False | 47 | return False |
---|
44 | return True | | return True |
---|
| | 48 | return True | 45 | | 49 | |
---|
46 | @app.before_request | 50 | @app.before_request |
---|
47 | def init_db(): | 51 | def init_db(): |
---|
| | | | 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 %} |
---|
| | | | 1 | {% extends "layout.html" %} | 1 | {% extends "layout.html" %} |
---|
2 | {% block body %} | 2 | {% block body %} |
---|
3 | {% if session.logged_in %} | | {% if session.logged_in %} |
---|
4 | <form action="{{ url_for('add_entry') }}" method="POST" class="add-entry"> | | <form action="{{ url_for('add_entry') }}" method="POST" class="add-entry"> |
---|
5 | <dl> | | <dl> |
---|
6 | <dt>Who:</dt> | | <dt>Who:</dt> |
---|
7 | <dd><input type="text" name="who"></dd> | | <dd><input type="text" name="who"></dd> |
---|
8 | <dt>What:</dt> | | <dt>What:</dt> |
---|
9 | <dd><input type="text" size="30" name="what"></dd> | | <dd><input type="text" size="30" name="what"></dd> |
---|
10 | <dt>Where:</dt> | | <dt>Where:</dt> |
---|
11 | <dd><input type="text" size="30" name="where"></dd> | | <dd><input type="text" size="30" name="where"></dd> |
---|
12 | <dt>How:</dt> | | <dt>How:</dt> |
---|
13 | <dd><textarea name="how" rows="6" cols="40"></textarea></dd> | | <dd><textarea name="how" rows="6" cols="40"></textarea></dd> |
---|
14 | <dd><input type="submit" value=" Share "></dd> | | <dd><input type="submit" value=" Share "></dd> |
---|
15 | </dl> | | </dl> |
---|
16 | </form> | | </form> |
---|
17 | {% endif %} | | {% 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> |
---|