updates color generation, tries fixing credentials bug
- credentials still lost the refresh token after a certain event - this was now fixed by completely removing any saves past the first one - https://trello.com/c/iORYLYHl/44-1-check-on-credentials - Color Coding is now updated - fixed an incorrect color mapping in the colors.json - updates some calls to functions to correctly get the natural colors - the incorrect red -> yellow mapping might have to do with the previous credentials error
This commit is contained in:
parent
1b7980e834
commit
ee54dd5daa
BIN
app.db.old
Normal file
BIN
app.db.old
Normal file
Binary file not shown.
2
backend
2
backend
@ -1 +1 @@
|
||||
Subproject commit b5dbfd87defaaed87c73f321ac3087fe5a7c689b
|
||||
Subproject commit 804ab33a6d07b34c2f0942a63c71f652dfb067f3
|
@ -1,10 +1,13 @@
|
||||
FROM python:3.8-slim-buster
|
||||
RUN apt-get update && apt-get upgrade
|
||||
RUN apt-get install -y cron
|
||||
RUN pip3 install flask Flask-SQLAlchemy flask_migrate flask_login flask_wtf python-dotenv
|
||||
RUN apt-get install gcc libpcre3 libpcre3-dev -y
|
||||
RUN pip3 install uwsgi
|
||||
|
||||
RUN pip3 install email-validator
|
||||
RUN pip3 install google google-oauth google-auth-oauthlib google-api-python-client
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
EXPOSE 8084
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
|
@ -1,4 +1,10 @@
|
||||
#!/bin/sh
|
||||
cd /home/calendarwatch
|
||||
# uwsgi --http-socket 0.0.0.0:8084 -w wsgi --protocol=https
|
||||
python3 app.py
|
||||
|
||||
python3 routine.py &
|
||||
echo "routine has been started"
|
||||
|
||||
python3 server.py
|
||||
echo "server has been started"
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 66f62f457a22
|
||||
Revises: 7bbc2215d87d
|
||||
Create Date: 2020-04-24 17:12:45.275636
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '66f62f457a22'
|
||||
down_revision = '7bbc2215d87d'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('user', sa.Column('google_credentials', sa.String(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('user', 'google_credentials')
|
||||
# ### end Alembic commands ###
|
@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 7bbc2215d87d
|
||||
Revises: 92db2e496087
|
||||
Create Date: 2020-04-24 11:36:43.600038
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7bbc2215d87d'
|
||||
down_revision = '92db2e496087'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('user', sa.Column('calendarJson', sa.String(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('user', 'calendarJson')
|
||||
# ### end Alembic commands ###
|
@ -1,8 +1,8 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 92db2e496087
|
||||
Revision ID: af001b07177d
|
||||
Revises:
|
||||
Create Date: 2020-04-20 21:33:50.061962
|
||||
Create Date: 2020-05-16 13:53:02.747714
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '92db2e496087'
|
||||
revision = 'af001b07177d'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
@ -29,11 +29,13 @@ def upgrade():
|
||||
op.create_index(op.f('ix_calendar_name'), 'calendar', ['name'], unique=False)
|
||||
op.create_index(op.f('ix_calendar_usr_id'), 'calendar', ['usr_id'], unique=False)
|
||||
op.create_table('user',
|
||||
sa.Column('id', sa.String(length=21), nullable=False),
|
||||
sa.Column('id', sa.String(length=64), nullable=False),
|
||||
sa.Column('username', sa.String(length=64), nullable=True),
|
||||
sa.Column('email', sa.String(length=120), nullable=True),
|
||||
sa.Column('profile_pic', sa.String(length=256), nullable=True),
|
||||
sa.Column('password_hash', sa.String(length=128), nullable=True),
|
||||
sa.Column('calendarJson', sa.String(), nullable=True),
|
||||
sa.Column('google_credentials', sa.String(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
|
13
routine.py
Normal file → Executable file
13
routine.py
Normal file → Executable file
@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
from backend.Routine import Routine
|
||||
import sched, time
|
||||
|
||||
s = sched.scheduler(time.time, time.sleep)
|
||||
routine = Routine()
|
||||
|
||||
def run_routine(sc):
|
||||
# do some stuff
|
||||
routine.start()
|
||||
|
||||
#schedule next routine
|
||||
s.enter(600, 1, run_routine, (sc,))
|
||||
|
||||
routine.start()
|
||||
s.enter(600, 1, run_routine, (s, ))
|
||||
s.run()
|
||||
|
@ -73,7 +73,7 @@ def verifyResponse():
|
||||
|
||||
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
|
||||
CLIENT_SECRETS_FILE, scopes=SCOPES, state=state)
|
||||
flow.redirect_uri = request.base_url
|
||||
flow.redirect_uri = flask.url_for('callback', _external=True)
|
||||
|
||||
# Use the authorization server's response to fetch the OAuth 2.0 tokens.
|
||||
authorization_response = flask.request.url
|
||||
@ -82,9 +82,10 @@ def verifyResponse():
|
||||
# Store credentials in the session.
|
||||
# ACTION ITEM: In a production app, you likely want to save these
|
||||
# credentials in a persistent database instead.
|
||||
|
||||
credentials = flow.credentials
|
||||
flask.session['credentials'] = credentials_to_dict(credentials)
|
||||
|
||||
print(credentials_to_dict(credentials), flush=True)
|
||||
session = flow.authorized_session()
|
||||
return session, credentials_to_dict(credentials)
|
||||
|
||||
|
@ -39,6 +39,7 @@ class User(UserMixin, db.Model):
|
||||
def getGoogleCredentials(self):
|
||||
|
||||
if self.google_credentials is None:
|
||||
print("no credentials", flush=True)
|
||||
return None
|
||||
return json.loads(self.google_credentials)
|
||||
|
||||
|
@ -116,6 +116,8 @@ def callback():
|
||||
print("login:" + user.id)
|
||||
|
||||
login_user(user)
|
||||
# TODO currently not using the credentials anymore
|
||||
if user.getGoogleCredentials() is None:
|
||||
user.setGoogleCredentials(credentials)
|
||||
return flask.redirect(flask.url_for('index'))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user