small fixes and improvements
This commit is contained in:
@@ -13,10 +13,11 @@ package_directory = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
cfg = Config(file(os.path.join(package_directory, 'config.cfg')))
|
||||
|
||||
maintopic_values=["studium", "information","ausleihen","jobausschreibung", "umfragen"]
|
||||
|
||||
def render_index(mths,opened=None,code=200):
|
||||
return render_template("index.html",mths=mths,
|
||||
title=cfg.title.decode("utf8"),opened=opened
|
||||
title=cfg.title.decode("utf8"),opened=opened,maintopics=maintopic_values
|
||||
), code
|
||||
from classifier import get_pipe
|
||||
#mail_threads=db_session.query(MailThread).all()
|
||||
@@ -33,7 +34,6 @@ from classifier import get_pipe
|
||||
# t.maintopic=maintopic[i]
|
||||
# t.lang=lang[i]
|
||||
|
||||
maintopic_values=["studium", "information","ausleihen"]
|
||||
|
||||
@app.route("/")
|
||||
def hello():
|
||||
@@ -49,10 +49,13 @@ def store_value(id,key,value):
|
||||
mth.opened=bool(value)
|
||||
if key=="maintopic" and value in maintopic_values:
|
||||
mth.maintopic=str(value)
|
||||
if key=="lang" and value in maintopic_values:
|
||||
mth.lang=str(value)
|
||||
if key =="trained":
|
||||
value = value in ["true", "True", "1", "t"]
|
||||
mth.istrained=bool(value)
|
||||
|
||||
db_session.add(mth)
|
||||
db_session.commit()
|
||||
@app.route("/<int:id>")
|
||||
def store_answered(id):
|
||||
|
||||
@@ -60,6 +63,7 @@ def store_answered(id):
|
||||
value = request.args.get('value')
|
||||
if not key is None and not value is None:
|
||||
store_value(id,key,value)
|
||||
mth=db_session.query(MailThread).filter(MailThread.firstmail==int(id)).first()
|
||||
|
||||
return render_index([mth], opened=id)
|
||||
|
||||
@@ -73,7 +77,10 @@ def studium():
|
||||
|
||||
@app.route("/<maintopic>/")
|
||||
def maintopic(maintopic):
|
||||
mth=db_session.query(MailThread).filter(MailThread.maintopic=="%s" % maintopic).order_by(desc(MailThread.date)).all()
|
||||
if maintopic == "trained":
|
||||
mth=db_session.query(MailThread).filter(MailThread.istrained==True).order_by(desc(MailThread.date)).all()
|
||||
else:
|
||||
mth=db_session.query(MailThread).filter(MailThread.maintopic=="%s" % maintopic).order_by(desc(MailThread.date)).all()
|
||||
return render_index(mth)
|
||||
|
||||
@app.route("/<maintopic>/<int:id>")
|
||||
|
||||
@@ -1,55 +1,104 @@
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>{{title}}</title>
|
||||
<script src="/static/jquery-3.2.0.min.js" ></script>
|
||||
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"/>
|
||||
<script src="/static/bootstrap/js/bootstrap.min.js" ></script>
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
.card.answ-1,.card.answ-True {
|
||||
background: lightgreen;
|
||||
}
|
||||
</style>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>{{title}}</h1>
|
||||
<head>
|
||||
<title>{{title}}</title>
|
||||
<script src="/static/jquery-3.2.0.min.js" ></script>
|
||||
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"/>
|
||||
<script src="/static/bootstrap/js/bootstrap.min.js" ></script>
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
.card.answ-1,.card.answ-True {
|
||||
background: lightgreen;
|
||||
}
|
||||
.card.trained-1,.card.trained-True {
|
||||
border: solid blue;
|
||||
}
|
||||
</style>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>{{title}}</h1>
|
||||
|
||||
<div id="accordion" role="tablist" aria-multiselectable="true">
|
||||
|
||||
{% for m in mths %}
|
||||
<div class="card answ-{{m.is_answered()}} trained-{{m.istrained}}" style="padding-top: 2pt; padding-bottom:2pt; border-radius:0;margin-top:1pt; margin-bottom:1pt">
|
||||
<div class="" role="tab" id="heading{{m.firstmail}}">
|
||||
<b class="mb-0">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapse{{m.firstmail}}" aria-expanded="true" aria-controls="collapse1">
|
||||
{% if m.istrained %} trained: {% endif %} {{m.tstr()}}
|
||||
</a>
|
||||
</b>
|
||||
</div>
|
||||
|
||||
<div id="collapse{{m.firstmail}}" class="collapse {{'show' if m.firstmail==opened}}" role="tabpanel" aria-labelledby="headingOne">
|
||||
|
||||
<div class="card-block">
|
||||
|
||||
<div id="accordion" role="tablist" aria-multiselectable="true">
|
||||
<div class="nav">
|
||||
<div class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" id="dropdownMenuLink1_{{m.firstmail}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"> {% if m.is_answered() %}
|
||||
IS answered
|
||||
{% else %}
|
||||
ISNOT answered
|
||||
{% endif %}
|
||||
</a>
|
||||
<div class="dropdown-menu" arialabelledby="dropdownMenuLink1_{{m.firstmail}}">
|
||||
|
||||
{% for m in mths %}
|
||||
<div class="card answ-{{m.is_answered()}}" style="padding-top: 2pt; padding-bottom:2pt; border-radius:0;margin-top:1pt; margin-bottom:1pt">
|
||||
<div class="" role="tab" id="heading{{m.firstmail}}">
|
||||
<b class="mb-0">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapse{{m.firstmail}}" aria-expanded="true" aria-controls="collapse1">
|
||||
{% if m.istrained %} trained: {% endif %} {{m.tstr()}}
|
||||
</a>
|
||||
</b>
|
||||
</div>
|
||||
|
||||
<div id="collapse{{m.firstmail}}" class="collapse {{'show' if m.firstmail==opened}}" role="tabpanel" aria-labelledby="headingOne">
|
||||
|
||||
<div class="card-block">
|
||||
<a href="{{m.firstmail}}?key=answered&value={{(not m.is_answered())}}">answered:{{(not m.is_answered())}}</a>
|
||||
{{m.maintopic}}, {{ m.istrained }} <a href="{{m.firstmail}}?key=trained&value={{(not m.istrained)}}">trained:{{(not m.istrained)}}</a>
|
||||
<div style="white-space: pre-wrap;font:Courier, monospace; font-size:small; width:50em; border: thin blue solid;">
|
||||
{{ m.print_text() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<a class="btn" href="{{m.firstmail}}?key=answered&value={{(not m.is_answered())}}">answered:{{(not m.is_answered())}}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div style="white-space: pre-wrap;font:Courier, monospace; font-size:small; width:50em">
|
||||
|
||||
{% for m in mths %}
|
||||
ID: {{m.tstr()}}
|
||||
{{ m.print_text() }}
|
||||
<div class="dropdown nav-item">
|
||||
<a class="nav-link dropdown-toggle" id="dropdownMenuLink2_{{m.firstmail}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"> {{m.maintopic}}</a>
|
||||
<div class="dropdown-menu" arialabelledby="dropdownMenuLink2_{{m.firstmail}}">
|
||||
{% for t in maintopics %}
|
||||
<a class="dropdown-item" href="{{m.firstmail}}?key=maintopic&value={{t}}">{{t}}</a>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" id="dropdownMenuLink3_{{m.firstmail}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"> {% if m.istrained %}
|
||||
IS trained
|
||||
{% else %}
|
||||
ISNOT trained
|
||||
{% endif %}
|
||||
</a>
|
||||
<div class="dropdown-menu" arialabelledby="dropdownMenuLink3_{{m.firstmail}}">
|
||||
<a class="btn" href="{{m.firstmail}}?key=trained&value={{(not m.istrained)}}">TRAINED:{{(not m.istrained)}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" id="dropdownMenuLink4_{{m.firstmail}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"> {{ m.lang }}
|
||||
</a>
|
||||
<div class="dropdown-menu" arialabelledby="dropdownMenuLink3_{{m.firstmail}}">
|
||||
{% for l in ["de", "en"] %}
|
||||
|
||||
<a class="btn" href="{{m.firstmail}}?key=lang&value={{l}}">{{(l)}}</a>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% for txt in m.print_text() %}
|
||||
<div style="white-space: pre-wrap;font:Courier, monospace; font-size:small; width:50em; border: thin blue solid;">
|
||||
{{ txt }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user