Newer
Older
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from flask import Blueprint
from const import pfsp
import config
from utils.decorator import login_required
from utils.template import my_render_template
trainer_view = Blueprint( "trainer", __name__, template_folder = "templates" )
@trainer_view.route( "/trainer/search" )
@login_required
def search():
"""
Provide the search page.
"""

Marco De Donno
committed
files.id,
files.uuid,
mark_info.pfsp,
mark_info.detection_technic,
mark_info.surface,
files.note,
users.username

Marco De Donno
committed
FROM files
LEFT JOIN mark_info ON mark_info.uuid = files.uuid
LEFT JOIN submissions ON files.folder = submissions.id
LEFT JOIN users ON submissions.donor_id = users.id

Marco De Donno
committed
WHERE ( files.type = 3 OR files.type = 4 )
ORDER BY files.id ASC
"""
marks = config.db.query_fetchall( sql )
all_detection_technics = config.db.query_fetchall( "SELECT * FROM detection_technics ORDER BY name ASC" )
surfaces = config.db.query_fetchall( "SELECT * FROM surfaces ORDER BY name ASC" )
for _, v in enumerate( marks ):
for col in [ "detection_technic", "surface", "note" ]:
for old, new in [ ( "{", "" ), ( "}", "" ), ( "\n", "; " ) ]:
v[ col ] = v[ col ].replace( old, new )
v[ "username" ] = v[ "username" ].replace( "_", " " )
return my_render_template(
"trainer/search.html",
marks = marks,
all_detection_technics = all_detection_technics,
surfaces = surfaces,
all_pfsp = pfsp.zones