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
08ba7476
Commit
08ba7476
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Plain Diff
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
parents
3135eb08
4d953f85
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/profile/forms.py
+2
-2
2 additions, 2 deletions
app/profile/forms.py
app/profile/views.py
+47
-28
47 additions, 28 deletions
app/profile/views.py
app/templates/profile/index.html.j2
+8
-8
8 additions, 8 deletions
app/templates/profile/index.html.j2
with
57 additions
and
38 deletions
app/profile/forms.py
+
2
−
2
View file @
08ba7476
from
flask_wtf
import
FlaskForm
from
flask_wtf
import
FlaskForm
from
wtforms
import
(
PasswordField
,
StringField
,
SubmitField
,
from
wtforms
import
(
PasswordField
,
StringField
,
SubmitField
,
ValidationError
,
BooleanField
)
ValidationError
,
BooleanField
)
from
wtforms.validators
import
DataRequired
,
EqualTo
,
Length
from
wtforms.validators
import
DataRequired
,
EqualTo
,
Length
,
Email
from
..models
import
User
from
..models
import
User
import
logging
import
logging
...
@@ -26,7 +26,7 @@ class ChangePasswordForm(FlaskForm):
...
@@ -26,7 +26,7 @@ class ChangePasswordForm(FlaskForm):
class
EditProfileForm
(
FlaskForm
):
class
EditProfileForm
(
FlaskForm
):
email
=
StringField
(
'
Change Email
'
,
email
=
StringField
(
'
Change Email
'
,
validators
=
[
Length
(
0
,
254
),
DataRequired
()])
validators
=
[
Email
(
),
DataRequired
()])
submit
=
SubmitField
(
'
Change Email
'
)
submit
=
SubmitField
(
'
Change Email
'
)
def
__init__
(
self
,
user
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
user
,
*
args
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
app/profile/views.py
+
47
−
28
View file @
08ba7476
from
app.utils
import
background_delete_user
from
app.utils
import
background_delete_user
from
flask
import
current_app
,
flash
,
redirect
,
render_template
,
url_for
from
flask
import
abort
,
current_app
,
flash
,
redirect
,
render_template
,
url_for
from
flask_login
import
current_user
,
login_required
,
logout_user
from
flask_login
import
current_user
,
login_required
,
logout_user
from
.
import
profile
from
.
import
profile
from
.forms
import
ChangePasswordForm
,
EditProfileForm
,
EditUserSettingsForm
from
.forms
import
ChangePasswordForm
,
EditProfileForm
,
EditUserSettingsForm
...
@@ -16,44 +16,63 @@ def index():
...
@@ -16,44 +16,63 @@ def index():
"""
"""
View where loged in User can change own User information like Password etc.
View where loged in User can change own User information like Password etc.
"""
"""
change_password_form
=
ChangePasswordForm
()
edit_user_info_form
=
EditProfileForm
(
user
=
current_user
)
if
change_password_form
.
validate_on_submit
():
edit_user_info_form
.
email
.
data
=
current_user
.
email
if
current_user
.
verify_password
(
change_password_form
.
old_password
.
data
):
return
render_template
(
'
profile/index.html.j2
'
,
current_user
.
password
=
change_password_form
.
new_password
.
data
change_password_form
=
ChangePasswordForm
(),
db
.
session
.
add
(
current_user
)
edit_user_info_form
=
edit_user_info_form
,
db
.
session
.
commit
()
edit_user_settings_form
=
EditUserSettingsForm
(),
flash
(
'
Your password has been updated.
'
)
title
=
'
Profile
'
)
return
redirect
(
url_for
(
'
profile.index
'
))
else
:
flash
(
'
Invalid password.
'
)
change_profile_form
=
EditProfileForm
(
user
=
current_user
)
if
change_profile_form
.
validate_on_submit
():
current_user
.
email
=
change_profile_form
.
email
.
data
db
.
session
.
add
(
current_user
.
_get_current_object
())
db
.
session
.
commit
()
flash
(
'
Your email has been updated.
'
)
change_profile_form
.
email
.
data
=
current_user
.
email
edit_user_settings_form
=
EditUserSettingsForm
()
@profile.route
(
'
/change_password
'
,
methods
=
[
'
POST
'
])
if
edit_user_settings_form
.
validate_on_submit
():
@login_required
current_user
.
is_dark
=
edit_user_settings_form
.
is_dark
.
data
def
profile_change_password
():
logger
.
warning
(
'
Form data: {}
'
.
format
(
current_user
.
is_dark
))
change_password_form
=
ChangePasswordForm
()
if
not
change_password_form
.
validate_on_submit
():
abort
(
400
)
if
current_user
.
verify_password
(
change_password_form
.
old_password
.
data
):
current_user
.
password
=
change_password_form
.
new_password
.
data
db
.
session
.
add
(
current_user
)
db
.
session
.
add
(
current_user
)
db
.
session
.
commit
()
db
.
session
.
commit
()
flash
(
'
Your password has been updated.
'
)
else
:
flash
(
'
Invalid password.
'
)
return
redirect
(
url_for
(
'
profile.index
'
))
return
render_template
(
'
profile/index.html.j2
'
,
change_password_form
=
change_password_form
,
@profile.route
(
'
/edit_user_info
'
,
methods
=
[
'
POST
'
])
change_profile_form
=
change_profile_form
,
@login_required
edit_user_settings_form
=
edit_user_settings_form
,
def
profile_edit_user_info
():
title
=
'
Profile
'
)
edit_user_info_form
=
EditProfileForm
(
user
=
current_user
)
if
not
edit_user_info_form
.
validate_on_submit
():
abort
(
400
)
current_user
.
email
=
edit_user_info_form
.
email
.
data
db
.
session
.
add
(
current_user
.
_get_current_object
())
db
.
session
.
commit
()
flash
(
'
Your email has been updated.
'
)
edit_user_info_form
.
email
.
data
=
current_user
.
email
return
redirect
(
url_for
(
'
profile.index
'
))
@profile.route
(
'
/edit_user_settings
'
,
methods
=
[
'
POST
'
])
@login_required
def
profile_edit_user_settings
():
edit_user_settings_form
=
EditUserSettingsForm
()
if
not
edit_user_settings_form
.
validate_on_submit
():
abort
(
400
)
current_user
.
is_dark
=
edit_user_settings_form
.
is_dark
.
data
logger
.
warning
(
'
Form data: {}
'
.
format
(
current_user
.
is_dark
))
db
.
session
.
add
(
current_user
)
db
.
session
.
commit
()
return
redirect
(
url_for
(
'
profile.index
'
))
@profile.route
(
'
/delete_self
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@profile.route
(
'
/delete_self
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@login_required
@login_required
def
delete_self
():
def
delete_self
():
"""
"""
Vie to delete yourslef and all associated data.
Vie
w
to delete yourslef and all associated data.
"""
"""
delete_thread
=
threading
.
Thread
(
delete_thread
=
threading
.
Thread
(
target
=
background_delete_user
,
target
=
background_delete_user
,
...
...
This diff is collapsed.
Click to expand it.
app/templates/profile/index.html.j2
+
8
−
8
View file @
08ba7476
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<div class="col s12 m8">
<div class="col s12 m8">
<div class="card">
<div class="card">
<div class="card-content">
<div class="card-content">
<form method="POST">
<form
action="{{ url_for('profile.profile_edit_user_settings') }}"
method="POST">
{{ edit_user_settings_form.hidden_tag() }}
{{ edit_user_settings_form.hidden_tag() }}
<div class="switch">
<div class="switch">
<i class="material-icons prefix">brightness_3</i>
<i class="material-icons prefix">brightness_3</i>
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
</div>
</div>
<div class="col s12 m8">
<div class="col s12 m8">
<div class="card">
<div class="card">
<form method="POST">
<form
action="{{ url_for('profile.profile_change_password') }}"
method="POST">
<div class="card-content">
<div class="card-content">
{{ change_password_form.hidden_tag() }}
{{ change_password_form.hidden_tag() }}
<div class="input-field ">
<div class="input-field ">
...
@@ -79,20 +79,20 @@
...
@@ -79,20 +79,20 @@
</div>
</div>
<div class="col s12 m8">
<div class="col s12 m8">
<div class="card">
<div class="card">
<form method="POST">
<form
action="{{ url_for('profile.profile_edit_user_info')}}"
method="POST">
<div class="card-content">
<div class="card-content">
{{
change_profile
_form.hidden_tag() }}
{{
edit_user_info
_form.hidden_tag() }}
<div class="input-field">
<div class="input-field">
<i class="material-icons prefix">mail</i>
<i class="material-icons prefix">mail</i>
{{
change_profile
_form.email() }}
{{
edit_user_info
_form.email() }}
{{
change_profile
_form.email.label }}
{{
edit_user_info
_form.email.label }}
{% for error in
change_profile
_form.email.errors %}
{% for error in
edit_user_info
_form.email.errors %}
<span class="helper-text red-text">{{ error }}</span>
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
{% endfor %}
</div>
</div>
</div>
</div>
<div class="card-action right-align">
<div class="card-action right-align">
{{
change_profile
_form.submit(class='btn') }}
{{
edit_user_info
_form.submit(class='btn') }}
</div>
</div>
</form>
</form>
</div>
</div>
...
...
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