Compare commits
No commits in common. "804ab33a6d07b34c2f0942a63c71f652dfb067f3" and "b5dbfd87defaaed87c73f321ac3087fe5a7c689b" have entirely different histories.
804ab33a6d
...
b5dbfd87de
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1 @@
|
||||
*.swp
|
||||
__pycache__/
|
||||
|
@ -25,10 +25,11 @@ class Routine:
|
||||
for calendar in calendars:
|
||||
if calendar.toggle == 'True':
|
||||
visualCals.append(calendar.name)
|
||||
googleCreds = google.oauth2.credentials.Credentials(**credentials)
|
||||
print(credentials_to_dict(googleCreds), flush=True)
|
||||
|
||||
googleCreds = google.oauth2.credentials.Credentials(**credentials)
|
||||
calendarjson = caltojson.generateJsonFromCalendarEntries(visualCals, googleCreds)
|
||||
user.setJson(calendarjson)
|
||||
print(calendarjson)
|
||||
directory = 'userinfo/' + user.id + '/'
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
|
22
caltojson.py
22
caltojson.py
@ -138,7 +138,7 @@ def getCalendarEvents(service, visibleCalendars, startDate, endDate):
|
||||
for event in events_result.get('items', []):
|
||||
|
||||
# create simple event
|
||||
name = event.get('summary', '(no Title)')
|
||||
name = event['summary']
|
||||
start = event['start'].get('dateTime')
|
||||
end = event['end'].get('dateTime')
|
||||
newEvent = Event(name, start, end)
|
||||
@ -179,21 +179,17 @@ def colorizeEvents(allEvents, service):
|
||||
colors = getCalendarColors(service)
|
||||
|
||||
for event in allEvents:
|
||||
event.colorHex = forEventGetColor(event, colormap, colors)
|
||||
event.colorHex = fromColorIdGetColor(event.calendarColorId, colormap, colors)
|
||||
|
||||
# this function is only used once for calendar generation stuff
|
||||
def fromColorIdGetColor(color, colormap, colors):
|
||||
return toNaturalColor(colormap, colors['calendar'][color]['background'])
|
||||
def fromColorIdGetColor(colorId, colormap, colors):
|
||||
|
||||
def forEventGetColor(event, colormap, colors):
|
||||
if event.calendarColorId != 0:
|
||||
bg = colors['calendar'][event.calendarColorId]['background']
|
||||
if colorId != 0:
|
||||
orgColor = colors['calendar'][colorId]['background']
|
||||
else:
|
||||
calColorId = toCalendarColorId(colormap, event.eventColorId)
|
||||
bg = colors['calendar'][calColorId]['background']
|
||||
print(event.name)
|
||||
print(bg)
|
||||
return toNaturalColor(colormap, bg)
|
||||
calColorId = toCalendarColorId(colormap, colorId)
|
||||
orgColor = colors['calendar'][calColorId]['background']
|
||||
|
||||
return toNaturalColor(colormap, orgColor)
|
||||
|
||||
def toJson(events):
|
||||
data = {}
|
||||
|
@ -10,7 +10,7 @@
|
||||
},
|
||||
{
|
||||
"api": "#f83a22",
|
||||
"natural": "#d50000"
|
||||
"natural": "#8E24AA"
|
||||
},
|
||||
{
|
||||
"api": "#fa573c",
|
||||
@ -143,4 +143,4 @@
|
||||
"to": "8"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user