diff --git a/app.py b/app.py index c250e5d..ec2e246 100644 --- a/app.py +++ b/app.py @@ -66,11 +66,7 @@ def logout(): @app.route('/') @authorize def landing(): - if 'editor' in session['role']: - print('editor') - else: - print('not editor') - return render_template('seasons.html') + return redirect('/seasons') @app.route('/seasons') @@ -81,6 +77,7 @@ def seasons(): model = { 'seasons': results, 'columns': [ + ('code', '#'), ('game', 'Game'), ('description', 'Season Description'), ('start', 'Started At'), @@ -117,6 +114,17 @@ def save_season(): return redirect('/seasons') +@app.route('/seasons/', 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']) @authorize def new_player(): diff --git a/db.py b/db.py index 4ac5ab0..bf475d0 100644 --- a/db.py +++ b/db.py @@ -128,13 +128,23 @@ def load_enemies(id=None): def save_season_query(season): if not season.id: - sql = 'insert into season values (?, ?, ?, ?, ?)' - args = (None, season.game, season.description, season.start, season.end) + sql = 'insert into season values (?, ?, ?, ?, ?, ?)' + args = (None, + season.game, + season.description, + season.start, + season.end, + season.code) else: sql = 'update season ' \ - 'set game=?, description=?, start=?, end=? ' \ + 'set game=?, description=?, start=?, end=?, code=? ' \ '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 diff --git a/models.py b/models.py index 4698563..7430a5e 100644 --- a/models.py +++ b/models.py @@ -78,6 +78,7 @@ class Season: description: str start: datetime.date end: datetime.date + code: str @classmethod def from_form(cls, form): @@ -104,5 +105,7 @@ class Season: except Exception: 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 diff --git a/schema.sql b/schema.sql index abaff16..dfb73c6 100644 --- a/schema.sql +++ b/schema.sql @@ -6,7 +6,8 @@ create table if not exists season game text, description text, start text, - end text + end text, + code text ); create unique index if not exists season_id_uindex diff --git a/templates/editseason.html b/templates/editseason.html index 270fe70..1c5f3f1 100644 --- a/templates/editseason.html +++ b/templates/editseason.html @@ -14,6 +14,14 @@ value="{{ model['id'] }}" readonly> +
+ + +