--- a/swtstore/classes/models/sweet.py +++ b/swtstore/classes/models/sweet.py @@ -99,7 +99,7 @@ def getFrontendSwts(): return Sweet.query.order_by(Sweet.created.desc()).all() - # get sweets all sweets authored by a particular user + # get all sweets authored by a particular user @staticmethod def getByCreator(user): return Sweet.query.filter_by(who=user).\ @@ -125,7 +125,8 @@ 'context_id': self.context_id, 'where': self.where, 'how': self.how, - 'created': self.created.isoformat() + #'created': self.created.isoformat() + 'created': self.created.strftime('%a, %d %b %Y, %I:%M %p UTC'), } --- a/swtstore/classes/models/user.py +++ b/swtstore/classes/models/user.py @@ -60,8 +60,10 @@ 'id': self.id, 'username': self.username, 'email': self.email, - 'created': self.created.isoformat(), - 'last_active': self.last_active.isoformat() + #'created': self.created.isoformat(), + 'created': self.created.strftime('%a, %d %b %Y, %I:%M %p UTC'), + #'last_active': self.last_active.isoformat() + 'last_active': self.last_active.strftime('%a, %d %b %Y, %I:%M %p UTC') } def __repr__(self): --- a/swtstore/classes/views/frontend.py +++ b/swtstore/classes/views/frontend.py @@ -5,8 +5,6 @@ from flask import Module, jsonify, request, render_template, redirect,\ url_for, g, current_app -from sqlalchemy import desc - from swtstore.classes.models import Sweet, User @@ -15,8 +13,7 @@ @frontend.route('/', methods=['GET']) def index(): sweets = Sweet.getFrontendSwts() - - user = User.getCurrentUser() + sweets = [sweet.to_dict() for sweet in sweets] return render_template('frontend/index.html', sweets=sweets) --- a/swtstore/classes/views/sweet.py +++ b/swtstore/classes/views/sweet.py @@ -21,7 +21,7 @@ sweet = Sweet.query.get(id) if sweet: print "sweet found " + str(sweet) - return render_template('sweet/specific.html', sweet=sweet) + return render_template('sweet/specific.html', sweet=sweet.to_dict()) else: abort(404) --- a/swtstore/classes/views/user.py +++ b/swtstore/classes/views/user.py @@ -89,7 +89,7 @@ return redirect(url_for('frontend.index')) if request.method == 'GET': - return render_template('user/me.html', user=current_user) + return render_template('user/me.html', user=current_user.to_dict()) # else POST request username = request.form.get('username') @@ -110,6 +110,7 @@ return redirect(url_for('frontend.index')) swts = Sweet.getByCreator(user) + swts = [swt.to_dict() for swt in swts] return render_template('user/sweets.html', sweets=swts) --- a/swtstore/static/css/style.css +++ b/swtstore/static/css/style.css @@ -23,4 +23,8 @@ font-size: 0.8em; text-align: center; } +.created { + font-size: 0.9em; + font-style: italic; +} --- a/swtstore/templates/frontend/index.html +++ b/swtstore/templates/frontend/index.html @@ -6,16 +6,16 @@ {% if sweets|length > 0 %} -
+ {{ user.last_active }} +
+