From 1b3a8b9c40e4bafe4167a711912dcb1d9fb96117 Mon Sep 17 00:00:00 2001 From: Abhigyan Ghosh Date: Wed, 21 Feb 2024 12:13:57 +0530 Subject: [PATCH] testing changes --- webapp/shop/cred/views.py | 74 +++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/webapp/shop/cred/views.py b/webapp/shop/cred/views.py index e1c3780d1c8..5c93c45510d 100644 --- a/webapp/shop/cred/views.py +++ b/webapp/shop/cred/views.py @@ -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") @@ -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] @@ -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 = [ {