From 8401ab6a4fd6a13eb32f8a9060f804e2f8b41ed9 Mon Sep 17 00:00:00 2001 From: hanfi <hanfi@spahan.ch> Date: Fri, 26 May 2023 23:29:45 +0200 Subject: [PATCH] make min/max date range configurable --- transporte/config.cfg.example | 3 +++ transporte/forms.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/transporte/config.cfg.example b/transporte/config.cfg.example index fdd71cf..a802cda 100644 --- a/transporte/config.cfg.example +++ b/transporte/config.cfg.example @@ -7,6 +7,9 @@ UPLOAD_DIR = 'uploads' SQLALCHEMY_DATABASE_URI = 'sqlite:///app.db' SQLALCHEMY_TRACK_MODIFICATIONS = False +MIN_DATE = '2023-07-17' +MAX_DATE = '2023-09-01' + #The passwords in this list need to be unique. #Login via /login/password/<password> SPECIAL_HELPDESK_ACCOUNTS = [{ diff --git a/transporte/forms.py b/transporte/forms.py index c6ce8e7..d21f1ee 100644 --- a/transporte/forms.py +++ b/transporte/forms.py @@ -1,5 +1,6 @@ -import datetime +from datetime import datetime +from flask import current_app as app from flask_wtf import FlaskForm from flask_wtf.file import FileField from wtforms import SelectField, StringField, SubmitField, TextAreaField @@ -40,8 +41,8 @@ class TransportForm(FlaskForm): validators=[ DataRequired(), DateRange( - min=datetime.date(year=2023, month=7, day=17), - max=datetime.date(year=2023, month=9, day=17), + min=datetime.strptime(app.config["MIN_DATE"], "%Y-%m-%d"), + max=datetime.strptime(app.config["MAX_DATE"], "%Y-%m-%d"), ), ], ) -- GitLab