small fixes and improvements

This commit is contained in:
Andreas Stephanides
2017-08-21 23:55:43 +02:00
parent 81fa9cc575
commit 1645221f93
10 changed files with 380 additions and 111 deletions

View File

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