Tons of anthology work with notes and scripts. Updated DE's tamplates. Small script changes as well.

This commit is contained in:
Norm Rasmussen
2023-11-17 17:18:13 -05:00
parent c3aedce0d1
commit 09053c34cd
32 changed files with 22644 additions and 575 deletions

View File

@ -19,3 +19,4 @@ DATASNIPPER = "098Odf9CIkk4aQA1lW7tsa9k8"
CHUBB = "m6ZEBesXzpWx2vmp11rEHxrMY"
BIRCHSTREET = "WpMV3jF4q9Om5FjUsrzZifduE"
G2 = "JRDpCGQ7vSRiva6t5OkWDr5eJ"
DOUGLASELLIMAN = "Bknf8kidbluRfcKu3m3lKoxS8"

View File

@ -36,10 +36,10 @@ def get_groups(APIKEY):
if "next" not in nextlink:
break
pp.pprint(groups)
# print(len(groups))
with open('/Users/normrasmussen/Documents/Work/CustomerNotes/Anthology/antho-groups.json', 'w') as jsn:
json.dump(groups, jsn)
pp.pprint(groups)
print(len(groups))
# with open('/Users/normrasmussen/Documents/Work/CustomerNotes/Anthology/antho-groups.json', 'w') as jsn:
# json.dump(groups, jsn)
if __name__ == "__main__":

View File

@ -3,11 +3,11 @@ import os
import Apikeys
import requests
apikey = Apikeys.walmartprod
apikey = Apikeys.DOUGLASELLIMAN
cmd = "touch ~/Downloads/Spark_Categories.csv"
os.system(cmd)
url = "https://api2.northpass.com/v2/categories?limit=100"
url = "https://api.northpass.com/v2/categories?limit=100"
headers = {
"accept": "application/json",
"X-Api-Key" : apikey,

View File

@ -0,0 +1,34 @@
import Apikeys
import requests
APIKEY = Apikeys.ANTHOLOGY
HEADERS = {
"accept": "application/json",
"X-Api-Key": APIKEY,
}
def get_courses():
"""
Function to get courses and their IDs
"""
count = 0
list_of_ids = []
while True:
count += 1
url = f"https://api.northpass.com/v2/courses/?limit=100&page={count}"
response = requests.get(url, headers=HEADERS)
response = response.json()
nextlink = response["links"]
for item in response["data"]:
id = item["id"]
name = item["attributes"]["name"]
list_of_ids.append(id)
if "next" not in nextlink:
break
print(list_of_ids)
if __name__ == "__main__":
get_courses()

44
Scripts/clone_courses.js Normal file
View File

@ -0,0 +1,44 @@
const pt = require('puppeteer');
const readline = require("readline");
const rl =
readline.createInterface({
input: process.stdin,
output: process.stdout,
})
var userEmail= 'nrasmussen@northpass.com';
var userPassword= 'ecx5pmy!MAN2vgh2knc';
var otp = '';
var schoolUUID = '52d19519-103f-45e3-9fa8-d21baa0f8aaa';
var courseUUIDs =
var schoolNameToCloneTo = 'Anthology Internal';
function wait(ms) {
return new Promise(r => setTimeout(r, ms));
}
pt.launch({ headless: false }).then(async browser => {
var p = await browser.newPage();
await p.setViewport({ width: 1000, height: 500 })
await p.goto('https://app.northpass.com/admin/sign_in')
await wait(500)
await p.type('#administrator_email', userEmail)
await p.type('#administrator_password', userPassword)
await p.click('input.button');
await wait(500)
await p.goto('https://app.northpass.com/admin/twofactorauth/edit')
await wait(500)
await p.type('#otp_otp_attempt',otp)
await p.click('input.button');
await wait(500)
for (var i = 0; i < courseUUIDs.length;i++) {
await p.goto('https://app.northpass.com/admin/schools/'+ schoolUUID +'/courses/'+ courseUUIDs[i] +'/clone/new')
await p.type('#react-select-2-input',schoolNameToCloneTo)
await p.keyboard.press('Enter');
await wait(100)
await p.click('input.button');
await wait(1000)
}
await wait(2000)
await browser.close()
})