Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
back end validation for recur requests
Browse files Browse the repository at this point in the history
  • Loading branch information
akelch11 committed Aug 21, 2022
1 parent f5bdd1b commit 79ee681
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 14 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def submit_request():
except Exception as ex:
return make_response(render_template('page404.html'), 404)

print('request arguments')
print(request.args, file=stdout)

# validate back end submission of requests to ensure
Expand Down Expand Up @@ -423,10 +424,13 @@ def recur_request_page():
current_recur_req)
print(current_recur_req_string)

print('final call for RR string: ' + current_recur_req_string)

html = render_template('recurrequest.html',
dhalls=dhall_list,
date=datetime.now(),
current_recur_req_string=current_recur_req_string)
current_recur_req_string=current_recur_req_string,
error=error)
response = make_response(html)
return response

Expand All @@ -446,6 +450,14 @@ def submit_recur_request():
except Exception as ex:
return make_response(render_template('page404.html'), 404)

print('recur req args')
print(request.args)

request_is_valid = validate_req(request.args)

if not request_is_valid:
return redirect('/recurrequest?error=invalid_request')

# TODO: add validation to ensure bad requests can't be submitted through url
# mostly just checking meal type alligns w times

Expand Down Expand Up @@ -530,7 +542,7 @@ def add_imports():
meal_requests.clean_requests, 'interval', hours=5)

initialize_usage_metrics = scheduler.add_job(database.create_new_day_usage_metrics, 'cron',
hour=12, minute=7, timezone='America/New_York')
hour=0, minute=0, timezone='America/New_York')
# schedule lunch job to start at 10:00AM ET
recur_lunch_text_job = scheduler.add_job(notifications.send_recurring_request_notifications_lunch,
'cron', hour=9, minute=45, timezone='America/New_York')
Expand Down
10 changes: 9 additions & 1 deletion templates/recurrequest.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body class="forceMaven">
{% include 'header.html' %}

{% if current_recur_req_string != None %}
{% if current_recur_req_string != None and current_recur_req_string != '' %}
<nav class="navbar navbar-expand-lg navbar-light jumbotron" id = 'currentRRHead'>
<div class="container-fluid">
<div class = 'col-md-8'>
Expand Down Expand Up @@ -111,6 +111,14 @@
</div>
</center>

<div class = "container" id = "hoursBox" style = "font-size: 18px;">
Dining Hall Hours: <br>

Lunch: 11:30AM - 2PM / Brunch: 10AM - 2PM
<br>
Dinner: 5PM - 8PM
</div>

<div class="container row" id="errorBox" style="color: red">

<!-- catching invalid requests on back-end -->
Expand Down

0 comments on commit 79ee681

Please sign in to comment.