mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
Remove darkmode setting
This commit is contained in:
parent
e92624f0c0
commit
bbea1553b8
@ -6,7 +6,6 @@ from app.decorators import admin_required
|
|||||||
from app.models import Role, User, UserSettingJobStatusMailNotificationLevel
|
from app.models import Role, User, UserSettingJobStatusMailNotificationLevel
|
||||||
from app.settings.forms import (
|
from app.settings.forms import (
|
||||||
EditGeneralSettingsForm,
|
EditGeneralSettingsForm,
|
||||||
EditInterfaceSettingsForm,
|
|
||||||
EditNotificationSettingsForm
|
EditNotificationSettingsForm
|
||||||
)
|
)
|
||||||
from . import bp
|
from . import bp
|
||||||
@ -55,9 +54,6 @@ def edit_user(user_id):
|
|||||||
user,
|
user,
|
||||||
prefix='edit-general-settings-form'
|
prefix='edit-general-settings-form'
|
||||||
)
|
)
|
||||||
edit_interface_settings_form = EditInterfaceSettingsForm(
|
|
||||||
prefix='edit-interface-settings-form'
|
|
||||||
)
|
|
||||||
edit_notification_settings_form = EditNotificationSettingsForm(
|
edit_notification_settings_form = EditNotificationSettingsForm(
|
||||||
prefix='edit-notification-settings-form'
|
prefix='edit-notification-settings-form'
|
||||||
)
|
)
|
||||||
@ -76,12 +72,6 @@ def edit_user(user_id):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Your changes have been saved')
|
flash('Your changes have been saved')
|
||||||
return redirect(url_for('.edit_user', user_id=user.id))
|
return redirect(url_for('.edit_user', user_id=user.id))
|
||||||
if (edit_interface_settings_form.submit.data
|
|
||||||
and edit_interface_settings_form.validate()):
|
|
||||||
user.setting_dark_mode = edit_interface_settings_form.dark_mode.data
|
|
||||||
db.session.commit()
|
|
||||||
flash('Your changes have been saved')
|
|
||||||
return redirect(url_for('.edit_user', user_id=user.id))
|
|
||||||
if (edit_notification_settings_form.submit.data
|
if (edit_notification_settings_form.submit.data
|
||||||
and edit_notification_settings_form.validate()):
|
and edit_notification_settings_form.validate()):
|
||||||
user.setting_job_status_mail_notification_level = \
|
user.setting_job_status_mail_notification_level = \
|
||||||
@ -93,13 +83,11 @@ def edit_user(user_id):
|
|||||||
return redirect(url_for('.edit_user', user_id=user.id))
|
return redirect(url_for('.edit_user', user_id=user.id))
|
||||||
admin_edit_user_form.prefill(user)
|
admin_edit_user_form.prefill(user)
|
||||||
edit_general_settings_form.prefill(user)
|
edit_general_settings_form.prefill(user)
|
||||||
edit_interface_settings_form.prefill(user)
|
|
||||||
edit_notification_settings_form.prefill(user)
|
edit_notification_settings_form.prefill(user)
|
||||||
return render_template(
|
return render_template(
|
||||||
'admin/edit_user.html.j2',
|
'admin/edit_user.html.j2',
|
||||||
admin_edit_user_form=admin_edit_user_form,
|
admin_edit_user_form=admin_edit_user_form,
|
||||||
edit_general_settings_form=edit_general_settings_form,
|
edit_general_settings_form=edit_general_settings_form,
|
||||||
edit_interface_settings_form=edit_interface_settings_form,
|
|
||||||
edit_notification_settings_form=edit_notification_settings_form,
|
edit_notification_settings_form=edit_notification_settings_form,
|
||||||
title='Edit user',
|
title='Edit user',
|
||||||
user=user
|
user=user
|
||||||
|
@ -150,7 +150,6 @@ class UserSchema(ma.SQLAlchemySchema):
|
|||||||
last_seen = ma.auto_field(dump_only=True)
|
last_seen = ma.auto_field(dump_only=True)
|
||||||
password = ma.String(load_only=True)
|
password = ma.String(load_only=True)
|
||||||
last_seen = ma.auto_field(dump_only=True)
|
last_seen = ma.auto_field(dump_only=True)
|
||||||
setting_dark_mode = ma.auto_field()
|
|
||||||
setting_job_status_mail_notification_level = ma.String(
|
setting_job_status_mail_notification_level = ma.String(
|
||||||
validate=validate.OneOf(list(UserSettingJobStatusMailNotificationLevel.__members__.keys()))
|
validate=validate.OneOf(list(UserSettingJobStatusMailNotificationLevel.__members__.keys()))
|
||||||
)
|
)
|
||||||
|
@ -263,7 +263,6 @@ class User(HashidMixin, UserMixin, db.Model):
|
|||||||
password_hash = db.Column(db.String(128))
|
password_hash = db.Column(db.String(128))
|
||||||
confirmed = db.Column(db.Boolean, default=False)
|
confirmed = db.Column(db.Boolean, default=False)
|
||||||
member_since = db.Column(db.DateTime(), default=datetime.utcnow)
|
member_since = db.Column(db.DateTime(), default=datetime.utcnow)
|
||||||
setting_dark_mode = db.Column(db.Boolean, default=False)
|
|
||||||
setting_job_status_mail_notification_level = db.Column(
|
setting_job_status_mail_notification_level = db.Column(
|
||||||
IntEnumColumn(UserSettingJobStatusMailNotificationLevel),
|
IntEnumColumn(UserSettingJobStatusMailNotificationLevel),
|
||||||
default=UserSettingJobStatusMailNotificationLevel.END
|
default=UserSettingJobStatusMailNotificationLevel.END
|
||||||
@ -500,7 +499,6 @@ class User(HashidMixin, UserMixin, db.Model):
|
|||||||
'member_since': f'{self.member_since.isoformat()}Z',
|
'member_since': f'{self.member_since.isoformat()}Z',
|
||||||
'username': self.username,
|
'username': self.username,
|
||||||
'settings': {
|
'settings': {
|
||||||
'dark_mode': self.setting_dark_mode,
|
|
||||||
'job_status_mail_notification_level': \
|
'job_status_mail_notification_level': \
|
||||||
self.setting_job_status_mail_notification_level.name
|
self.setting_job_status_mail_notification_level.name
|
||||||
}
|
}
|
||||||
|
@ -71,10 +71,6 @@ class EditGeneralSettingsForm(FlaskForm):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.user = user
|
self.user = user
|
||||||
|
|
||||||
def prefill(self, user):
|
|
||||||
self.email.data = user.email
|
|
||||||
self.username.data = user.username
|
|
||||||
|
|
||||||
def validate_email(self, field):
|
def validate_email(self, field):
|
||||||
if (field.data != self.user.email
|
if (field.data != self.user.email
|
||||||
and User.query.filter_by(email=field.data).first()):
|
and User.query.filter_by(email=field.data).first()):
|
||||||
@ -86,13 +82,6 @@ class EditGeneralSettingsForm(FlaskForm):
|
|||||||
raise ValidationError('Username already in use')
|
raise ValidationError('Username already in use')
|
||||||
|
|
||||||
|
|
||||||
class EditInterfaceSettingsForm(FlaskForm):
|
|
||||||
dark_mode = BooleanField('Dark mode')
|
|
||||||
submit = SubmitField()
|
|
||||||
|
|
||||||
def prefill(self, user):
|
|
||||||
self.dark_mode.data = user.setting_dark_mode
|
|
||||||
|
|
||||||
class EditNotificationSettingsForm(FlaskForm):
|
class EditNotificationSettingsForm(FlaskForm):
|
||||||
job_status_mail_notification_level = SelectField(
|
job_status_mail_notification_level = SelectField(
|
||||||
'Job status mail notification level',
|
'Job status mail notification level',
|
||||||
|
@ -6,7 +6,6 @@ from . import bp
|
|||||||
from .forms import (
|
from .forms import (
|
||||||
ChangePasswordForm,
|
ChangePasswordForm,
|
||||||
EditGeneralSettingsForm,
|
EditGeneralSettingsForm,
|
||||||
EditInterfaceSettingsForm,
|
|
||||||
EditNotificationSettingsForm
|
EditNotificationSettingsForm
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,11 +19,9 @@ def settings():
|
|||||||
)
|
)
|
||||||
edit_general_settings_form = EditGeneralSettingsForm(
|
edit_general_settings_form = EditGeneralSettingsForm(
|
||||||
current_user,
|
current_user,
|
||||||
|
obj=current_user,
|
||||||
prefix='edit-general-settings-form'
|
prefix='edit-general-settings-form'
|
||||||
)
|
)
|
||||||
edit_interface_settings_form = EditInterfaceSettingsForm(
|
|
||||||
prefix='edit-interface-settings-form'
|
|
||||||
)
|
|
||||||
edit_notification_settings_form = EditNotificationSettingsForm(
|
edit_notification_settings_form = EditNotificationSettingsForm(
|
||||||
prefix='edit-notification-settings-form'
|
prefix='edit-notification-settings-form'
|
||||||
)
|
)
|
||||||
@ -41,13 +38,6 @@ def settings():
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Your changes have been saved')
|
flash('Your changes have been saved')
|
||||||
return redirect(url_for('.settings'))
|
return redirect(url_for('.settings'))
|
||||||
if (edit_interface_settings_form.submit.data
|
|
||||||
and edit_interface_settings_form.validate()):
|
|
||||||
current_user.setting_dark_mode = (
|
|
||||||
edit_interface_settings_form.dark_mode.data)
|
|
||||||
db.session.commit()
|
|
||||||
flash('Your changes have been saved')
|
|
||||||
return redirect(url_for('.settings'))
|
|
||||||
if (edit_notification_settings_form.submit.data
|
if (edit_notification_settings_form.submit.data
|
||||||
and edit_notification_settings_form.validate()):
|
and edit_notification_settings_form.validate()):
|
||||||
current_user.setting_job_status_mail_notification_level = (
|
current_user.setting_job_status_mail_notification_level = (
|
||||||
@ -58,14 +48,11 @@ def settings():
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Your changes have been saved')
|
flash('Your changes have been saved')
|
||||||
return redirect(url_for('.settings'))
|
return redirect(url_for('.settings'))
|
||||||
edit_general_settings_form.prefill(current_user)
|
|
||||||
edit_interface_settings_form.prefill(current_user)
|
|
||||||
edit_notification_settings_form.prefill(current_user)
|
edit_notification_settings_form.prefill(current_user)
|
||||||
return render_template(
|
return render_template(
|
||||||
'settings/settings.html.j2',
|
'settings/settings.html.j2',
|
||||||
change_password_form=change_password_form,
|
change_password_form=change_password_form,
|
||||||
edit_general_settings_form=edit_general_settings_form,
|
edit_general_settings_form=edit_general_settings_form,
|
||||||
edit_interface_settings_form=edit_interface_settings_form,
|
|
||||||
edit_notification_settings_form=edit_notification_settings_form,
|
edit_notification_settings_form=edit_notification_settings_form,
|
||||||
title='Settings'
|
title='Settings'
|
||||||
)
|
)
|
||||||
|
@ -27,38 +27,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form method="POST">
|
|
||||||
{{ edit_interface_settings_form.hidden_tag() }}
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-content">
|
|
||||||
<span class="card-title">Interface settings</span>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s1">
|
|
||||||
<p><i class="material-icons">brightness_3</i></p>
|
|
||||||
</div>
|
|
||||||
<div class="col s8">
|
|
||||||
<p>{{ edit_interface_settings_form.dark_mode.label.text }}</p>
|
|
||||||
<p class="light">Enable dark mode to ease your eyes.</p>
|
|
||||||
</div>
|
|
||||||
<div class="col s3 right-align">
|
|
||||||
<div class="switch">
|
|
||||||
<label>
|
|
||||||
{{ edit_interface_settings_form.dark_mode() }}
|
|
||||||
<span class="lever"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card-action">
|
|
||||||
<div class="right-align">
|
|
||||||
{{ wtf.render_field(edit_interface_settings_form.submit, material_icon='send') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
{{ edit_notification_settings_form.hidden_tag() }}
|
{{ edit_notification_settings_form.hidden_tag() }}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
@ -5,12 +5,6 @@
|
|||||||
{% block head %}
|
{% block head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<link href="{{ url_for('static', filename='images/nopaque_-_favicon.png') }}" rel="icon">
|
<link href="{{ url_for('static', filename='images/nopaque_-_favicon.png') }}" rel="icon">
|
||||||
{% if current_user.setting_dark_mode %}
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/darkreader/4.9.40/darkreader.min.js" integrity="sha512-0Jbi9gWSyU5SvNS16za0aILl6l+MgM8N+TGlZxy4qPQEzqKoU9egh4h56Kz0xp2R+ZFPQMfeDn26Gh6cqu2WAg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
|
||||||
<script>
|
|
||||||
DarkReader.enable();
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock head %}
|
{% endblock head %}
|
||||||
|
|
||||||
{% block metas %}
|
{% block metas %}
|
||||||
|
@ -27,38 +27,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form method="POST">
|
|
||||||
{{ edit_interface_settings_form.hidden_tag() }}
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-content">
|
|
||||||
<span class="card-title">Interface settings</span>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s1">
|
|
||||||
<p><i class="material-icons">brightness_3</i></p>
|
|
||||||
</div>
|
|
||||||
<div class="col s8">
|
|
||||||
<p>{{ edit_interface_settings_form.dark_mode.label.text }}</p>
|
|
||||||
<p class="light">Enable dark mode to ease your eyes.</p>
|
|
||||||
</div>
|
|
||||||
<div class="col s3 right-align">
|
|
||||||
<div class="switch">
|
|
||||||
<label>
|
|
||||||
{{ edit_interface_settings_form.dark_mode() }}
|
|
||||||
<span class="lever"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card-action">
|
|
||||||
<div class="right-align">
|
|
||||||
{{ wtf.render_field(edit_interface_settings_form.submit, material_icon='send') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
{{ edit_notification_settings_form.hidden_tag() }}
|
{{ edit_notification_settings_form.hidden_tag() }}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
26
migrations/versions/89e9526089bf_.py
Normal file
26
migrations/versions/89e9526089bf_.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
"""Remove setting_dark_mode column from users table
|
||||||
|
|
||||||
|
Revision ID: 89e9526089bf
|
||||||
|
Revises: 721829b5dd25
|
||||||
|
Create Date: 2022-11-17 09:47:27.724692
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '89e9526089bf'
|
||||||
|
down_revision = '721829b5dd25'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.drop_column('users', 'setting_dark_mode')
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.add_column('users',
|
||||||
|
sa.Column('setting_dark_mode', sa.Boolean(), nullable=True)
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user