-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetadata.gs
185 lines (162 loc) · 4.44 KB
/
metadata.gs
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
var userTable = SpreadsheetApp
.openById(getUserTableId()); // functions like getUserTableId() are in a file called secrets.gs, which is not in the repo.
var staffChecklist = SpreadsheetApp
.openById(getStaffChecklistId());
var signinTable = SpreadsheetApp
.openById(getSigninTableId());
var staffScheduleCal = false;
function getStaffScheduleCal(){
if(!staffScheduleCal){
var calendars = CalendarApp.getCalendarsByName(getStaffScheduleCalName);
staffScheduleCal = calendars[0];
}
return staffScheduleCal;
}
function getStaffScheduleEvents(startTime, endTime){
var cal = getStaffScheduleCal();
return getCalEvents(cal, startTime, endTime);
}
function getCalEvents(cal, startTime, endTime){
var realStartDate = new Date(startTime);
var realEndDate = new Date(endTime);
try{
var events = cal.getEvents(new Date(startTime), new Date(endTime));
var returnEvents = events.map(function(event){
Logger.log(JSON.stringify(event));
var returnEvent = {
id: event.getId(),
calendarName : cal.getName(),
startTime: event.getStartTime().toString(),
endTime : event.getEndTime().toString(),
title : event.getTitle(),
description : event.getDescription(),
guestList : event.getGuestList(true).map(function(guest){
return {name : guest.getName(),
email : guest.getEmail(),
status: guest.getGuestStatus()
};
}),
creators : event.getCreators(),
dateCreated : event.getDateCreated.toString(),
location : event.getLocation()
}
return returnEvent;
});
return returnEvents;
}catch (error){
Logger.log(error);
throw error;
}
}
function getStaffSchedules(startDate, endDate){
var staffCal = getStaffScheduleCal();
var staffSchedules = {};
var now = new Date();
var startDateTime = new Date(startDate);
var endDateTime = new Date(endDate);
var events = staffCal.getEvents(startDateTime, endDateTime);
Logger.log("got them");
Logger.log(JSON.stringify(events, null, " "));
for(var i = 0; i < events.length; i++){
var guests = events[i].getGuestList(true);
for(var j = 0; j < guests.length; j++){
var guest = guests[j];
var email = guest.getEmail().toLowerCase();
var eventDetails = {title: events[i].getTitle(),
startTime: events[i].getStartTime(),
endTime: events[i].getEndTime(),
guestList : events[i].getGuestList(),
staffEmail : events[i].getGuestList()[0].toString(),
id : events[i].getId()
};
if(!staffSchedules[email]){
staffSchedules[email] = [];
}
staffSchedules[email].push(eventDetails);
}
}
return JSON.parse(JSON.stringify(staffSchedules));
}
var checklistItems = [
'Recieved Safety Orientation' ,
'Signed Safety Waiver'
];
function getChecklistItems(){
return checklistItems;
}
var MeritBadges = [
'Laser Cutter',
'3D Printing',
'Hand Tools',
'HandiBot',
'Power Tools',
'Print Shop',
'Sewing Machine',
'Embroidery Machine',
'Vinyl Cutter',
'FormLabs',
'Soldering',
'Arduino',
'Button Maker',
'Raspberry Pi'
];
function getMeritBadges(){
return MeritBadges;
}
var entryReasons = [
'Staff/Volunteer Shift',
'Looking for Advice',
'Just wandered in, checking things out',
'My own project',
'Workshop',
'Class assignment',
'Club meeting',
'Tour',
'Class Session',
'Hanging out/meeting a friend/nothing very maker-y (that\'s OK too!)',
'Office Hours (Faculty or Student)',
'Class Preparation (Faculty)'
];
function getEntryReasons(){
return entryReasons;
}
var workingOn = [
'3D Modeling and Printing',
'Laser Cutter',
'Vinyl Cutter',
'Print Shop/Book Binding',
'Wood Shop/Power Tools',
'Electronics',
'Sewing, Embroidery, Knitting and Other Textiles',
'Button Makers',
'Arts and Crafts'
]
function getWorkingOn(){
return workingOn;
}
var openHouse = {
"Monday" : {
open : "12:00",
close : "17:00",
},
"Tuesday" : {
open : "17:00",
close : "20:00",
},
"Wednesday" : {
open : "17:00",
close : "20:00",
},
"Thursday" : {
open : "17:00",
close : "20:00",
},
"Friday" : {
open : "12:00",
close : "17:00",
},
"Saturday" : {
open : "12:00",
close : "17:00",
}
};