From c5fc1fe94a312b6f193d0a4402e6eaa132f5440a Mon Sep 17 00:00:00 2001 From: nukeop Date: Tue, 3 Jan 2017 15:24:35 +0100 Subject: [PATCH] CSS and csometic --- smash/__init__.py | 2 +- smash/static/css/custom.css | 19 ++++++++++++++- smash/templates/latest.html | 27 ++++++++++++++++++---- smash/templates/queue.html | 14 ++++++----- smash/views.py | 46 ++++++++++++------------------------- 5 files changed, 64 insertions(+), 44 deletions(-) diff --git a/smash/__init__.py b/smash/__init__.py index 3d9a9b1..85d19dd 100644 --- a/smash/__init__.py +++ b/smash/__init__.py @@ -1,6 +1,6 @@ import os from flask import Flask, g -from flask.ext.sqlalchemy import SQLAlchemy +from flask_sqlalchemy import SQLAlchemy from . import config, log diff --git a/smash/static/css/custom.css b/smash/static/css/custom.css index ef5e9c9..f66abef 100644 --- a/smash/static/css/custom.css +++ b/smash/static/css/custom.css @@ -96,14 +96,26 @@ html, body { } .quote-link { - color: #03A9F4; + color: #424242; font-weight: bold; + padding-left: 8px; } .quote { font-family: 'Inconsolata', monospace; } +.quote-header { + background-color: #b3e5fc; + border-bottom: 1px solid; + border-color: #4fc3f7; + margin-bottom: 2px; +} + +.quote-date { + padding-right: 8px; +} + .rate-positive { color: #4caf50; } @@ -134,3 +146,8 @@ html, body { .badge { background-color: #03A9F4; } + +.btn-mod { + padding: 2px 8px; + border-radius: 0px; +} diff --git a/smash/templates/latest.html b/smash/templates/latest.html index eb15d24..7549ede 100644 --- a/smash/templates/latest.html +++ b/smash/templates/latest.html @@ -3,8 +3,21 @@ {% if quotes %} {% for quote in quotes %} -#{{ quote.id }} -+ ({{quote.rating}}) -
+
+ #{{ quote.id }} + + ({{quote.rating}}) - +
{{ quote.time }}
+
+ +{% if session.authorized %} +
+
+ + +
+
+{% endif %} +

{{ quote.content|safe }}

@@ -12,9 +25,13 @@
Tags: - {% for tag in quote.tags %} - {{tag.name}} - {% endfor %} + {% if quote.tags|length > 0 and quote.tags[0].name|length>0%} + {% for tag in quote.tags %} + {{tag.name}} + {% endfor %} + {% else %} + No tags + {% endif %}
{% endfor %} diff --git a/smash/templates/queue.html b/smash/templates/queue.html index 924b1d2..d45a8a8 100644 --- a/smash/templates/queue.html +++ b/smash/templates/queue.html @@ -4,19 +4,21 @@ {% if quotes %} {% for quote in quotes %} #{{ quote.id }} -+ ({{quote.rating}}) -
-
-

{{ quote.content|safe }}

-
++ ({{quote.rating}}) -
- - + +
+
+

{{ quote.content|safe }}

+
+ +
Tags: diff --git a/smash/views.py b/smash/views.py index 9c886ba..39f6cce 100644 --- a/smash/views.py +++ b/smash/views.py @@ -13,6 +13,14 @@ def timestamp(): return datetime.datetime.now().strftime("%H:%M:%S %d/%m/%y") +def message(level, msg): + return render_template( + "message.html", + alertclass=level, + message=msg + ) + + @app.before_request def before_request(): g.appname = conf.config['APPNAME'] @@ -62,21 +70,13 @@ def latest(): quotes=quotes ) else: - return render_template( - "message.html", - alertclass="alert-warning", - message="No quotes in the database. " - ) + return message("alert-warning", "No quotes in the database.") @app.route('/queue') def queue(): if not session.get('authorized'): - return render_template( - "message.html", - alertclass="alert-danger", - message="You are not authorized to view this page." - ) + return message("alert-danger", "You are not authorized to view this page.") quotes = Quote.query.filter_by(approved=False).order_by(Quote.id).all() @@ -91,43 +91,27 @@ def queue(): quotes=quotes ) else: - return render_template( - "message.html", - alertclass="alert-warning", - message="No quotes in the database. " - ) + return message("alert-warning", "No quotes in the database.") @app.route('/moderate', methods=['POST']) def moderate(): if not session.get('authorized'): - return render_template( - "message.html", - alertclass="alert-danger", - message="You are not authorized to perform this action." - ) - + return message("alert-danger", "You are not authorized to perform this action.") if request.form['submit'] == "Approve": quote = Quote.query.filter_by(id=request.form['quoteid']).first() quote.approved = True db.session.commit() - return render_template( - "message.html", - alertclass="alert-success", - message="Quote approved." - ) + return message("alert-success", "Quote approved.") + elif request.form['submit'] == "Delete": quote = Quote.query.filter_by(id=request.form['quoteid']).first() db.session.delete(quote) db.session.commit() - return render_template( - "message.html", - alertclass="alert-success", - message="Quote deleted." - ) + return message("alert-success", "Quote deleted.") abort(501)