diff --git a/app/admin/routes.py b/app/admin/routes.py index 011de1bb..38ad9253 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -6,7 +6,6 @@ from app.decorators import admin_required from app.models import Role, User, UserSettingJobStatusMailNotificationLevel from app.settings.forms import ( EditGeneralSettingsForm, - EditInterfaceSettingsForm, EditNotificationSettingsForm ) from . import bp @@ -55,9 +54,6 @@ def edit_user(user_id): user, prefix='edit-general-settings-form' ) - edit_interface_settings_form = EditInterfaceSettingsForm( - prefix='edit-interface-settings-form' - ) edit_notification_settings_form = EditNotificationSettingsForm( prefix='edit-notification-settings-form' ) @@ -76,12 +72,6 @@ def edit_user(user_id): db.session.commit() flash('Your changes have been saved') 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 and edit_notification_settings_form.validate()): 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)) admin_edit_user_form.prefill(user) edit_general_settings_form.prefill(user) - edit_interface_settings_form.prefill(user) edit_notification_settings_form.prefill(user) return render_template( 'admin/edit_user.html.j2', admin_edit_user_form=admin_edit_user_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, title='Edit user', user=user diff --git a/app/api/schemas.py b/app/api/schemas.py index 9474bd1a..7abb56de 100644 --- a/app/api/schemas.py +++ b/app/api/schemas.py @@ -150,7 +150,6 @@ class UserSchema(ma.SQLAlchemySchema): last_seen = ma.auto_field(dump_only=True) password = ma.String(load_only=True) last_seen = ma.auto_field(dump_only=True) - setting_dark_mode = ma.auto_field() setting_job_status_mail_notification_level = ma.String( validate=validate.OneOf(list(UserSettingJobStatusMailNotificationLevel.__members__.keys())) ) diff --git a/app/models.py b/app/models.py index 16ff2725..f4889bbd 100644 --- a/app/models.py +++ b/app/models.py @@ -263,7 +263,6 @@ class User(HashidMixin, UserMixin, db.Model): password_hash = db.Column(db.String(128)) confirmed = db.Column(db.Boolean, default=False) 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( IntEnumColumn(UserSettingJobStatusMailNotificationLevel), default=UserSettingJobStatusMailNotificationLevel.END @@ -500,7 +499,6 @@ class User(HashidMixin, UserMixin, db.Model): 'member_since': f'{self.member_since.isoformat()}Z', 'username': self.username, 'settings': { - 'dark_mode': self.setting_dark_mode, 'job_status_mail_notification_level': \ self.setting_job_status_mail_notification_level.name } diff --git a/app/settings/forms.py b/app/settings/forms.py index 3bd3b5ab..00904e00 100644 --- a/app/settings/forms.py +++ b/app/settings/forms.py @@ -71,10 +71,6 @@ class EditGeneralSettingsForm(FlaskForm): super().__init__(*args, **kwargs) self.user = user - def prefill(self, user): - self.email.data = user.email - self.username.data = user.username - def validate_email(self, field): if (field.data != self.user.email and User.query.filter_by(email=field.data).first()): @@ -86,13 +82,6 @@ class EditGeneralSettingsForm(FlaskForm): 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): job_status_mail_notification_level = SelectField( 'Job status mail notification level', diff --git a/app/settings/routes.py b/app/settings/routes.py index eb2636e8..0604eb06 100644 --- a/app/settings/routes.py +++ b/app/settings/routes.py @@ -6,7 +6,6 @@ from . import bp from .forms import ( ChangePasswordForm, EditGeneralSettingsForm, - EditInterfaceSettingsForm, EditNotificationSettingsForm ) @@ -20,11 +19,9 @@ def settings(): ) edit_general_settings_form = EditGeneralSettingsForm( current_user, + obj=current_user, prefix='edit-general-settings-form' ) - edit_interface_settings_form = EditInterfaceSettingsForm( - prefix='edit-interface-settings-form' - ) edit_notification_settings_form = EditNotificationSettingsForm( prefix='edit-notification-settings-form' ) @@ -41,13 +38,6 @@ def settings(): db.session.commit() flash('Your changes have been saved') 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 and edit_notification_settings_form.validate()): current_user.setting_job_status_mail_notification_level = ( @@ -58,14 +48,11 @@ def settings(): db.session.commit() flash('Your changes have been saved') 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) return render_template( 'settings/settings.html.j2', change_password_form=change_password_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, title='Settings' ) diff --git a/app/templates/admin/edit_user.html.j2 b/app/templates/admin/edit_user.html.j2 index 45c27c6a..13e8a473 100644 --- a/app/templates/admin/edit_user.html.j2 +++ b/app/templates/admin/edit_user.html.j2 @@ -27,38 +27,6 @@ -
- - -