mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 19:04:18 +00:00
Change darmode setting
This commit is contained in:
parent
3a05a4d2f4
commit
7cfa3bd022
@ -109,12 +109,12 @@ class User(UserMixin, db.Model):
|
|||||||
registration_date = db.Column(db.DateTime(), default=datetime.utcnow)
|
registration_date = db.Column(db.DateTime(), default=datetime.utcnow)
|
||||||
role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
|
role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
|
||||||
username = db.Column(db.String(64), unique=True, index=True)
|
username = db.Column(db.String(64), unique=True, index=True)
|
||||||
|
setting_dark_mode = db.Column(db.Boolean, default=False)
|
||||||
# Relationships
|
# Relationships
|
||||||
corpora = db.relationship('Corpus', backref='creator', lazy='dynamic',
|
corpora = db.relationship('Corpus', backref='creator', lazy='dynamic',
|
||||||
cascade='save-update, merge, delete')
|
cascade='save-update, merge, delete')
|
||||||
jobs = db.relationship('Job', backref='creator', lazy='dynamic',
|
jobs = db.relationship('Job', backref='creator', lazy='dynamic',
|
||||||
cascade='save-update, merge, delete')
|
cascade='save-update, merge, delete')
|
||||||
is_dark = db.Column(db.Boolean, default=False)
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""
|
"""
|
||||||
|
@ -25,7 +25,7 @@ def settings():
|
|||||||
# Check if edit_settings_form is submitted and valid
|
# Check if edit_settings_form is submitted and valid
|
||||||
if (edit_general_settings_form.save_settings.data
|
if (edit_general_settings_form.save_settings.data
|
||||||
and edit_general_settings_form.validate_on_submit()):
|
and edit_general_settings_form.validate_on_submit()):
|
||||||
current_user.is_dark = edit_general_settings_form.dark_mode.data
|
current_user.setting_dark_mode = edit_general_settings_form.dark_mode.data
|
||||||
db.session.add(current_user)
|
db.session.add(current_user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Your settings have been updated.')
|
flash('Your settings have been updated.')
|
||||||
@ -40,7 +40,7 @@ def settings():
|
|||||||
return redirect(url_for('profile.settings'))
|
return redirect(url_for('profile.settings'))
|
||||||
# If no form is submitted or valid, fill out fields with current values
|
# If no form is submitted or valid, fill out fields with current values
|
||||||
edit_email_form.email.data = current_user.email
|
edit_email_form.email.data = current_user.email
|
||||||
edit_general_settings_form.dark_mode.data = current_user.is_dark
|
edit_general_settings_form.dark_mode.data = current_user.setting_dark_mode
|
||||||
return render_template(
|
return render_template(
|
||||||
'profile/settings.html.j2',
|
'profile/settings.html.j2',
|
||||||
edit_email_form=edit_email_form,
|
edit_email_form=edit_email_form,
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
<script src="{{ url_for('static', filename='js/nopaque.lists.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/nopaque.lists.js') }}"></script>
|
||||||
<script>
|
<script>
|
||||||
nopaque.user.isAuthenticated = {{ current_user.is_authenticated|tojson }};
|
nopaque.user.isAuthenticated = {{ current_user.is_authenticated|tojson }};
|
||||||
nopaque.user.settings.darkMode = {{ (current_user.is_authenticated and current_user.is_dark)|tojson }};
|
nopaque.user.settings.darkMode = {{ (current_user.is_authenticated and current_user.setting_dark_mode)|tojson }};
|
||||||
nopaque.flashedMessages = {{ get_flashed_messages(with_categories=true)|tojson }};
|
nopaque.flashedMessages = {{ get_flashed_messages(with_categories=true)|tojson }};
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
Loading…
Reference in New Issue
Block a user