24 lines
793 B
Python
24 lines
793 B
Python
from flask import flash, redirect, render_template, url_for
|
|
from flask_login import current_user, login_required
|
|
|
|
from . import bp
|
|
from .forms import PreferencesForm
|
|
from .services import update_preferences
|
|
|
|
|
|
@bp.route("/", methods=["GET", "POST"])
|
|
@login_required
|
|
def index():
|
|
form = PreferencesForm(obj=current_user)
|
|
if form.validate_on_submit():
|
|
update_preferences(
|
|
current_user,
|
|
theme=form.theme.data,
|
|
dyslexia_font=form.dyslexia_font.data,
|
|
completion_chime=form.completion_chime.data,
|
|
notification_frequency=form.notification_frequency.data,
|
|
)
|
|
flash("Preferences saved.", "success")
|
|
return redirect(url_for("settings.index"))
|
|
return render_template("settings/index.html", form=form)
|
|
|