SQLMIGRATION flask design thread date

This commit is contained in:
Andreas Stephanides
2017-08-11 16:23:10 +02:00
parent 67213b957b
commit ba6add107c
19 changed files with 249 additions and 31 deletions

View File

@@ -5,7 +5,7 @@ from flask import Flask,jsonify,send_from_directory, render_template
from config import Config
import yaml
import os
from sqlalchemy import desc
from storage import MailThread,db_session
app = Flask(__name__, template_folder="templates", static_folder="static")
@@ -20,20 +20,35 @@ def render_index(mths,code=200):
), code
from classifier import get_pipe
mail_threads=db_session.query(MailThread).all()
pipe1,le=get_pipe("pipe1",b"answered")
pipe2,le2=get_pipe("pipe2b", b"maintopic")
pipe3,le3=get_pipe("pipe2b", b"lang")
#pipe1,le=get_pipe("pipe1",b"answered")
#pipe2,le2=get_pipe("pipe2b", b"maintopic")
#pipe3,le3=get_pipe("pipe2b", b"lang")
answered=le.inverse_transform(pipe1.predict(mail_threads))
maintopic=le2.inverse_transform(pipe2.predict(mail_threads))
lang=le3.inverse_transform(pipe3.predict(mail_threads))
#answered=le.inverse_transform(pipe1.predict(mail_threads))
#maintopic=le2.inverse_transform(pipe2.predict(mail_threads))
#lang=le3.inverse_transform(pipe3.predict(mail_threads))
#for i, t in enumerate(mail_threads):
# t.answered=answered[i]
# t.maintopic=maintopic[i]
# t.lang=lang[i]
for i, t in enumerate(mail_threads):
t.answered=answered[i]
t.maintopic=maintopic[i]
t.lang=lang[i]
@app.route("/")
def hello():
mth=mail_threads
mth=db_session.query(MailThread).order_by(desc(MailThread.date)).all()
return render_index(mth)
@app.route("/answered/<id>/<value>")
def store_answered(id, value):
mth=db_session.query(MailThread).filter(MailThread.firstmail==int(id)).first()
value= value in ["true", "True", "1", "t"]
mth.answered=bool(value)
mth.opened=bool(value)
return render_index([mth])
@app.route("/studium")
def studium():
mth=db_session.query(MailThread).filter(MailThread.maintopic=="studium").order_by(desc(MailThread.date)).all()
return render_index(mth)

View File

@@ -6,27 +6,32 @@
<script src="static/bootstrap/js/bootstrap.min.js" ></script>
</head>
<body>
<style>
.card.opened-True {
background: lightgreen;
}
</style>
<div class="container">
<div class="row">
<div class="col-12">
<h1>{{title}}</h1>
<div id="accordion" role="tablist" aria-multiselectable="true">
<h1>{{title}}</h1>
<div id="accordion" role="tablist" aria-multiselectable="true">
{% for m in mths %}
<div class="card" style="padding-top: 2pt; padding-bottom:2pt; border-radius:0;margin-top:1pt; margin-bottom:1pt">
<div class="card opened-{{m.opened}}" 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">
{{m.tstr()}}
<b class="mb-0">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse{{m.firstmail}}" aria-expanded="true" aria-controls="collapse1">
{{m.tstr()}}
</a>
</b>
</b>
</div>
<div id="collapse{{m.firstmail}}" class="collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="card-block">
<div style="white-space: pre-wrap;font:Courier, monospace; font-size:small; width:50em; border: thin blue solid;"> {{ m.text() }} </div>
<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>
@@ -36,7 +41,7 @@
{% for m in mths %}
ID: {{m.tstr()}}
{{ m.text() }}
{{ m.print_text() }}
{% endfor %}
</div>