diff --git a/server/forms.py b/server/forms.py index 311ec75..2f1dda0 100644 --- a/server/forms.py +++ b/server/forms.py @@ -28,4 +28,8 @@ class RegistrationForm(FlaskForm): def validate_email(self, email): user = User.query.filter_by(email=email.data).first() if user is not None: - raise ValidationError('Please use a different email address.') \ No newline at end of file + raise ValidationError('Please use a different email address.') + +class DeviceForm(FlaskForm): + deviceId=StringField('New Device ID', validators=[DataRequired()]) + submit = SubmitField('Add New Device') diff --git a/server/googleHandler.py b/server/googleHandler.py index b36b089..888acd6 100644 --- a/server/googleHandler.py +++ b/server/googleHandler.py @@ -104,7 +104,7 @@ def calendarsFromDb(): calendars = dbCalendar.getCalendars(dbCalendar, current_user.id) pyCalendars = [] for calendar in calendars: - name = calendar.name + name = (calendar.name[:16] + '..') if len(calendar.name)> 18 else calendar.name calendarId = calendar.calendar_id toggle = calendar.toggle color = calendar.color diff --git a/server/models.py b/server/models.py index b28cbce..048fb0a 100644 --- a/server/models.py +++ b/server/models.py @@ -88,3 +88,7 @@ class Calendar(db.Model): db.session.add(newcal) db.session.commit() + +class Device(db.Model): + id = db.Column(db.Integer, primary_key=True) + deviceId = db.Column(db.String(128), index=True) diff --git a/server/routes.py b/server/routes.py index de35ceb..10e6750 100644 --- a/server/routes.py +++ b/server/routes.py @@ -19,8 +19,8 @@ import requests import server.googleHandler as google from server import login_manager, app, db -from server.forms import LoginForm, RegistrationForm -from server.models import User, Calendar +from server.forms import LoginForm, RegistrationForm, DeviceForm +from server.models import User, Calendar, Device os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' @@ -45,7 +45,23 @@ def view(): return flask.render_template('login.html') else: return (flask.render_template('view.html')) + +@app.route("/devices", methods=['GET', 'POST']) +def devices(): + if not current_user.is_authenticated: + return flask.render_template('login.html') + device = Device() + device.deviceId="Anthon-Mouse-Car" + devices = [device] + form = DeviceForm() + if form.validate_on_submit(): + print(form.deviceId.data, flush=True) + # TODO add device to database here + + return flask.render_template('devices.html', devices=devices, form=form) + + @app.route("/calendar") @login_required def calendar(): @@ -67,6 +83,7 @@ def emaillogin(): return redirect(url_for('account')) return render_template('emaillogin.html', title='Sign In', form=form) + @app.route('/register', methods=['GET', 'POST']) def register(): if current_user.is_authenticated: @@ -81,7 +98,7 @@ def register(): db.session.commit() flash('Congratulations, you are now a registered user!') return redirect(url_for('emaillogin')) - return render_template('register.html', title='Register', form=form) + return flask.render_template('register.html', title='Register', form=form) @app.route("/test") def testAPI(): diff --git a/server/static/css/main.css b/server/static/css/main.css index c40e035..3dfcf24 100644 --- a/server/static/css/main.css +++ b/server/static/css/main.css @@ -179,6 +179,15 @@ body * background-color: #b51409; } +.container .button.adddevice { + background-color: #ddd; + color: white; +} +.container .button.addcalendar { + background-color: #ddd; + color: white; +} + .sub.container { width: 20rem; justify-content: left; diff --git a/server/template/calendar.html b/server/template/calendar.html index ed8f6d1..2043fb3 100644 --- a/server/template/calendar.html +++ b/server/template/calendar.html @@ -1,20 +1,19 @@ {% extends "sidebar.html" %} {% block body%} -