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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
50ad8bda
Commit
50ad8bda
authored
4 years ago
by
Jiří Setnička
Browse files
Options
Downloads
Patches
Plain Diff
Tlačítko na pozvání zvacího emailu / resetování hesla v detailu soutěžícího/organizátora
Užitečné po změně emailu.
parent
535f147c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
mo/web/org_users.py
+31
-0
31 additions, 0 deletions
mo/web/org_users.py
mo/web/templates/org_org.html
+11
-4
11 additions, 4 deletions
mo/web/templates/org_org.html
mo/web/templates/org_user.html
+12
-5
12 additions, 5 deletions
mo/web/templates/org_user.html
with
54 additions
and
9 deletions
mo/web/org_users.py
+
31
−
0
View file @
50ad8bda
...
...
@@ -7,6 +7,7 @@ from sqlalchemy import or_
from
sqlalchemy.orm
import
joinedload
,
subqueryload
from
wtforms
import
validators
from
wtforms.fields.simple
import
SubmitField
from
wtforms.validators
import
Required
...
...
@@ -210,6 +211,20 @@ class FormRemoveRole(FlaskForm):
remove
=
wtforms
.
SubmitField
(
'
Odebrat roli
'
)
class
ResendInviteForm
(
FlaskForm
):
resend_invite
=
SubmitField
()
def
do
(
self
,
user
:
db
.
User
):
token
=
mo
.
users
.
ask_reset_password
(
user
)
db
.
get_session
().
commit
()
if
user
.
last_login_at
is
None
and
mo
.
util
.
send_new_account_email
(
user
,
token
):
flash
(
'
Uvítací e-mail s odkazem pro nastavení hesla odeslán na {}
'
.
format
(
user
.
email
),
'
success
'
)
elif
mo
.
util
.
send_password_reset_email
(
user
,
token
):
flash
(
'
E-mail s odkazem pro resetování hesla odeslán na {}
'
.
format
(
user
.
email
),
'
success
'
)
else
:
flash
(
'
Problém při odesílání e-mailu s odkazem pro nastavení hesla
'
,
'
danger
'
)
@app.route
(
'
/org/org/<int:id>/
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_org
(
id
:
int
):
sess
=
db
.
get_session
()
...
...
@@ -222,6 +237,13 @@ def org_org(id: int):
rr
=
g
.
gatekeeper
.
rights_generic
()
can_assign_rights
=
rr
.
have_right
(
Right
.
assign_rights
)
resend_invite_form
:
Optional
[
ResendInviteForm
]
=
None
if
rr
.
can_edit_user
(
user
):
resend_invite_form
=
ResendInviteForm
()
if
resend_invite_form
.
validate_on_submit
():
resend_invite_form
.
do
(
user
)
return
redirect
(
url_for
(
'
org_org
'
,
id
=
id
))
form_add_role
=
FormAddRole
()
form_remove_role
=
FormRemoveRole
()
role_errors
=
[]
...
...
@@ -286,6 +308,7 @@ def org_org(id: int):
can_incarnate
=
g
.
user
.
is_admin
,
roles_by_type
=
mo
.
rights
.
roles_by_type
,
role_errors
=
role_errors
,
form_add_role
=
form_add_role
,
form_remove_role
=
form_remove_role
,
resend_invite_form
=
resend_invite_form
,
)
...
...
@@ -300,6 +323,13 @@ def org_user(id: int):
rr
=
g
.
gatekeeper
.
rights_generic
()
resend_invite_form
:
Optional
[
ResendInviteForm
]
=
None
if
rr
.
can_edit_user
(
user
):
resend_invite_form
=
ResendInviteForm
()
if
resend_invite_form
.
validate_on_submit
():
resend_invite_form
.
do
(
user
)
return
redirect
(
url_for
(
'
org_user
'
,
id
=
id
))
participants
=
sess
.
query
(
db
.
Participant
).
filter_by
(
user_id
=
user
.
user_id
)
participations
=
(
sess
.
query
(
db
.
Participation
,
db
.
Contest
,
db
.
Round
)
...
...
@@ -316,6 +346,7 @@ def org_user(id: int):
'
org_user.html
'
,
user
=
user
,
can_edit
=
rr
.
can_edit_user
(
user
),
can_incarnate
=
g
.
user
.
is_admin
,
participants
=
participants
,
participations
=
participations
,
resend_invite_form
=
resend_invite_form
,
)
...
...
This diff is collapsed.
Click to expand it.
mo/web/templates/org_org.html
+
11
−
4
View file @
50ad8bda
...
...
@@ -15,20 +15,27 @@
<tr><td>
Poznámka:
<td
style=
"white-space: pre;"
>
{{ user.note }}
</table>
{% if can_edit %}
<div
class=
"btn-group"
role=
"group"
>
{% if can_edit %}
<a
class=
"btn btn-primary"
href=
"{{ url_for('org_org_edit', id=user.user_id) }}"
>
Editovat
</a>
{% endif %}
{% if resend_invite_form %}
<form
method=
POST
class=
'btn-group'
onsubmit=
'return confirm("Poslat organizátorovi email s odkazem na vytvoření hesla?");'
>
{{ resend_invite_form.csrf_token }}
<button
class=
"btn btn-default"
type=
'submit'
name=
'resend_invite'
>
{% if user.last_login_at %}Resetovat heslo{% else %}Znovu poslat zvací email{% endif %}
</button>
</form>
{% endif %}
{% if g.user.is_admin %}
<a
class=
"btn btn-default"
href=
"{{ log_url('user', user.user_id) }}"
>
Historie
</a>
{% endif %}
</div>
{% endif %}
{% if can_incarnate %}
<form
action=
"{{ url_for('incarnate', id=user.user_id) }}"
method=
POST
class=
'btn-group'
>
<button
class=
"btn btn-default"
type=
'Submit'
>
Převtělit se
</button>
</form>
{% endif %}
</div>
{% if user.is_org or user.is_admin %}
<h3>
Role
</h3>
...
...
This diff is collapsed.
Click to expand it.
mo/web/templates/org_user.html
+
12
−
5
View file @
50ad8bda
...
...
@@ -10,25 +10,32 @@
{% if user.is_admin %}
<tr><td>
Správce:
<td>
ano{% endif %}
{% if user.is_org %}
<tr><td>
Organizátor:
<td>
ano{% endif %}
<tr><td>
Účet založen:
<td>
{{ user.created_at|timeformat }}
<tr><td>
Poslední přihlášení:
<td>
{{ user.last_login_at|timeformat }}
<tr><td>
Poslední přihlášení:
{% if user.last_login_at %}
<td>
{{ user.last_login_at|timeformat }}
{% else %}
<td
class=
"error"
><i>
Zatím nepřihlášen
</i>
{% endif %}
{% if user.reset_at %}
<tr><td>
Reset hesla:
<td>
{{ user.reset_at|timeformat }}{% endif %}
<tr><td>
Poznámka:
<td
style=
"white-space: pre;"
>
{{ user.note }}
</table>
{% if can_edit %}
<div
class=
"btn-group"
role=
"group"
>
{% if can_edit %}
<a
class=
"btn btn-primary"
href=
"{{ url_for('org_user_edit', id=user.user_id) }}"
>
Editovat
</a>
{% endif %}
{% if resend_invite_form %}
<form
method=
POST
class=
'btn-group'
onsubmit=
'return confirm("Poslat účastníkovi email s odkazem na vytvoření hesla?");'
>
{{ resend_invite_form.csrf_token }}
<button
class=
"btn btn-default"
type=
'submit'
name=
'resend_invite'
>
{% if user.last_login_at %}Resetovat heslo{% else %}Znovu poslat zvací email{% endif %}
</button>
</form>
{% endif %}
{% if g.user.is_admin %}
<a
class=
"btn btn-default"
href=
"{{ log_url('user', user.user_id) }}"
>
Historie
</a>
{% endif %}
</div>
{% endif %}
{% if can_incarnate %}
<form
action=
"{{ url_for('incarnate', id=user.user_id) }}"
method=
POST
class=
'btn-group'
>
<button
class=
"btn btn-default"
type=
'Submit'
>
Převtělit se
</button>
</form>
{% endif %}
</div>
<h3>
Registrace v ročnících
</h3>
{% if participants.count() %}
...
...
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