Pushed Walmart's ecommerce stuff to production and made the changes the client requested. Updated bulk_invite_and_props script for Chubb.
This commit is contained in:
@ -34,26 +34,44 @@
|
|||||||
{% 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">
|
||||||
{% if course.enrolled? == false and course.properties.course_cost > 0 %}
|
{% if course.properties.course_cost > 0 %}
|
||||||
{{ course.properties.course_cost }}
|
{% if course.enrolled? == false %}
|
||||||
|
Paid Course
|
||||||
|
{% elsif course.progress > 0 and course.progress < 100 %}
|
||||||
|
Purchased
|
||||||
|
{% elsif course.progress == 100 %}
|
||||||
|
Purchased
|
||||||
|
{% else %}
|
||||||
|
Purchased
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% t shared.progress, count: course.progress %}
|
{% t shared.progress, count: course.progress %}
|
||||||
{% endif %}
|
{% 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.enrolled? == false and course.properties.course_cost > 0 %}
|
{% if course.properties.course_cost > 0 %}
|
||||||
Paid Course
|
{% if course.enrolled? == false %}
|
||||||
{% elsif course.progress > 0 and course.progress < 100 %}
|
Preview
|
||||||
Continue
|
{% elsif course.progress > 0 and course.progress < 100 %}
|
||||||
{% elsif course.progress == 100 %}
|
Continue
|
||||||
Retake
|
{% elsif course.progress == 100 %}
|
||||||
{% else %}
|
Retake
|
||||||
View
|
{% else %}
|
||||||
{% endif %}
|
Start
|
||||||
|
{% endif %}
|
||||||
|
{% elsif course.progress > 0 and course.progress < 100 %}
|
||||||
|
Continue
|
||||||
|
{% elsif course.progress == 100 %}
|
||||||
|
Retake
|
||||||
|
{% else %}
|
||||||
|
View
|
||||||
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -88,7 +88,7 @@
|
|||||||
t.setAttribute("data-firstname", "{{ current_person.first_name }}");
|
t.setAttribute("data-firstname", "{{ current_person.first_name }}");
|
||||||
t.setAttribute("data-lastname", "{{ current_person.last_name }}");
|
t.setAttribute("data-lastname", "{{ current_person.last_name }}");
|
||||||
t.setAttribute("data-email", "{{ current_person.email }}");
|
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-redirectionurl", "https://walmartluminate.northpass.com/app/courses/{{ course.id }}"); //url they are currently on
|
||||||
t.setAttribute("data-snappayurl", "https://snappayglobal.com/Interop/HostedPaymentPage");
|
t.setAttribute("data-snappayurl", "https://snappayglobal.com/Interop/HostedPaymentPage");
|
||||||
document.getElementsByTagName("head")[0].appendChild(t);
|
document.getElementsByTagName("head")[0].appendChild(t);
|
||||||
return false;
|
return false;
|
||||||
@ -118,7 +118,7 @@
|
|||||||
alert.appendChild(error_text)
|
alert.appendChild(error_text)
|
||||||
sessionStorage.clear()
|
sessionStorage.clear()
|
||||||
} else {
|
} else {
|
||||||
window.location.replace('https://luminatesandbox.northpass.com/c/{{ course.enrollment_code }}')
|
window.location.replace('https://walmartluminate.northpass.com/c/{{ course.enrollment_code }}')
|
||||||
sessionStorage.clear()
|
sessionStorage.clear()
|
||||||
}
|
}
|
||||||
// Set course prop as whole number, if 0, don't do anything
|
// Set course prop as whole number, if 0, don't do anything
|
||||||
|
|||||||
@ -5,4 +5,5 @@
|
|||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.4/tiny-slider.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.4/tiny-slider.css">
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.2/min/tiny-slider.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.2/min/tiny-slider.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ HEADERS = {
|
|||||||
"X-Api-Key": APIKEY,
|
"X-Api-Key": APIKEY,
|
||||||
}
|
}
|
||||||
BASEURL = "https://api.northpass.com/v2/"
|
BASEURL = "https://api.northpass.com/v2/"
|
||||||
IMPORTFILE = "/Users/normrasmussen/Downloads/chubb-cisa-624.csv"
|
IMPORTFILE = "/Users/normrasmussen/Downloads/CISA-061724.csv"
|
||||||
|
|
||||||
|
|
||||||
def bulk_invite_and_group():
|
def bulk_invite_and_group():
|
||||||
@ -30,39 +30,35 @@ def bulk_invite_and_group():
|
|||||||
data = pd.read_csv(IMPORTFILE)
|
data = pd.read_csv(IMPORTFILE)
|
||||||
groups = data["Group"].unique()
|
groups = data["Group"].unique()
|
||||||
groups = list(groups)
|
groups = list(groups)
|
||||||
try:
|
for group in groups:
|
||||||
for group in groups:
|
payload = ""
|
||||||
payload = ""
|
tmp_group = data[data.Group == group]
|
||||||
tmp_group = data[data.Group == group]
|
people = list(tmp_group["Email"])
|
||||||
people = list(tmp_group["Email"])
|
group = str(tmp_group["Group"].unique())[2:-2]
|
||||||
group = str(tmp_group["Group"].unique())[2:-2]
|
print(f"Group --> {group} & Email Length --> {len(people)}")
|
||||||
print(f"Group --> {group} & Email Length --> {len(people)}")
|
url = f"{BASEURL}bulk/people"
|
||||||
url = f"{BASEURL}bulk/people"
|
if len(people) > 1500:
|
||||||
if len(people) > 1500:
|
for chunk in range(0, len(people), 1500):
|
||||||
for chunk in range(0, len(people), 1500):
|
i = chunk
|
||||||
i = chunk
|
|
||||||
payload_1 = []
|
|
||||||
i_to_add = people[i : i + 1500]
|
|
||||||
for person in i_to_add:
|
|
||||||
miniload = {"email": person, "groups": group}
|
|
||||||
payload_1.append(miniload)
|
|
||||||
print(f"The long length {group} payload has {len(payload_1)}")
|
|
||||||
payload = {"data": {"attributes": {"people": payload_1}}}
|
|
||||||
response = requests.post(url, headers=HEADERS, json=payload)
|
|
||||||
print(f"Completed. Status code is {response.status_code}")
|
|
||||||
else:
|
|
||||||
payload_1 = []
|
payload_1 = []
|
||||||
for person in people:
|
i_to_add = people[i : i + 1500]
|
||||||
|
for person in i_to_add:
|
||||||
miniload = {"email": person, "groups": group}
|
miniload = {"email": person, "groups": group}
|
||||||
payload_1.append(miniload)
|
payload_1.append(miniload)
|
||||||
# print(f"The {group} payload has {len(payload_1)}")
|
print(f"The long length {group} payload has {len(payload_1)}")
|
||||||
payload = {"data": {"attributes": {"people": payload_1}}}
|
payload = {"data": {"attributes": {"people": payload_1}}}
|
||||||
response = requests.post(url, headers=HEADERS, json=payload)
|
response = requests.post(url, headers=HEADERS, json=payload)
|
||||||
print(f"Completed. Status code is {response.status_code}")
|
print(f"Completed. Status code is {response.status_code}")
|
||||||
print(response.text)
|
else:
|
||||||
except:
|
payload_1 = []
|
||||||
pass
|
for person in people:
|
||||||
finally:
|
miniload = {"email": person, "groups": group}
|
||||||
|
payload_1.append(miniload)
|
||||||
|
# print(f"The {group} payload has {len(payload_1)}")
|
||||||
|
payload = {"data": {"attributes": {"people": payload_1}}}
|
||||||
|
response = requests.post(url, headers=HEADERS, json=payload)
|
||||||
|
print(f"Completed. Status code is {response.status_code}")
|
||||||
|
print(response.text)
|
||||||
print("Running add props from func...")
|
print("Running add props from func...")
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
add_props_from_func(people, data)
|
add_props_from_func(people, data)
|
||||||
@ -95,12 +91,14 @@ def add_props_from_func(people, data):
|
|||||||
propresponse = requests.post(prop_url, json=payload, headers=HEADERS)
|
propresponse = requests.post(prop_url, json=payload, headers=HEADERS)
|
||||||
print(propresponse.status_code)
|
print(propresponse.status_code)
|
||||||
if propresponse.status_code != 200:
|
if propresponse.status_code != 200:
|
||||||
error_tupe = (learner_uud, learner_email, agency_name)
|
error_tupe = (learner_uuid, learner_email, agname)
|
||||||
errorlist.append(error_tupe)
|
errorlist.append(error_tupe)
|
||||||
else:
|
else:
|
||||||
print(f"Looks like {learner_email} and {agency_name} was successful.")
|
print(f"Looks like {learner_email} and {agname} was successful.")
|
||||||
except TypeError as e:
|
except ( TypeError,IndexError ) as e:
|
||||||
pass
|
error_tupe = (0, learner_email, agency_name)
|
||||||
|
errorlist.append(error_tupe)
|
||||||
|
print(f"{e} has occurred with {learner_email}")
|
||||||
finally:
|
finally:
|
||||||
print(f"Error list: {errorlist}")
|
print(f"Error list: {errorlist}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user