diff --git a/templates/credentials/provision.html b/templates/credentials/provision.html deleted file mode 100644 index 189e2c724b..0000000000 --- a/templates/credentials/provision.html +++ /dev/null @@ -1,56 +0,0 @@ -{% extends "credentials/base_cred.html" %} - -{% block title %}Canonical Credentials -- Provision{% endblock %} - -{% block meta_description %}The Canonical Ubuntu Essentials exams certify knowledge and verify skills in general Linux, Ubuntu Desktop, and Ubuntu Server topics.{% endblock meta_description %} -{% block meta_copydoc %}https://docs.google.com/document/d/1QuhO-9FEOGLrYp8bErS_9snqdljl7d6tFAUoNQxoVDQ/edit{% endblock meta_copydoc %} - -{% block content %} - -
-
- {% if error %} -
-
-
-
Error
-

{{ error }}

-
-
-
- {% endif %} -

Welcome to the CUE: Linux Beta!

-

Take your exam now

- {% if assessment %} - {% set percent_complete = [100 * assessment["provisioning_time"] // assessment["average_provisioning_time"], 100] | min %} - {% if assessment["state"] in ["notified", "released", "in_progress"] %} -

Your exam is ready to go! Click Take Exam to begin.

-

Take Exam

- {% elif assessment["state"] in ["created", "drafted", "provisioning", "provisioned", "notifying"] %} -

Your exam environment is being provisioned ({{ percent_complete }}%).

-
-
-

During this limited testing cycle, exams could potentially take up to 20 minutes to be provisioned under heavy system load.

-
-
- {% else %} -

Your exam is complete. Please make sure that you have completed the exit survey.

- {% endif %} - {% elif reservation %} -

Your exam environment is awaiting provisioning.

-
-
-

During this limited testing cycle, exams could potentially take up to 20 minutes to be provisioned under heavy system load.

-
-
- {% else %} -

Return to your exams ›

- {% endif %} -
-
- - - -{% endblock content%} diff --git a/templates/credentials/schedule.html b/templates/credentials/schedule.html index b2581261d7..377b16dcab 100644 --- a/templates/credentials/schedule.html +++ b/templates/credentials/schedule.html @@ -35,7 +35,7 @@
Error
-

You can schedule or reschedule your exam up to 24 hours in advance.

+

You can schedule your exam to begin 30 minutes from now or later.

Your exam will take up to one hour to complete. Please make sure to plan accordingly before and after to diff --git a/webapp/app.py b/webapp/app.py index f37a7210d5..68ee044355 100644 --- a/webapp/app.py +++ b/webapp/app.py @@ -81,7 +81,6 @@ cred_cancel_exam, cred_exam, cred_home, - cred_provision, cred_redeem_code, cred_schedule, cred_self_study, @@ -1134,11 +1133,6 @@ def takeovers_index(): view_func=cred_submit_form, methods=["GET", "POST"], ) -app.add_url_rule( - "/credentials/provision", - view_func=cred_provision, - methods=["GET", "POST"], -) app.add_url_rule("/credentials/shop/", view_func=cred_shop) app.add_url_rule("/credentials/shop/

", view_func=cred_shop) app.add_url_rule( diff --git a/webapp/shop/cred/views.py b/webapp/shop/cred/views.py index 29cfc58ec2..5b62e8ccd8 100644 --- a/webapp/shop/cred/views.py +++ b/webapp/shop/cred/views.py @@ -13,7 +13,6 @@ from webapp.shop.decorators import shop_decorator, canonical_staff from webapp.shop.utils import get_exam_contract_id, get_user_first_last_name from webapp.login import user_info -from webapp.views import get_user_country_by_ip from google.oauth2 import service_account from googleapiclient.discovery import build @@ -64,8 +63,8 @@ def cred_sign_up(**_): def cred_schedule(ua_contracts_api, trueability_api, **_): error = None now = datetime.utcnow() - min_date = (now + timedelta(days=1)).strftime("%Y-%m-%d") - max_date = (now + timedelta(days=42)).strftime("%Y-%m-%d") + min_date = (now + timedelta(minutes=30)).strftime("%Y-%m-%d") + max_date = (now + timedelta(days=30)).strftime("%Y-%m-%d") if flask.request.method == "POST": data = flask.request.form @@ -265,12 +264,6 @@ def cred_your_exams(ua_contracts_api, trueability_api, **kwargs): f"contractItemID={contract_item_id}", "button_class": "p-button", }, - { - "text": "Take now", - "href": "/credentials/provision?" - f"contractItemID={contract_item_id}", - "button_class": "p-button", - }, ] exams_not_taken.append( {"name": name, "state": "Not taken", "actions": actions} @@ -366,87 +359,6 @@ def cred_exam(trueability_api, **_): return flask.render_template("credentials/exam.html", url=url) -@shop_decorator(area="cred", permission="user", response="html") -def cred_provision(ua_contracts_api, trueability_api, **_): - contract_item_id = flask.request.args.get("contractItemID", type=int) - - if contract_item_id is None: - return flask.redirect("/credentials/your-exams") - - country_code = get_user_country_by_ip().json["country_code"] or "GB" - reservation_uuid = None - assessment = None - reservation = None - error = None - - exam_contracts = ua_contracts_api.get_annotated_contract_items( - product_tags=["cue"], - ) - - exam_contract = None - for item in exam_contracts: - if contract_item_id == (item.get("id") or item["contractItem"]["id"]): - exam_contract = item - break - - if exam_contract: - if "reservation" in exam_contract["cueContext"]: - reservation_uuid = exam_contract["cueContext"]["reservation"][ - "IDs" - ][-1] - else: - error = "Exam not found" - - if not reservation_uuid: - tz_info = pytz.timezone("UTC") - starts_at = tz_info.localize(datetime.utcnow() + timedelta(seconds=20)) - first_name, last_name = get_user_first_last_name() - - try: - response = ua_contracts_api.post_assessment_reservation( - contract_item_id, - first_name, - last_name, - tz_info.zone, - starts_at.isoformat(), - country_code, - ) - - reservation_uuid = response.get("reservation", {}).get("IDs", [])[ - -1 - ] - - except UAContractsAPIErrorView: - error = ( - "An error occurred while reserving your exam. " - + "Please try refreshing the page." - ) - - if reservation_uuid: - response = trueability_api.get_assessment_reservation(reservation_uuid) - - if "error" in response: - error = response.get("message", "No exam booking could be found.") - else: - reservation = response["assessment_reservation"] - assessment = reservation["assessment"] - - if assessment and assessment.get("state") in [ - "notified", - "released", - "in_progress", - ]: - return flask.redirect(f"/credentials/exam?id={ assessment['id'] }") - - return flask.render_template( - "/credentials/provision.html", - contract_item_id=contract_item_id, - assessment=assessment, - reservation=reservation, - error=error, - ) - - @shop_decorator(area="cred", permission="user_or_guest", response="html") def cred_syllabus_data(**_): exam_name = flask.request.args.get("exam") @@ -609,10 +521,6 @@ def cred_redeem_code(ua_contracts_api, advantage_mapper, **kwargs): return flask.redirect( f"/credentials/schedule?contractItemID={contract_id}" ) - if action == "take": - return flask.redirect( - f"/credentials/provision?contractItemID={contract_id}" - ) return flask.render_template( "/credentials/redeem.html", notification_class="positive",