Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
9b4a4e25
Commit
9b4a4e25
authored
3 years ago
by
Martin Mareš
Committed by
Jan Prachař
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Nastavení účtu obsahuje přepínač emailových notifikací
V DB jsme ho už měli.
parent
d2776fda
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/web/acct.py
+25
-4
25 additions, 4 deletions
mo/web/acct.py
mo/web/templates/settings.html
+14
-0
14 additions, 0 deletions
mo/web/templates/settings.html
with
39 additions
and
4 deletions
mo/web/acct.py
+
25
−
4
View file @
9b4a4e25
...
...
@@ -107,9 +107,27 @@ def incarnate(id):
return
login_and_redirect
(
new_user
,
flash_msg
=
'
Převtělení proběhlo
'
)
@app.route
(
'
/acct/settings
'
)
class
AcctSettingsForm
(
FlaskForm
):
email_notify
=
wtforms
.
BooleanField
(
'
Posílat e-mailové notifikace
'
)
submit
=
wtforms
.
SubmitField
(
'
Nastavit
'
)
@app.route
(
'
/acct/settings
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
user_settings
():
sess
=
db
.
get_session
()
user
=
g
.
user
form
=
AcctSettingsForm
()
if
not
form
.
submit
.
data
:
form
.
email_notify
.
data
=
user
.
email_notify
if
form
.
validate_on_submit
():
user
.
email_notify
=
form
.
email_notify
.
data
app
.
logger
.
info
(
f
'
Settings: Změněny preference uživatele #
{
user
.
user_id
}
:
{
db
.
get_object_changes
(
user
)
}
'
)
# Do databázového logu nezapisujeme, nemá smysl logovat prkotiny.
sess
.
commit
()
flash
(
'
Nastavení změněno.
'
,
'
success
'
)
return
redirect
(
url_for
(
'
user_settings
'
))
roles
=
(
sess
.
query
(
db
.
UserRole
)
.
filter_by
(
user_id
=
g
.
user
.
user_id
)
...
...
@@ -121,10 +139,13 @@ def user_settings():
else
:
pant
=
sess
.
query
(
db
.
Participant
).
get
((
g
.
user
.
user_id
,
mo
.
current_year
))
return
render_template
(
'
settings.html
'
,
user
=
g
.
user
,
pant
=
pant
,
roles
=
roles
,
roles_by_type
=
mo
.
rights
.
roles_by_type
)
return
render_template
(
'
settings.html
'
,
user
=
g
.
user
,
pant
=
pant
,
roles
=
roles
,
roles_by_type
=
mo
.
rights
.
roles_by_type
,
form
=
form
)
class
SettingsForm
(
FlaskForm
):
class
Personal
SettingsForm
(
FlaskForm
):
email
=
mo_fields
.
Email
(
validators
=
[
validators
.
DataRequired
()])
current_passwd
=
mo_fields
.
Password
(
'
Aktuální heslo
'
,
validators
=
[
validators
.
DataRequired
()])
new_passwd
=
mo_fields
.
NewPassword
(
...
...
@@ -143,7 +164,7 @@ def user_settings_personal():
sess
=
db
.
get_session
()
user
=
g
.
user
form
=
SettingsForm
()
form
=
Personal
SettingsForm
()
if
not
form
.
submit
.
data
:
form
.
email
.
data
=
user
.
email
...
...
This diff is collapsed.
Click to expand it.
mo/web/templates/settings.html
+
14
−
0
View file @
9b4a4e25
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}Uživatel {{ user.full_name() }}{% endblock %}
{% block body %}
...
...
@@ -20,6 +21,19 @@
<p>
Pokud potřebujete změnit jiné údaje, ozvěte se svému učiteli nebo garantovi.
Neuspějete-li u nich, napište správci OSMO (kontakt viz patička stránky).
<h3>
Nastavení
</h3>
<form
action=
""
method=
"post"
class=
"form"
role=
"form"
>
{{ form.csrf_token }}
<div
class=
'form-group'
>
{{ wtf.form_field(form.email_notify, form_type='simple') }}
</div>
{{ wtf.form_field(form.submit, form_type='simple', button_map={'submit': 'primary'}) }}
</form>
{% if user.is_admin or user.is_org %}
<h3>
Práva
</h3>
...
...
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