Compare commits
No commits in common. "c3dcccb479978f9dc55efc36b0efd549be84c50c" and "9ecaf0211fd2f81efc395660240087eb61479854" have entirely different histories.
c3dcccb479
...
9ecaf0211f
@ -96,53 +96,49 @@ def devices():
|
|||||||
|
|
||||||
|
|
||||||
@app.route("/calendar", methods=['GET', 'POST', 'DELETE'])
|
@app.route("/calendar", methods=['GET', 'POST', 'DELETE'])
|
||||||
|
@login_required
|
||||||
def calendar():
|
def calendar():
|
||||||
if not current_user.is_authenticated:
|
|
||||||
return flask.render_template('login.html')
|
|
||||||
|
|
||||||
calendars = backend.calendarsFromDb(current_user)
|
calendars = backend.calendarsFromDb(current_user)
|
||||||
|
|
||||||
form = CalendarForm()
|
form = CalendarForm()
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
|
||||||
if request.form.get("submit") == "Remove":
|
if form.validate_on_submit():
|
||||||
calendar = db.session.query(Calendar).filter(Calendar.calendar_id==request.form.get("calendar")).first()
|
# try to add the submitted ical as a calendar
|
||||||
db.session.delete(calendar)
|
print(form.iCalURL.data, flush=True)
|
||||||
db.session.commit()
|
|
||||||
return flask.redirect(url_for('calendar'))
|
|
||||||
|
|
||||||
elif form.validate_on_submit():
|
|
||||||
ical.icalToCalendarDb(form.iCalURL.data, form.calName.data, current_user)
|
|
||||||
return flask.redirect(url_for('calendar'))
|
|
||||||
|
|
||||||
|
|
||||||
|
ical.icalToCalendarDb(form.iCalURL.data, form.calName.data, current_user)
|
||||||
|
|
||||||
# otherwise it is a javascript POST
|
# otherwise it is a javascript POST
|
||||||
else:
|
else:
|
||||||
try:
|
calId = request.json.get('calendar_id')
|
||||||
calId = request.json.get('calendar_id')
|
color = request.json.get('color', None)
|
||||||
color = request.json.get('color', None)
|
toggle = request.json.get('toggle', None)
|
||||||
toggle = request.json.get('toggle', None)
|
|
||||||
except:
|
|
||||||
return flask.render_template('calendar.html', calendars=calendars, form=form)
|
|
||||||
|
|
||||||
if color != None:
|
if color != None:
|
||||||
current_user.updateCalendar(calId, color=color)
|
current_user.updateCalendar(calId, color=color)
|
||||||
if toggle != None:
|
if toggle != None:
|
||||||
current_user.updateCalendar(calId, toggle=toggle)
|
current_user.updateCalendar(calId, toggle=toggle)
|
||||||
# toggle specific calendar of user
|
# toggle specific calendar of user
|
||||||
try:
|
calId = request.json.get('calendar_id')
|
||||||
calId = request.json.get('calendar_id')
|
color = request.json.get('color', None)
|
||||||
color = request.json.get('color', None)
|
toggle = request.json.get('toggle', None)
|
||||||
toggle = request.json.get('toggle', None)
|
|
||||||
except:
|
|
||||||
return flask.render_template('calendar.html', calendars=calendars, form=form)
|
|
||||||
|
|
||||||
if color != None:
|
if color != None:
|
||||||
current_user.updateCalendar(calId, color=color)
|
current_user.updateCalendar(calId, color=color)
|
||||||
if toggle != None:
|
if toggle != None:
|
||||||
current_user.updateCalendar(calId, toggle=toggle)
|
current_user.updateCalendar(calId, toggle=toggle)
|
||||||
# toggle specific calendar of user
|
# toggle specific calendar of user
|
||||||
|
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
elif request.method == 'DELETE':
|
||||||
|
# do nothing
|
||||||
|
return 'NONE'
|
||||||
|
else:
|
||||||
|
# POST Error 405
|
||||||
|
print("405")
|
||||||
|
|
||||||
return flask.render_template('calendar.html', calendars=calendars, form=form)
|
return flask.render_template('calendar.html', calendars=calendars, form=form)
|
||||||
|
|
||||||
|
@ -9,13 +9,6 @@
|
|||||||
|
|
||||||
{% for item in calendars %}
|
{% for item in calendars %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<!--action button-->
|
|
||||||
<div style="width: 4rem; margin: 1rem;">
|
|
||||||
<form action="" method="post">
|
|
||||||
<input type="hidden" name="calendar" value={{ item.calendarId }}>
|
|
||||||
<input type="submit" name="submit" value="Remove">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<!--Name-->
|
<!--Name-->
|
||||||
<div style="width: 15rem; margin: 1rem;">{{ item.name }}</div>
|
<div style="width: 15rem; margin: 1rem;">{{ item.name }}</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user