diff --git a/webapp/app.py b/webapp/app.py index 73f00fa0363..dbb895f33de 100644 --- a/webapp/app.py +++ b/webapp/app.py @@ -81,10 +81,9 @@ cred_syllabus_data, cred_your_exams, get_activation_keys, - get_exam_products, + get_cue_products, get_filtered_webhook_responses, get_issued_badges, - get_key_products, get_my_issued_badges, get_webhook_response, issue_badges, @@ -1133,7 +1132,9 @@ def takeovers_index(): app.add_url_rule("/credentials/assessments", view_func=cred_assessments) app.add_url_rule("/credentials/exam", view_func=cred_exam) app.add_url_rule( - "/credentials/exam/products", view_func=get_exam_products, methods=["GET"] + "/credentials//products", + view_func=get_cue_products, + methods=["GET"], ) app.add_url_rule( "/credentials/exit-survey", @@ -1165,9 +1166,6 @@ def takeovers_index(): view_func=activate_activation_key, methods=["POST"], ) -app.add_url_rule( - "/credentials/keys/products", view_func=get_key_products, methods=["GET"] -) app.add_url_rule( "/credentials/beta/activation", view_func=cred_beta_activation, diff --git a/webapp/shop/cred/views.py b/webapp/shop/cred/views.py index 7accd632c03..34849e527b6 100644 --- a/webapp/shop/cred/views.py +++ b/webapp/shop/cred/views.py @@ -717,11 +717,11 @@ def issue_badges(trueability_api, credly_api, **kwargs): @shop_decorator(area="cred", permission="user", response="json") -def get_key_products(ua_contracts_api, **kwargs): +def get_cue_products(ua_contracts_api, type, **kwargs): listings = ua_contracts_api.get_product_listings("canonical-cube").get( "productListings" ) - key_products = [ + filtered_products = [ { "id": listing["productID"], "longId": listing["id"], @@ -731,25 +731,7 @@ def get_key_products(ua_contracts_api, **kwargs): "price": listing["price"], } for listing in listings - if listing["productID"].endswith("key") + if (listing["productID"].endswith("key") and type == "keys") + or (type == "exam") ] - return flask.jsonify(key_products) - - -@shop_decorator(area="cred", permission="user", response="json") -def get_exam_products(ua_contracts_api, **kwargs): - listings = ua_contracts_api.get_product_listings("canonical-cube").get( - "productListings" - ) - exam_products = [ - { - "id": listing["productID"], - "longId": listing["id"], - "period": listing["period"], - "marketplace": listing["marketplace"], - "name": listing["name"], - "price": listing["price"], - } - for listing in listings - ] - return flask.jsonify(exam_products) + return flask.jsonify(filtered_products)