mirror of
https://github.com/sartography/uva-covid19-testing-communicator.git
synced 2025-02-23 12:28:26 +00:00
fixing some stupid bugs.
This commit is contained in:
parent
6008b4895d
commit
107c36bf96
@ -115,6 +115,9 @@ def index():
|
||||
action = BASE_HREF + "/"
|
||||
samples = db.session.query(Sample).order_by(Sample.date.desc())
|
||||
|
||||
if request.method == "POST" or request.args.get('cancel') == 'true':
|
||||
session["index_filter"] = {} # Clear out the session if it is invalid.
|
||||
|
||||
if form.validate():
|
||||
session["index_filter"] = {}
|
||||
if form.startDate.data:
|
||||
@ -124,26 +127,25 @@ def index():
|
||||
if form.studentId.data:
|
||||
session["index_filter"]["student_id"] = form.studentId.data
|
||||
if form.location.data:
|
||||
session["index_filter"]["location"] = form.studentId.data
|
||||
session["index_filter"]["location"] = form.location.data
|
||||
if form.download.data:
|
||||
download = True
|
||||
|
||||
# Store previous form submission settings in the session, so they are preseved through pagination.
|
||||
if "index_filter" in session:
|
||||
filters = session["index_filter"]
|
||||
if "start_date" in filters:
|
||||
samples = samples.filter(Sample.date >= filters["start_date"])
|
||||
form.startDate.data = datetime.strptime(filters["start_date"], "%Y-%m-%d")
|
||||
if "end_date" in filters:
|
||||
samples = samples.filter(Sample.date >= filters["end_date"])
|
||||
form.startDate.data = datetime.strptime(filters["end_date"], "%Y-%m-%d")
|
||||
if "student_id" in filters:
|
||||
samples = samples.filter(Sample.date >= filters["student_id"])
|
||||
form.startDate.data = filters["student_id"]
|
||||
if "location" in filters:
|
||||
samples = samples.filter(Sample.date >= filters["location"])
|
||||
form.startDate.data = filters["location"]
|
||||
|
||||
try:
|
||||
if "start_date" in filters:
|
||||
samples = samples.filter(Sample.date >= filters["start_date"])
|
||||
if "end_date" in filters:
|
||||
samples = samples.filter(Sample.date <= filters["end_date"])
|
||||
if "student_id" in filters:
|
||||
samples = samples.filter(Sample.student_id == filters["student_id"])
|
||||
if "location" in filters:
|
||||
samples = samples.filter(Sample.location == filters["location"])
|
||||
except Exception as e:
|
||||
logging.error("Encountered an error building filters, so clearing. " + e)
|
||||
session["index_filter"] = {}
|
||||
|
||||
# display results
|
||||
if download:
|
||||
|
@ -36,7 +36,7 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
<button class="btn btn-primary" type="submit">Submit</button>
|
||||
<a href="{{ url_for('index') }}" class="btn btn-default">Cancel</a>
|
||||
<a href="{{ url_for('index') }}?cancel=true" class="btn btn-default">Cancel</a>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user