Add season codes and overview page.
This commit is contained in:
18
app.py
18
app.py
@@ -66,11 +66,7 @@ def logout():
|
|||||||
@app.route('/')
|
@app.route('/')
|
||||||
@authorize
|
@authorize
|
||||||
def landing():
|
def landing():
|
||||||
if 'editor' in session['role']:
|
return redirect('/seasons')
|
||||||
print('editor')
|
|
||||||
else:
|
|
||||||
print('not editor')
|
|
||||||
return render_template('seasons.html')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/seasons')
|
@app.route('/seasons')
|
||||||
@@ -81,6 +77,7 @@ def seasons():
|
|||||||
model = {
|
model = {
|
||||||
'seasons': results,
|
'seasons': results,
|
||||||
'columns': [
|
'columns': [
|
||||||
|
('code', '#'),
|
||||||
('game', 'Game'),
|
('game', 'Game'),
|
||||||
('description', 'Season Description'),
|
('description', 'Season Description'),
|
||||||
('start', 'Started At'),
|
('start', 'Started At'),
|
||||||
@@ -117,6 +114,17 @@ def save_season():
|
|||||||
return redirect('/seasons')
|
return redirect('/seasons')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/seasons/<id>', methods=['GET'])
|
||||||
|
@authorize
|
||||||
|
def season_overview(id: int):
|
||||||
|
sql, args = db.load_season(id)
|
||||||
|
db_season = db.query_db(sql, args, one=True, cls=models.Season)
|
||||||
|
model = {
|
||||||
|
'title': f'{db_season.code} {db_season.game}'
|
||||||
|
}
|
||||||
|
return render_template('seasonoverview.html', model=model)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/newplayer', methods=['GET'])
|
@app.route('/newplayer', methods=['GET'])
|
||||||
@authorize
|
@authorize
|
||||||
def new_player():
|
def new_player():
|
||||||
|
|||||||
18
db.py
18
db.py
@@ -128,13 +128,23 @@ def load_enemies(id=None):
|
|||||||
|
|
||||||
def save_season_query(season):
|
def save_season_query(season):
|
||||||
if not season.id:
|
if not season.id:
|
||||||
sql = 'insert into season values (?, ?, ?, ?, ?)'
|
sql = 'insert into season values (?, ?, ?, ?, ?, ?)'
|
||||||
args = (None, season.game, season.description, season.start, season.end)
|
args = (None,
|
||||||
|
season.game,
|
||||||
|
season.description,
|
||||||
|
season.start,
|
||||||
|
season.end,
|
||||||
|
season.code)
|
||||||
else:
|
else:
|
||||||
sql = 'update season ' \
|
sql = 'update season ' \
|
||||||
'set game=?, description=?, start=?, end=? ' \
|
'set game=?, description=?, start=?, end=?, code=? ' \
|
||||||
'where id==?'
|
'where id==?'
|
||||||
args = (season.game, season.description, season.start, season.end, season.id)
|
args = (season.game,
|
||||||
|
season.description,
|
||||||
|
season.start,
|
||||||
|
season.end,
|
||||||
|
season.code,
|
||||||
|
season.id)
|
||||||
return sql, args
|
return sql, args
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class Season:
|
|||||||
description: str
|
description: str
|
||||||
start: datetime.date
|
start: datetime.date
|
||||||
end: datetime.date
|
end: datetime.date
|
||||||
|
code: str
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_form(cls, form):
|
def from_form(cls, form):
|
||||||
@@ -104,5 +105,7 @@ class Season:
|
|||||||
except Exception:
|
except Exception:
|
||||||
raise INVALID_STR.format('end')
|
raise INVALID_STR.format('end')
|
||||||
|
|
||||||
self = cls(id, game, description, start, end)
|
code = form.get('code', None)
|
||||||
|
|
||||||
|
self = cls(id, game, description, start, end, code)
|
||||||
return self
|
return self
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ create table if not exists season
|
|||||||
game text,
|
game text,
|
||||||
description text,
|
description text,
|
||||||
start text,
|
start text,
|
||||||
end text
|
end text,
|
||||||
|
code text
|
||||||
);
|
);
|
||||||
|
|
||||||
create unique index if not exists season_id_uindex
|
create unique index if not exists season_id_uindex
|
||||||
|
|||||||
@@ -14,6 +14,14 @@
|
|||||||
value="{{ model['id'] }}"
|
value="{{ model['id'] }}"
|
||||||
readonly>
|
readonly>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="code">Season Code</label>
|
||||||
|
<input name="code"
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
id="code"
|
||||||
|
value="{{ model['code'] }}">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="game">Game Name</label>
|
<label for="game">Game Name</label>
|
||||||
<input name="game"
|
<input name="game"
|
||||||
|
|||||||
7
templates/seasonoverview.html
Normal file
7
templates/seasonoverview.html
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% set active_page = "seasons" %}
|
||||||
|
{% block title %}{{ model.title }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user