adds ical url handling
- icalToCalendarDB converts the information the user puts into the form on the calendar.html page and pulls the calendar from the url. It then passes it into the database. - fetchCanedarEvents gets all events within a startDate and an endDate and removes any all day events. This is currently a bit costly, because it takes some time for the ics library to download the entire .ical file from the url. Then it goes through every entry ever added to the file and saves only the future events.
This commit is contained in:
@ -135,7 +135,7 @@ def toNaturalColor(colormap, orgColor):
|
||||
# uses the event color id to convert it to a hex color
|
||||
# does this for every event in events
|
||||
# this is used for Google Calendars
|
||||
def colorizeEvents(events, colors):
|
||||
def colorizeGoogleEvents(events, colors):
|
||||
COLORS_FILE = os.path.join(os.path.dirname(__file__), 'colors.json')
|
||||
with open(COLORS_FILE) as f:
|
||||
colormap = json.load(f)
|
||||
@ -190,17 +190,18 @@ def getTimeStamps():
|
||||
|
||||
# define today and tomorrow
|
||||
now = datetime.datetime.now(datetime.timezone.utc).astimezone()
|
||||
today = now.replace(hour=0, minute=0, second = 0).isoformat()
|
||||
today = now.replace(hour=0, minute=0, second = 0)
|
||||
tomorrow = now.replace(hour=23, minute=59, second=59).isoformat() # + '+01:00'
|
||||
twodaysfromnow = datetime.datetime.today() + datetime.timedelta(days=2)
|
||||
twodaysfromnow = twodaysfromnow.replace(hour=23, minute=59, second=59).astimezone().isoformat()
|
||||
twodaysfromnow = twodaysfromnow.replace(hour=23, minute=59, second=59).astimezone()
|
||||
|
||||
return today, twodaysfromnow
|
||||
|
||||
def generateJsonFromCalendarEntries(events, colors):
|
||||
|
||||
# fix all colors in events that have a different event color
|
||||
colorizeEvents(events, colors)
|
||||
if colors != None:
|
||||
colorizeGoogleEvents(events, colors)
|
||||
# if not events:
|
||||
# print('No upcoming events found.')
|
||||
|
||||
|
Reference in New Issue
Block a user