From 9df47d7bb6cf2ef5ee9234729af9337585031165 Mon Sep 17 00:00:00 2001 From: luxick Date: Sat, 12 Jan 2019 15:04:40 +0100 Subject: [PATCH] Require code in season. --- models.py | 4 +++- schema.sql | 2 +- templates/editseason.html | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/models.py b/models.py index 7430a5e..f5482bf 100644 --- a/models.py +++ b/models.py @@ -103,9 +103,11 @@ class Season: try: end = datetime.date.fromisoformat(end) except Exception: - raise INVALID_STR.format('end') + raise AttributeError(INVALID_STR.format('end')) code = form.get('code', None) + if not code: + raise AttributeError(INVALID_STR.format('code')) self = cls(id, game, description, start, end, code) return self diff --git a/schema.sql b/schema.sql index dfb73c6..2c9b603 100644 --- a/schema.sql +++ b/schema.sql @@ -7,7 +7,7 @@ create table if not exists season description text, start text, end text, - code text + code text not null ); create unique index if not exists season_id_uindex diff --git a/templates/editseason.html b/templates/editseason.html index 1c5f3f1..babd98b 100644 --- a/templates/editseason.html +++ b/templates/editseason.html @@ -20,7 +20,8 @@ type="text" class="form-control" id="code" - value="{{ model['code'] }}"> + value="{{ model['code'] }}" + required>