CSS and csometic

This commit is contained in:
nukeop 2017-01-03 15:24:35 +01:00
parent f77a8c7260
commit c5fc1fe94a
5 changed files with 64 additions and 44 deletions

View file

@ -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

View file

@ -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;
}

View file

@ -3,8 +3,21 @@
{% if quotes %}
{% for quote in quotes %}
<div class="quote-header">
<a class="quote-link" href="quote/{{ quote.id }}">#{{ quote.id }}</a>
<a class="rate-positive">+</a> ({{quote.rating}}) <a class="rate-negative">-</a></br>
<a class="rate-positive">+</a> ({{quote.rating}}) <a class="rate-negative">-</a>
<div class="pull-right quote-date">{{ quote.time }}</div>
</div>
{% if session.authorized %}
<form action="/moderate" name="moderate" method="post">
<div class="btn-group" role="group">
<input type="hidden" name="quoteid" value={{quote.id}} />
<button type="submit" name="submit" class="btn btn-danger btn-sm btn-mod" value="Delete">Delete</button>
</div>
</form>
{% endif %}
<div class="quote">
<p>{{ quote.content|safe }}</p>
</div>
@ -12,9 +25,13 @@
<div class="tags">
Tags:
{% if quote.tags|length > 0 and quote.tags[0].name|length>0%}
{% for tag in quote.tags %}
<a href="tag/{{tag.name}}" class="badge"> {{tag.name}} </a>
{% endfor %}
{% else %}
<strong> No tags </strong>
{% endif %}
</div>
{% endfor %}

View file

@ -4,19 +4,21 @@
{% if quotes %}
{% for quote in quotes %}
<a class="quote-link" href="quote/{{ quote.id }}">#{{ quote.id }}</a>
<a class="rate-positive">+</a> ({{quote.rating}}) <a class="rate-negative">-</a></br>
<div class="quote">
<p>{{ quote.content|safe }}</p>
</div>
<a class="rate-positive">+</a> ({{quote.rating}}) <a class="rate-negative">-</a>
<form action="/moderate" name="moderate" method="post">
<div class="btn-group" role="group">
<input type="hidden" name="quoteid" value={{quote.id}} />
<button type="submit" name="submit" class="btn btn-success btn-sm" value="Approve">Approve</button>
<button type="submit" name="submit" class="btn btn-danger btn-sm" value="Delete">Delete</button>
<button type="submit" name="submit" class="btn btn-success btn-sm btn-mod" value="Approve">Approve</button>
<button type="submit" name="submit" class="btn btn-danger btn-sm btn-mod" value="Delete">Delete</button>
</div>
</form>
<div class="quote">
<p>{{ quote.content|safe }}</p>
</div>
<div class="tags">
Tags:

View file

@ -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)