Skip to content
__init__.py 1.18 KiB
Newer Older
#!/usr/bin/python
# -*- coding: UTF-8 -*-

from flask import Blueprint

from const import pfsp
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.
    """
    marks = config.db.query_fetchall( "SELECT mark_info.*, files.note FROM mark_info INNER JOIN files ON mark_info.uuid = files.uuid" )
    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" ]:
            for old in "{}":
                try:
                    v[ col ] = v[ col ].replace( old, "" )
                except:
                    pass
    return my_render_template( 
        "trainer/search.html",
        marks = marks,
        all_detection_technics = all_detection_technics,
        surfaces = surfaces,
        all_pfsp = pfsp.zones