Compare commits
2 Commits
04c5410c41
...
1f48689a32
Author | SHA1 | Date | |
---|---|---|---|
1f48689a32 | |||
752c7c5577 |
2
backend
2
backend
@ -1 +1 @@
|
|||||||
Subproject commit fec09edb888013c5cb9c062d5cdb2220bc1a217d
|
Subproject commit 056779f7d26746cf54e73156e0a3909ecf058298
|
@ -2,7 +2,7 @@ FROM python:3.8-slim-buster
|
|||||||
RUN apt-get update && apt-get upgrade
|
RUN apt-get update && apt-get upgrade
|
||||||
RUN pip3 install flask Flask-SQLAlchemy flask_migrate flask_login flask_wtf python-dotenv
|
RUN pip3 install flask Flask-SQLAlchemy flask_migrate flask_login flask_wtf python-dotenv
|
||||||
RUN apt-get install gcc libpcre3 libpcre3-dev libmariadbclient-dev -y
|
RUN apt-get install gcc libpcre3 libpcre3-dev libmariadbclient-dev -y
|
||||||
RUN pip3 install uwsgi email-validator RandomWords icalevents
|
RUN pip3 install uwsgi email-validator RandomWords ics
|
||||||
RUN pip3 install google google-oauth google-auth-oauthlib google-api-python-client mysqlclient
|
RUN pip3 install google google-oauth google-auth-oauthlib google-api-python-client mysqlclient
|
||||||
COPY docker-entrypoint.sh /usr/local/bin/
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
EXPOSE 8084
|
EXPOSE 8084
|
||||||
|
@ -50,6 +50,7 @@ class DeviceForm(FlaskForm):
|
|||||||
|
|
||||||
class CalendarForm(FlaskForm):
|
class CalendarForm(FlaskForm):
|
||||||
iCalURL = StringField('New ical URL', validators=[DataRequired()])
|
iCalURL = StringField('New ical URL', validators=[DataRequired()])
|
||||||
|
calName = StringField('Calendar Name', validators=[DataRequired()])
|
||||||
submit = SubmitField('Add URL')
|
submit = SubmitField('Add URL')
|
||||||
|
|
||||||
def validate_iCalURL (self, iCalURL):
|
def validate_iCalURL (self, iCalURL):
|
||||||
|
@ -122,18 +122,22 @@ def deleteAccount(user):
|
|||||||
|
|
||||||
def fetchCalendarEvents(user, calendars, startDate, endDate):
|
def fetchCalendarEvents(user, calendars, startDate, endDate):
|
||||||
|
|
||||||
client_token = GC.build_credentials(user.google_token.token,
|
service = None
|
||||||
user.google_token.refresh_token)
|
if user.google_token is not None:
|
||||||
credentials = google.oauth2.credentials.Credentials(**client_token)
|
client_token = GC.build_credentials(user.google_token.token,
|
||||||
|
user.google_token.refresh_token)
|
||||||
|
credentials = google.oauth2.credentials.Credentials(**client_token)
|
||||||
|
|
||||||
service = build(GC.API_SERVICE_NAME, GC.API_VERSION, credentials=credentials)
|
service = build(GC.API_SERVICE_NAME, GC.API_VERSION, credentials=credentials)
|
||||||
|
|
||||||
all_events = []
|
all_events = []
|
||||||
for calendar in calendars:
|
for calendar in calendars:
|
||||||
if calendar.toggle == "True" and calendar.calType == "Google":
|
if (calendar.toggle == "True" and
|
||||||
|
calendar.calendar_type == "Google" and
|
||||||
|
service != None):
|
||||||
event_result = service.events().list(calendarId=calendar.calendar_id,
|
event_result = service.events().list(calendarId=calendar.calendar_id,
|
||||||
timeMin=startDate,
|
timeMin=startDate.isoformat(),
|
||||||
timeMax=endDate,
|
timeMax=endDate.isoformat(),
|
||||||
maxResults=10,
|
maxResults=10,
|
||||||
singleEvents=True,
|
singleEvents=True,
|
||||||
orderBy='startTime').execute()
|
orderBy='startTime').execute()
|
||||||
@ -156,7 +160,10 @@ def fetchCalendarEvents(user, calendars, startDate, endDate):
|
|||||||
|
|
||||||
all_events.append(newEvent)
|
all_events.append(newEvent)
|
||||||
|
|
||||||
colors = service.colors().get().execute()
|
if service != None:
|
||||||
|
colors = service.colors().get().execute()
|
||||||
|
else:
|
||||||
|
colors = None
|
||||||
|
|
||||||
return all_events, colors
|
return all_events, colors
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ from flask_login import (
|
|||||||
from random_words import RandomWords
|
from random_words import RandomWords
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
import backend.icalHandler as ical
|
||||||
import server.googleHandler as google
|
import server.googleHandler as google
|
||||||
|
|
||||||
from server import login_manager, app, db
|
from server import login_manager, app, db
|
||||||
@ -106,6 +107,9 @@ def calendar():
|
|||||||
# try to add the submitted ical as a calendar
|
# try to add the submitted ical as a calendar
|
||||||
print(form.iCalURL.data, flush=True)
|
print(form.iCalURL.data, flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
ical.icalToCalendarDb(form.iCalURL.data, form.calName.data, current_user)
|
||||||
|
|
||||||
# otherwise it is a javascript POST
|
# otherwise it is a javascript POST
|
||||||
else:
|
else:
|
||||||
calId = request.json.get('calendar_id')
|
calId = request.json.get('calendar_id')
|
||||||
@ -255,6 +259,7 @@ def downloader(device):
|
|||||||
# TODO only pass along google calendars form user
|
# TODO only pass along google calendars form user
|
||||||
startDate, endDate = backend.getTimeStamps()
|
startDate, endDate = backend.getTimeStamps()
|
||||||
events, colors = google.fetchCalendarEvents(request_user, request_user.calendars, startDate, endDate)
|
events, colors = google.fetchCalendarEvents(request_user, request_user.calendars, startDate, endDate)
|
||||||
|
events.extend(ical.fetchCalendarEvents(request_user.calendars, startDate, endDate))
|
||||||
calendarjson = backend.generateJsonFromCalendarEntries(events, colors)
|
calendarjson = backend.generateJsonFromCalendarEntries(events, colors)
|
||||||
return jsonify(calendarjson)
|
return jsonify(calendarjson)
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<div class="container grey" style="margin-top: 3rem;">
|
<div class="container grey" style="margin-top: 3rem;">
|
||||||
<div>{{ form.hidden_tag() }}</div>
|
<div>{{ form.hidden_tag() }}</div>
|
||||||
|
<div style="margin: 1rem">{{ form.calName.label }}</div>
|
||||||
|
<div style="margin: 1rem">{{ form.calName(size=24) }}</div>
|
||||||
<div style="margin: 1rem">{{ form.iCalURL.label }}</div>
|
<div style="margin: 1rem">{{ form.iCalURL.label }}</div>
|
||||||
<div style="margin: 1rem">{{ form.iCalURL(size=24) }}</div>
|
<div style="margin: 1rem">{{ form.iCalURL(size=24) }}</div>
|
||||||
<div style="with: 8rem; margin: 1rem">{{ form.submit() }}</div>
|
<div style="with: 8rem; margin: 1rem">{{ form.submit() }}</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user