Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding fixes for 500 error for wild card urls #639

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions app/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,19 @@ def format_rehydrate_payload(


def find_round_short_name_in_request():
if round_short_name := request.view_args.get("round_short_name") or request.args.get("round"):
if round_short_name := (request.view_args and request.view_args.get("round_short_name")) or (
request.args and request.args.get("round")
):
return round_short_name
else:
return None


def find_round_id_in_request():
if (
application_id := request.args.get("application_id")
or request.view_args.get("application_id")
or request.form.get("application_id")
application_id := (request.args and request.args.get("application_id"))
or (request.view_args and request.view_args.get("application_id"))
or (request.form and request.form.get("application_id"))
):
application = get_application_data(application_id)
return application.round_id
Expand All @@ -160,12 +162,14 @@ def find_round_id_in_request():


def find_fund_id_in_request():
if fund_id := request.view_args.get("fund_id") or request.args.get("fund_id"):
if fund_id := (request.view_args and request.view_args.get("fund_id")) or (
request.args and request.args.get("fund_id")
):
return fund_id
elif (
application_id := request.args.get("application_id")
or request.view_args.get("application_id")
or request.form.get("application_id")
application_id := (request.args and request.args.get("application_id"))
or (request.view_args and request.view_args.get("application_id"))
or (request.form and request.form.get("application_id"))
):
application = get_application_data(application_id)
return application.fund_id
Expand All @@ -174,9 +178,10 @@ def find_fund_id_in_request():


def find_fund_short_name_in_request():
if (fund_short_name := request.view_args.get("fund_short_name") or request.args.get("fund")) and str.upper(
fund_short_name
) in get_all_fund_short_names():
if (
fund_short_name := (request.view_args and request.view_args.get("fund_short_name"))
or (request.args and request.args.get("fund"))
) and (fund_short_name and (str.upper(fund_short_name) in get_all_fund_short_names())):
return fund_short_name
else:
return None
Expand Down