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 %}
|
||||
<div class="np-card-content-footer">
|
||||
<div class="np-card-content-progress np-button-color">
|
||||
{% if course.enrolled? == false and course.properties.course_cost > 0 %}
|
||||
{{ course.properties.course_cost }}
|
||||
{% if course.properties.course_cost > 0 %}
|
||||
{% if course.enrolled? == false %}
|
||||
Paid Course
|
||||
{% elsif course.progress > 0 and course.progress < 100 %}
|
||||
Purchased
|
||||
{% elsif course.progress == 100 %}
|
||||
Purchased
|
||||
{% else %}
|
||||
Purchased
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% t shared.progress, count: course.progress %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% capture course_path %}{% route course, id: course.id %}{% endcapture %}
|
||||
|
||||
{% capture course_path %}{% route course, id: course.id %}{% endcapture %}
|
||||
{% if course.has_to_restart? %}
|
||||
{% include "course_version_outdated_popup", path: course_path %}
|
||||
{% endif %}
|
||||
|
||||
<a class="np-button np-button-wide" href="{{ course_path }}">
|
||||
{% if course.enrolled? == false and course.properties.course_cost > 0 %}
|
||||
Paid Course
|
||||
{% elsif course.progress > 0 and course.progress < 100 %}
|
||||
Continue
|
||||
{% elsif course.progress == 100 %}
|
||||
Retake
|
||||
{% else %}
|
||||
View
|
||||
{% endif %}
|
||||
{% if course.properties.course_cost > 0 %}
|
||||
{% if course.enrolled? == false %}
|
||||
Preview
|
||||
{% elsif course.progress > 0 and course.progress < 100 %}
|
||||
Continue
|
||||
{% elsif course.progress == 100 %}
|
||||
Retake
|
||||
{% else %}
|
||||
Start
|
||||
{% endif %}
|
||||
{% elsif course.progress > 0 and course.progress < 100 %}
|
||||
Continue
|
||||
{% elsif course.progress == 100 %}
|
||||
Retake
|
||||
{% else %}
|
||||
View
|
||||
{% endif %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -88,7 +88,7 @@
|
||||
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-redirectionurl", "https://walmartluminate.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;
|
||||
@ -118,7 +118,7 @@
|
||||
alert.appendChild(error_text)
|
||||
sessionStorage.clear()
|
||||
} 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()
|
||||
}
|
||||
// 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">
|
||||
<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 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,
|
||||
}
|
||||
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():
|
||||
@ -30,39 +30,35 @@ def bulk_invite_and_group():
|
||||
data = pd.read_csv(IMPORTFILE)
|
||||
groups = data["Group"].unique()
|
||||
groups = list(groups)
|
||||
try:
|
||||
for group in groups:
|
||||
payload = ""
|
||||
tmp_group = data[data.Group == group]
|
||||
people = list(tmp_group["Email"])
|
||||
group = str(tmp_group["Group"].unique())[2:-2]
|
||||
print(f"Group --> {group} & Email Length --> {len(people)}")
|
||||
url = f"{BASEURL}bulk/people"
|
||||
if len(people) > 1500:
|
||||
for chunk in range(0, len(people), 1500):
|
||||
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:
|
||||
for group in groups:
|
||||
payload = ""
|
||||
tmp_group = data[data.Group == group]
|
||||
people = list(tmp_group["Email"])
|
||||
group = str(tmp_group["Group"].unique())[2:-2]
|
||||
print(f"Group --> {group} & Email Length --> {len(people)}")
|
||||
url = f"{BASEURL}bulk/people"
|
||||
if len(people) > 1500:
|
||||
for chunk in range(0, len(people), 1500):
|
||||
i = chunk
|
||||
payload_1 = []
|
||||
for person in people:
|
||||
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 {group} payload has {len(payload_1)}")
|
||||
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}")
|
||||
print(response.text)
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
else:
|
||||
payload_1 = []
|
||||
for person in people:
|
||||
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...")
|
||||
time.sleep(3)
|
||||
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)
|
||||
print(propresponse.status_code)
|
||||
if propresponse.status_code != 200:
|
||||
error_tupe = (learner_uud, learner_email, agency_name)
|
||||
error_tupe = (learner_uuid, learner_email, agname)
|
||||
errorlist.append(error_tupe)
|
||||
else:
|
||||
print(f"Looks like {learner_email} and {agency_name} was successful.")
|
||||
except TypeError as e:
|
||||
pass
|
||||
print(f"Looks like {learner_email} and {agname} was successful.")
|
||||
except ( TypeError,IndexError ) as e:
|
||||
error_tupe = (0, learner_email, agency_name)
|
||||
errorlist.append(error_tupe)
|
||||
print(f"{e} has occurred with {learner_email}")
|
||||
finally:
|
||||
print(f"Error list: {errorlist}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user