forked from asmbly-makerspace/NeonIntegrations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassTierPopulater.py
More file actions
81 lines (75 loc) · 2.15 KB
/
Copy pathclassTierPopulater.py
File metadata and controls
81 lines (75 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import datetime
import helpers.neon as neon
CLASSES = {
"Woodshop Safety": 1,
"Metal Shop Safety": 1,
"Woodshop Specialty Tools": 2,
"Metal Lathe": 2,
"Milling": 2,
"MIG Welding": 2,
"TIG Welding": 2,
"Beginner CNC": 3,
"Filament 3D Printing": 1,
"Resin 3D Printing":2,
"Wood Lathe": 2,
"Big Lasers": 3,
"Small Lasers": 2,
"Sublimation": 1,
"Shaper Origin": 2,
"Stationary Sanders": 1,
"Bowl Turning": 2,
"Vinyl Cutter": 1,
"Round Materials": 3,
"Stained Glass": 2,
"Sewing": 1,
"Fusion 360 CAM": 2,
"Orientation": "PS",
}
today = datetime.date.today()
#deltaDays = today + datetime.timedelta(days=90)
searchFields = f'''
[
{{
"field": "Event End Date",
"operator": "GREATER_THAN",
"value": "{today}"
}},
{{
"field": "Event Archived",
"operator": "EQUAL",
"value": "No"
}}
]
'''
outputFields = '''
[
"Event Name",
"Event Topic",
"Event Start Date",
"Event End Date",
"Event Registration Attendee Count",
"Event ID",
"Event Code"
]
'''
totalPatched = 0
response = neon.postEventSearch(searchFields, outputFields)
totalPages = response["pagination"]["totalPages"]
responseEvents = response['searchResults']
for event in responseEvents:
if not event.get("Event Code"):
for eventName, tier in CLASSES.items():
if eventName in event["Event Name"]:
codePatch = neon.eventTierCodePatch(event["Event ID"], tier)
print(event["Event Name"] + " Status Code: " + f"{codePatch.status_code}")
totalPatched += 1
for page in range(totalPages):
responseEvents = neon.postEventSearch(searchFields, outputFields, page=page)['searchResults']
for event in responseEvents:
if not event.get("Event Code"):
for eventName, tier in CLASSES.items():
if eventName in event["Event Name"]:
codePatch = neon.eventTierCodePatch(event["Event ID"], tier)
print(event["Event Name"] + " Status Code: " + f"{codePatch.status_code}")
totalPatched += 1
print(totalPatched)