Add constants module.
This commit is contained in:
16
app.py
16
app.py
@@ -6,12 +6,13 @@ from flask import Flask, g, render_template, request, redirect, session
|
|||||||
|
|
||||||
import db
|
import db
|
||||||
import models
|
import models
|
||||||
|
import const
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(filename='estus-shots.log', level=logging.DEBUG)
|
logging.basicConfig(filename=const.LOG_PATH, level=logging.DEBUG)
|
||||||
|
|
||||||
logging.info(f'Starting with working dir: {os.getcwd()}')
|
logging.info(f'Starting in working dir: {os.getcwd()}')
|
||||||
logging.info(f'App file location: {os.path.abspath(__file__)}')
|
logging.info(f'App base path: {const.BASE_PATH}')
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@@ -127,8 +128,15 @@ def save_season():
|
|||||||
def season_overview(id: int):
|
def season_overview(id: int):
|
||||||
sql, args = db.load_season(id)
|
sql, args = db.load_season(id)
|
||||||
db_season = db.query_db(sql, args, one=True, cls=models.Season)
|
db_season = db.query_db(sql, args, one=True, cls=models.Season)
|
||||||
|
infos = {
|
||||||
|
'Number': db_season.code,
|
||||||
|
'Game': db_season.game,
|
||||||
|
'Start Date': db_season.start,
|
||||||
|
'End Date': db_season.end if db_season.end else 'Ongoing'
|
||||||
|
}
|
||||||
model = {
|
model = {
|
||||||
'title': f'{db_season.code} {db_season.game}'
|
'title': f'{db_season.code} {db_season.game}',
|
||||||
|
'season_info': infos
|
||||||
}
|
}
|
||||||
return render_template('seasonoverview.html', model=model)
|
return render_template('seasonoverview.html', model=model)
|
||||||
|
|
||||||
|
|||||||
9
const.py
Normal file
9
const.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
BASE_PATH = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
DATABASE_NAME = 'es_debug.db'
|
||||||
|
DATABASE_PATH = os.path.join(BASE_PATH, DATABASE_NAME)
|
||||||
|
|
||||||
|
LOG_NAME = 'estus-shots.log'
|
||||||
|
LOG_PATH = os.path.join(BASE_PATH, LOG_NAME)
|
||||||
8
db.py
8
db.py
@@ -3,17 +3,15 @@ import logging as log
|
|||||||
from flask import g
|
from flask import g
|
||||||
|
|
||||||
import models
|
import models
|
||||||
|
import const
|
||||||
|
|
||||||
DATABASE = 'database/es_debug.db'
|
|
||||||
|
|
||||||
|
|
||||||
def connect_db():
|
def connect_db():
|
||||||
"""Create a new sqlite3 connection and register it in 'g._database'"""
|
"""Create a new sqlite3 connection and register it in 'g._database'"""
|
||||||
db = getattr(g, '_database', None)
|
db = getattr(g, '_database', None)
|
||||||
if db is None:
|
if db is None:
|
||||||
log.info(f'Connecting {DATABASE}')
|
log.info(f'Connecting {const.DATABASE_NAME}')
|
||||||
db = g._database = sqlite3.connect(DATABASE)
|
db = g._database = sqlite3.connect(const.DATABASE_PATH)
|
||||||
|
|
||||||
db.row_factory = sqlite3.Row
|
db.row_factory = sqlite3.Row
|
||||||
return db
|
return db
|
||||||
|
|||||||
@@ -3,5 +3,40 @@
|
|||||||
{% block title %}{{ model.title }}{% endblock %}
|
{% block title %}{{ model.title }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
{# Overview #}
|
||||||
|
<div class="col-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header text-center">
|
||||||
|
{{ model.title }}
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Infos</h5>
|
||||||
|
{% for item in model.season_info %}
|
||||||
|
<div class="card-text">
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<span class="font-weight-bold">{{ item }}:</span>
|
||||||
|
{{ model.season_info[item] }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# Episode List #}
|
||||||
|
<div class="col">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header text-center">Episodes</div>
|
||||||
|
<div class="card-body">
|
||||||
|
Episode list here
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user