From 5170459186734ded7cfa54b768527abdf1589c1f Mon Sep 17 00:00:00 2001 From: Norm Rasmussen Date: Thu, 13 Mar 2025 14:15:03 -0400 Subject: [PATCH] Supplier script for group and course associations. --- .../Chubb/_featured_cards_course.html.liquid | 12 +++++++- .../API_Tests/add_course_to_group_from_csv.py | 28 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Custom_Templates/customer_templates/Chubb/_featured_cards_course.html.liquid b/Custom_Templates/customer_templates/Chubb/_featured_cards_course.html.liquid index 4f3f1eb5..8c61bf79 100644 --- a/Custom_Templates/customer_templates/Chubb/_featured_cards_course.html.liquid +++ b/Custom_Templates/customer_templates/Chubb/_featured_cards_course.html.liquid @@ -3,7 +3,7 @@ {% if group.id == '2d93e49d-48e0-4419-baf8-88f31ad78349' %} {% comment %} < -----------------------------> - The carousel HTML goes here. + The carousel for the access agent group goes here. < -----------------------------> {% endcomment %}
@@ -48,6 +48,11 @@ {% if current_person.groups.any? %} {% for group in current_person.groups %} {% if group.id == '5766ee65-0f6e-42fa-b932-a26b3bbb1636' %} + {% comment %} + < -----------------------------> + The carousel for the Cornerstone group goes here. + < -----------------------------> + {% endcomment %}
@@ -83,6 +88,11 @@
{% else %} + {% comment %} + < -----------------------------> + The carousel for the remainder of the groups. + < -----------------------------> + {% endcomment %}
diff --git a/Scripts/API_Tests/add_course_to_group_from_csv.py b/Scripts/API_Tests/add_course_to_group_from_csv.py index 90ecfb88..4b37c18e 100644 --- a/Scripts/API_Tests/add_course_to_group_from_csv.py +++ b/Scripts/API_Tests/add_course_to_group_from_csv.py @@ -9,13 +9,35 @@ BASEFILE = "~/Downloads/Supplier Academy Course Groupings.csv" def parse_csv(): df = pd.read_csv(BASEFILE) - unique_groups = df['group_uuid'].nunique() + unique_groups = df['group_uuid'].unique().tolist() + unique_group_name = df['group_name'].unique().tolist() groups = df.groupby('group_uuid') for key,item in groups: - print(groups.get_group(key), "\n\n") + pass + # print(groups.get_group(key), "\n\n") print(f"Total Number of courses: {df['course_name'].nunique()}") - print(f"Number of Unique Groups: {unique_groups}") + print(unique_group_name, unique_groups) + # print(f"Number of Unique Groups: {unique_groups}") + remove_group_courses(unique_groups) + +def remove_group_courses(unique_groups): + """ + From Bartosz Chodyla: There's a non-public endpoint: + /v1/group_courses/:id + where id is the UUID of a record from the group_courses table. You can get the UUIDs directly from the DB or by calling another non-public endpoint, which is: + /v1/groups/:group_uuid/courses + """ + print(unique_groups) + for group_uuid in unique_groups: + print(group_uuid) + # Get Group Courses + get_gcourses = f"https://api2.northpass.com/v1/groups/{group_uuid}/courses" + group_courses = requests.get(get_gcourses, headers=HEADERS) + gcourse_json = group_courses.json() + print(gcourse_json) + + if __name__ == "__main__": parse_csv()