Luminate templates. Categories script to account for error handling.
This commit is contained in:
@ -28,21 +28,27 @@
|
|||||||
<div class="course-length">{{course.properties.course_length}}</div>
|
<div class="course-length">{{course.properties.course_length}}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<div></div>
|
<div></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="np-card-content-footer">
|
<div class="np-card-content-footer">
|
||||||
<div class="np-card-content-progress np-button-color">
|
<div class="np-card-content-progress np-button-color">
|
||||||
{% t shared.progress, count: course.progress %}
|
{% if course.enrolled? == false and course.properties.course_cost > 0 %}
|
||||||
|
{{ course.properties.course_cost }}
|
||||||
|
{% else %}
|
||||||
|
{% t shared.progress, count: course.progress %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% capture course_path %}{% route course, id: course.id %}{% endcapture %}
|
{% capture course_path %}{% route course, id: course.id %}{% endcapture %}
|
||||||
{% if course.has_to_restart? %}
|
{% if course.has_to_restart? %}
|
||||||
{% include "course_version_outdated_popup", path: course_path %}
|
{% include "course_version_outdated_popup", path: course_path %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="np-button np-button-wide" href="{{ course_path }}">
|
<a class="np-button np-button-wide" href="{{ course_path }}">
|
||||||
{% if course.progress > 0 and course.progress < 100 %}
|
{% if course.enrolled? == false and course.properties.course_cost > 0 %}
|
||||||
Continue
|
Paid Course
|
||||||
|
{% elsif course.progress > 0 and course.progress < 100 %}
|
||||||
|
Continue
|
||||||
{% elsif course.progress == 100 %}
|
{% elsif course.progress == 100 %}
|
||||||
Retake
|
Retake
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -53,3 +59,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if course.enrolled? == false and course.properties.course_cost != 0 %}
|
||||||
|
<div class="np-top-cta-progress-text np-button-color" style="font-size: 25px;">
|
||||||
|
$ {{ course.properties.course_cost }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a
|
||||||
|
class="np-top-button np-button-font-color np-button np-button-big"
|
||||||
|
<input id="snappayhppform_response" name="snappayhppform_response" />
|
||||||
|
<button type="button" value="Submit" onclick="myclick()" class="button" style="color: white; border:none; background:transparent;">
|
||||||
|
<strong>Purchase</strong>
|
||||||
|
<div id='mylink'></div>
|
||||||
|
</button>
|
||||||
|
<input src="https://snappayglobal.com/Interop/HostedPaymentPage" id="snappayhppform_response" type="hidden" name="snappayhppform_response" />
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
<div class="np-top-cta-progress-text
|
<div class="np-top-cta-progress-text
|
||||||
{% if course.completed? %} np-color-success {% else %} np-button-color {% endif %}
|
{% if course.completed? %} np-color-success {% else %} np-button-color {% endif %}
|
||||||
">
|
">
|
||||||
@ -32,7 +49,7 @@
|
|||||||
href="{% route course_enrollment, code: course.enrollment_code %}"
|
href="{% route course_enrollment, code: course.enrollment_code %}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
>
|
>
|
||||||
{% if course.enrolled? == false %}
|
{% if course.enrolled? == false %}
|
||||||
{% t shared.enroll %}
|
{% t shared.enroll %}
|
||||||
{% elsif course.started? == false %}
|
{% elsif course.started? == false %}
|
||||||
{% t shared.course.start, key: current_school.course_vocabulary %}
|
{% t shared.course.start, key: current_school.course_vocabulary %}
|
||||||
@ -42,5 +59,73 @@
|
|||||||
{% t shared.continue %}
|
{% t shared.continue %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% comment %}
|
||||||
|
<div id="dvsnappay_hppform">
|
||||||
|
</div>
|
||||||
|
<div id="dvsnappay_hppform">
|
||||||
|
<!-- HTML is dynamically placed here -->
|
||||||
|
</div>
|
||||||
|
{% endcomment %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
function myclick() {
|
||||||
|
sessionStorage.clear()
|
||||||
|
var mylink = document.getElementById('mylink');
|
||||||
|
mylink.onclick = function () {
|
||||||
|
var t = document.createElement("script");
|
||||||
|
t.setAttribute("id", "snappay_hppform");
|
||||||
|
t.setAttribute("src", "https://snappayglobal.com/Areas/Interop/Scripts/HPPForm.js");
|
||||||
|
t.setAttribute("data-target", "#snappayhppform_response");
|
||||||
|
t.setAttribute("data-callback", "submit_external_ecommerce");
|
||||||
|
t.setAttribute("data-accountid", "1002491072");
|
||||||
|
t.setAttribute("data-merchantid", "350160170881");
|
||||||
|
t.setAttribute("data-customerid", "100");
|
||||||
|
t.setAttribute("data-paymentmode", "CC");
|
||||||
|
t.setAttribute("data-transactionamount", '{{ course.properties.course_cost }}');
|
||||||
|
t.setAttribute("data-currencycode", "USD");
|
||||||
|
t.setAttribute("data-firstname", "{{ current_person.first_name }}");
|
||||||
|
t.setAttribute("data-lastname", "{{ current_person.last_name }}");
|
||||||
|
t.setAttribute("data-email", "{{ current_person.email }}");
|
||||||
|
t.setAttribute("data-redirectionurl", "https://luminatesandbox.northpass.com/app/courses/{{ course.id }}"); //url they are currently on
|
||||||
|
t.setAttribute("data-snappayurl", "https://snappayglobal.com/Interop/HostedPaymentPage");
|
||||||
|
document.getElementsByTagName("head")[0].appendChild(t);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
document.getElementById('mylink').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = document.getElementById('snappayhppform_response');
|
||||||
|
function submit_external_ecommerce() {
|
||||||
|
var result = $("#snappayhppform_response").val();
|
||||||
|
sessionStorage.setItem("snappayhpp_response", result);
|
||||||
|
sessionStorage.setItem("caller", "js");
|
||||||
|
var obj = JSON.parse(result);
|
||||||
|
var response = obj['response']
|
||||||
|
var inside = JSON.parse(obj['response'])
|
||||||
|
var stringside = JSON.stringify(inside)
|
||||||
|
sessionStorage.setItem("stringside", stringside)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var error_code = JSON.parse(sessionStorage.getItem('stringside')).pgreturncode
|
||||||
|
var error_desc = JSON.parse(sessionStorage.getItem('stringside')).pgreturndescription
|
||||||
|
if(error_code != 000 ) {
|
||||||
|
var alert = document.getElementById("fiveserv-alert")
|
||||||
|
document.getElementById("fiveserv-alert").style.display = 'grid';
|
||||||
|
var error_text = document.createTextNode(error_desc + ". Please try again.");
|
||||||
|
alert.appendChild(error_text)
|
||||||
|
sessionStorage.clear()
|
||||||
|
} else {
|
||||||
|
window.location.replace('https://luminatesandbox.northpass.com/c/{{ course.enrollment_code }}')
|
||||||
|
sessionStorage.clear()
|
||||||
|
}
|
||||||
|
// Set course prop as whole number, if 0, don't do anything
|
||||||
|
// If user is not enrolled in course, run functions - check error message
|
||||||
|
// With redirect they will land back on page, with error message from sessionstorage
|
||||||
|
// If no error, auto-redirect/click to enrollment link. window.replace(/c/aklwjdalkjd)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
99
Scripts/API_Tests/;
Normal file
99
Scripts/API_Tests/;
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
import requests
|
||||||
|
import pandas as pd
|
||||||
|
import Apikeys
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
|
apiKey = Apikeys.SKUID
|
||||||
|
course_dict = {}
|
||||||
|
|
||||||
|
COURSES= [
|
||||||
|
"Shopping an order",
|
||||||
|
"Delivery FAQs",
|
||||||
|
"Checking out Shopping & Delivery orders",
|
||||||
|
"Shopping & Delivery FAQs",
|
||||||
|
"Communicating with customers",
|
||||||
|
"Delivering an order",
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_course():
|
||||||
|
count = 0
|
||||||
|
courses = []
|
||||||
|
|
||||||
|
while True:
|
||||||
|
count += 1
|
||||||
|
url = f"https://api.northpass.com/v2/courses?page={count}"
|
||||||
|
headers = {"accept": "application/json", "X-Api-Key": apiKey}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
data = response.json()
|
||||||
|
nextlink = data["links"]
|
||||||
|
|
||||||
|
for response in data["data"]:
|
||||||
|
status = response["attributes"]["status"]
|
||||||
|
uuid = response["id"]
|
||||||
|
name = response["attributes"]["name"]
|
||||||
|
# build_url = response["links"]["builder"]["href"]
|
||||||
|
# if name in COURSES:
|
||||||
|
print(uuid)
|
||||||
|
course_dict = {
|
||||||
|
"id": uuid,
|
||||||
|
"name": name,
|
||||||
|
"status": status,
|
||||||
|
# "build_url": build_url
|
||||||
|
# "url": f"https://walmart.northpass.com/app/courses/{uuid}",
|
||||||
|
}
|
||||||
|
courses.append(course_dict)
|
||||||
|
# print(courses)
|
||||||
|
|
||||||
|
# FIX: Up until here, each course gets read to the terminal.
|
||||||
|
# FIX: After this, something is being overwritten.
|
||||||
|
|
||||||
|
# cat_id = response["relationships"]["categories"]["data"]
|
||||||
|
# get_cat_name(cat_id, course_dict, courses)
|
||||||
|
|
||||||
|
if "next" not in nextlink:
|
||||||
|
break
|
||||||
|
|
||||||
|
# write_to_csv(courses)
|
||||||
|
# pp.pprint(courses)
|
||||||
|
# print(len(courses))
|
||||||
|
|
||||||
|
def get_cat_name(course_dict):
|
||||||
|
headers = {"accept": "application/json", "X-Api-Key": apiKey}
|
||||||
|
cats = []
|
||||||
|
if len(cat_id) == 0:
|
||||||
|
pass
|
||||||
|
elif len(cat_id) == 1:
|
||||||
|
categoryid = cat_id[0]["id"]
|
||||||
|
url = f"https://api.northpass.com/v2/categories/{categoryid}"
|
||||||
|
cat_resp = requests.get(url, headers=headers)
|
||||||
|
cat_data = cat_resp.json()
|
||||||
|
cat_name = cat_data["data"]["attributes"]["name"]
|
||||||
|
print(cat_name)
|
||||||
|
cats.append(cat_name)
|
||||||
|
course_dict.update({"categories": cats})
|
||||||
|
else:
|
||||||
|
for item in cat_id:
|
||||||
|
categoryid = item["id"]
|
||||||
|
url = f"https://api.northpass.com/v2/categories/{categoryid}"
|
||||||
|
cat_resp = requests.get(url, headers=headers)
|
||||||
|
cat_data = cat_resp.json()
|
||||||
|
cat_name = cat_data["data"]["attributes"]["name"]
|
||||||
|
cats.append(cat_name)
|
||||||
|
course_dict.update({"categories": cats})
|
||||||
|
|
||||||
|
try:
|
||||||
|
courses.append(course_dict)
|
||||||
|
except TypeError as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
finally:
|
||||||
|
write_to_csv(courses)
|
||||||
|
|
||||||
|
|
||||||
|
def write_to_csv(courses):
|
||||||
|
df = pd.DataFrame.from_dict(courses)
|
||||||
|
df.to_csv("/Users/normrasmussen/Downloads/sps_courses.csv")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
get_course()
|
||||||
@ -4,7 +4,7 @@ import Apikeys
|
|||||||
import pprint
|
import pprint
|
||||||
|
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
apiKey = Apikeys.SPS
|
apiKey = Apikeys.SKUID
|
||||||
course_dict = {}
|
course_dict = {}
|
||||||
|
|
||||||
COURSES= [
|
COURSES= [
|
||||||
@ -48,13 +48,13 @@ def get_course():
|
|||||||
# FIX: Up until here, each course gets read to the terminal.
|
# FIX: Up until here, each course gets read to the terminal.
|
||||||
# FIX: After this, something is being overwritten.
|
# FIX: After this, something is being overwritten.
|
||||||
|
|
||||||
# cat_id = response["relationships"]["categories"]["data"]
|
cat_id = response["relationships"]["categories"]["data"]
|
||||||
# get_cat_name(cat_id, course_dict, courses)
|
get_cat_name(cat_id, course_dict, courses)
|
||||||
|
|
||||||
if "next" not in nextlink:
|
if "next" not in nextlink:
|
||||||
break
|
break
|
||||||
|
|
||||||
write_to_csv(courses)
|
# write_to_csv(courses)
|
||||||
# pp.pprint(courses)
|
# pp.pprint(courses)
|
||||||
# print(len(courses))
|
# print(len(courses))
|
||||||
|
|
||||||
@ -68,10 +68,14 @@ def get_cat_name(cat_id, course_dict, courses):
|
|||||||
url = f"https://api.northpass.com/v2/categories/{categoryid}"
|
url = f"https://api.northpass.com/v2/categories/{categoryid}"
|
||||||
cat_resp = requests.get(url, headers=headers)
|
cat_resp = requests.get(url, headers=headers)
|
||||||
cat_data = cat_resp.json()
|
cat_data = cat_resp.json()
|
||||||
cat_name = cat_data["data"]["attributes"]["name"]
|
try:
|
||||||
print(cat_name)
|
cat_name = cat_data["data"]["attributes"]["name"]
|
||||||
cats.append(cat_name)
|
cats.append(cat_name)
|
||||||
course_dict.update({"categories": cats})
|
course_dict.update({"categories": cats})
|
||||||
|
except KeyError:
|
||||||
|
print(f"key error for cat {cat_id}")
|
||||||
|
finally:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
for item in cat_id:
|
for item in cat_id:
|
||||||
categoryid = item["id"]
|
categoryid = item["id"]
|
||||||
|
|||||||
5
Todos.md
5
Todos.md
@ -351,3 +351,8 @@ message](https://northpasshq.slack.com/archives/C04RER4PH09/p1709147957374999?th
|
|||||||
## 06-24-2024
|
## 06-24-2024
|
||||||
|
|
||||||
- [ ] Anthology - URL Cut over to `academy.anthology.com`
|
- [ ] Anthology - URL Cut over to `academy.anthology.com`
|
||||||
|
|
||||||
|
## 06-26-2024
|
||||||
|
|
||||||
|
- [ ] Walmart - Add visuals to instructions for single activity
|
||||||
|
- [ ] Walmart - Change accordion in video activities to new accordion.
|
||||||
|
|||||||
Reference in New Issue
Block a user