Skip to content

Commit

Permalink
testing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abhigyanghosh30 committed Feb 21, 2024
1 parent 43a3e79 commit 1b3a8b9
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions webapp/shop/cred/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,34 +114,36 @@ def cred_schedule(ua_contracts_api, trueability_api, **_):
contract_item_id = data["contractItemID"]
first_name, last_name = get_user_first_last_name()
country_code = TIMEZONE_COUNTRIES[timezone]

response = ua_contracts_api.post_assessment_reservation(
contract_item_id,
first_name,
last_name,
timezone,
starts_at.isoformat(),
country_code,
)

if response and "error" in response:
error = response["message"]
return flask.render_template(
"/credentials/schedule.html", error=error
)
else:
uuid = response.get("reservation", {}).get("IDs", [])[-1]
exam = {
"name": "CUE: Linux",
"date": starts_at.strftime("%d %b %Y"),
"time": starts_at.strftime("%I:%M %p %Z"),
"uuid": uuid,
"contract_item_id": contract_item_id,
}
return flask.render_template(
"/credentials/schedule-confirm.html", exam=exam
try:
response = ua_contracts_api.post_assessment_reservation(
contract_item_id,
first_name,
last_name,
timezone,
starts_at.isoformat(),
country_code,
)

if response and "error" in response:
error = response["message"]
return flask.render_template(
"/credentials/schedule.html", error=error
)
else:
uuid = response.get("reservation", {}).get("IDs", [])[-1]
exam = {
"name": "CUE: Linux",
"date": starts_at.strftime("%d %b %Y"),
"time": starts_at.strftime("%I:%M %p %Z"),
"uuid": uuid,
"contract_item_id": contract_item_id,
}
return flask.render_template(
"/credentials/schedule-confirm.html", exam=exam
)
except Exception as e:
print("Exception:",e)

contract_item_id = flask.request.args.get("contractItemID")
if contract_item_id is None:
return flask.redirect("/credentials/your-exams")
Expand Down Expand Up @@ -210,17 +212,6 @@ def cred_your_exams(ua_contracts_api, trueability_api, **kwargs):
exam_contract.get("id") or exam_contract["contractItem"]["id"]
)

if (
"effectivenessContext" in exam_contract
and "status" in exam_contract["effectivenessContext"]
and exam_contract["effectivenessContext"]["status"]
== "expired"
):
exams_expired.append(
{"name": name, "state": "Expired", "actions": []}
)
continue

if "reservation" in exam_contract["cueContext"]:
response = trueability_api.get_assessment_reservation(
exam_contract["cueContext"]["reservation"]["IDs"][-1]
Expand Down Expand Up @@ -314,6 +305,15 @@ def cred_your_exams(ua_contracts_api, trueability_api, **kwargs):
"actions": actions,
}
)
elif (
"effectivenessContext" in exam_contract
and "status" in exam_contract["effectivenessContext"]
and exam_contract["effectivenessContext"]["status"]
== "expired"
):
exams_expired.append(
{"name": name, "state": "Expired", "actions": []}
)
else:
actions = [
{
Expand Down

0 comments on commit 1b3a8b9

Please sign in to comment.