Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
980b8cc1
Commit
980b8cc1
authored
2 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Codestyle enhancements
parent
32081127
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/models.py
+3
-2
3 additions, 2 deletions
app/models.py
app/settings/forms.py
+8
-29
8 additions, 29 deletions
app/settings/forms.py
app/settings/routes.py
+10
-15
10 additions, 15 deletions
app/settings/routes.py
with
21 additions
and
46 deletions
app/models.py
+
3
−
2
View file @
980b8cc1
...
...
@@ -127,6 +127,8 @@ class IntEnumColumn(db.TypeDecorator):
return
value
.
value
elif
isinstance
(
value
,
int
):
return
self
.
enum_type
(
value
).
value
elif
isinstance
(
value
,
str
):
return
self
.
enum_type
[
value
].
value
else
:
return
TypeError
()
...
...
@@ -144,8 +146,7 @@ class ContainerColumn(db.TypeDecorator):
def
process_bind_param
(
self
,
value
,
dialect
):
if
isinstance
(
value
,
self
.
container_type
):
return
json
.
dumps
(
value
)
elif
(
isinstance
(
value
,
str
)
and
isinstance
(
json
.
loads
(
value
),
self
.
container_type
)):
elif
isinstance
(
value
,
str
)
and
isinstance
(
json
.
loads
(
value
),
self
.
container_type
):
return
value
else
:
return
TypeError
()
...
...
This diff is collapsed.
Click to expand it.
app/settings/forms.py
+
8
−
29
View file @
980b8cc1
from
flask_wtf
import
FlaskForm
from
wtforms
import
(
BooleanField
,
FileField
,
PasswordField
,
SelectField
,
StringField
,
SubmitField
,
TextAreaField
,
ValidationError
)
from
wtforms.validators
import
(
DataRequired
,
InputRequired
,
Email
,
EqualTo
,
Length
,
Regexp
)
from
app.models
import
User
,
UserSettingJobStatusMailNotificationLevel
from
app.auth
import
USERNAME_REGEX
from
wtforms
import
PasswordField
,
SelectField
,
SubmitField
,
ValidationError
from
wtforms.validators
import
DataRequired
,
EqualTo
from
app.models
import
UserSettingJobStatusMailNotificationLevel
class
ChangePasswordForm
(
FlaskForm
):
...
...
@@ -47,18 +30,14 @@ class ChangePasswordForm(FlaskForm):
if
not
self
.
user
.
verify_password
(
field
.
data
):
raise
ValidationError
(
'
Invalid password
'
)
class
EditNotificationSettingsForm
(
FlaskForm
):
job_status_mail_notification_level
=
SelectField
(
'
Job status mail notification level
'
,
choices
=
[(
''
,
'
Choose your option
'
)],
choices
=
[
(
x
.
name
,
x
.
name
.
capitalize
())
for
x
in
UserSettingJobStatusMailNotificationLevel
],
validators
=
[
DataRequired
()]
)
submit
=
SubmitField
()
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
job_status_mail_notification_level
.
choices
+=
[
(
x
.
name
,
x
.
name
.
capitalize
())
for
x
in
UserSettingJobStatusMailNotificationLevel
]
This diff is collapsed.
Click to expand it.
app/settings/routes.py
+
10
−
15
View file @
980b8cc1
from
flask
import
abort
,
flash
,
redirect
,
render_template
,
url_for
from
flask
import
flash
,
redirect
,
render_template
,
url_for
from
flask_login
import
current_user
,
login_required
from
app
import
db
from
app.models
import
ProfilePrivacySettings
,
UserSettingJobStatusMailNotificationLevel
from
app.models
import
UserSettingJobStatusMailNotificationLevel
from
.
import
bp
from
.forms
import
(
ChangePasswordForm
,
EditNotificationSettingsForm
)
from
.forms
import
ChangePasswordForm
,
EditNotificationSettingsForm
@bp.route
(
''
,
methods
=
[
'
GET
'
,
'
POST
'
])
...
...
@@ -20,22 +17,20 @@ def settings():
data
=
current_user
.
to_json_serializeable
(),
prefix
=
'
edit-notification-settings-form
'
)
# region handle change_password_form POST
if
change_password_form
.
submit
.
data
and
change_password_form
.
validate
():
current_user
.
password
=
change_password_form
.
new_password
.
data
db
.
session
.
commit
()
flash
(
'
Your changes have been saved
'
)
return
redirect
(
url_for
(
'
.index
'
))
if
(
edit_notification_settings_form
.
submit
and
edit_notification_settings_form
.
validate
()):
current_user
.
setting_job_status_mail_notification_level
=
(
UserSettingJobStatusMailNotificationLevel
[
edit_notification_settings_form
.
job_status_mail_notification_level
.
data
# noqa
]
)
return
redirect
(
url_for
(
'
.settings
'
))
# endregion handle change_password_form POST
# region handle edit_notification_settings_form POST
if
edit_notification_settings_form
.
submit
and
edit_notification_settings_form
.
validate
():
current_user
.
setting_job_status_mail_notification_level
=
edit_notification_settings_form
.
job_status_mail_notification_level
.
data
db
.
session
.
commit
()
flash
(
'
Your changes have been saved
'
)
return
redirect
(
url_for
(
'
.settings
'
))
# endregion handle edit_notification_settings_form POST
return
render_template
(
'
settings/settings.html.j2
'
,
change_password_form
=
change_password_form
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment