mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +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)
|
||||
role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
|
||||
username = db.Column(db.String(64), unique=True, index=True)
|
||||
setting_dark_mode = db.Column(db.Boolean, default=False)
|
||||
# Relationships
|
||||
corpora = db.relationship('Corpus', backref='creator', lazy='dynamic',
|
||||
cascade='save-update, merge, delete')
|
||||
jobs = db.relationship('Job', backref='creator', lazy='dynamic',
|
||||
cascade='save-update, merge, delete')
|
||||
is_dark = db.Column(db.Boolean, default=False)
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
|
@ -25,7 +25,7 @@ def settings():
|
||||
# Check if edit_settings_form is submitted and valid
|
||||
if (edit_general_settings_form.save_settings.data
|
||||
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.commit()
|
||||
flash('Your settings have been updated.')
|
||||
@ -40,7 +40,7 @@ def settings():
|
||||
return redirect(url_for('profile.settings'))
|
||||
# If no form is submitted or valid, fill out fields with current values
|
||||
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(
|
||||
'profile/settings.html.j2',
|
||||
edit_email_form=edit_email_form,
|
||||
|
@ -50,7 +50,7 @@
|
||||
<script src="{{ url_for('static', filename='js/nopaque.lists.js') }}"></script>
|
||||
<script>
|
||||
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 }};
|
||||
</script>
|
||||
</head>
|
||||
|
Loading…
Reference in New Issue
Block a user