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
2ef024f7
Commit
2ef024f7
authored
3 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Přidán formulář na editaci registrace do ročníku
Closes
#96
parent
f416e750
No related branches found
No related tags found
1 merge request
!90
Formulářová políčka; Přidání účastníka do soutěže; Editace registrace do ročníku
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
mo/web/org_users.py
+45
-0
45 additions, 0 deletions
mo/web/org_users.py
mo/web/templates/org_user.html
+2
-1
2 additions, 1 deletion
mo/web/templates/org_user.html
mo/web/templates/org_user_participant_edit.html
+8
-0
8 additions, 0 deletions
mo/web/templates/org_user_participant_edit.html
with
55 additions
and
1 deletion
mo/web/org_users.py
+
45
−
0
View file @
2ef024f7
...
...
@@ -17,6 +17,7 @@ from mo.rights import Right
import
mo.util
import
mo.users
from
mo.web
import
app
import
mo.web.fields
as
mo_fields
from
mo.web.util
import
PagerForm
...
...
@@ -485,3 +486,47 @@ def org_user_new():
if
not
is_duplicate_name
:
del
form
.
allow_duplicate_name
return
render_template
(
'
org_user_new.html
'
,
form
=
form
,
is_org
=
is_org
)
class
ParticipantEditForm
(
FlaskForm
):
school
=
mo_fields
.
School
(
"
Škola
"
,
validators
=
[
Required
()],
render_kw
=
{
'
autofocus
'
:
True
})
grade
=
mo_fields
.
Grade
(
"
Třída
"
,
validators
=
[
Required
()])
birth_year
=
mo_fields
.
BirthYear
(
"
Rok narození
"
,
validators
=
[
Required
()])
submit
=
wtforms
.
SubmitField
(
"
Uložit
"
)
@app.route
(
'
/org/user/<int:user_id>/participant/<int:year>/edit
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_user_participant_edit
(
user_id
:
int
,
year
:
int
):
sess
=
db
.
get_session
()
user
=
mo
.
users
.
user_by_uid
(
user_id
)
if
not
user
:
raise
werkzeug
.
exceptions
.
NotFound
()
rr
=
g
.
gatekeeper
.
rights_generic
()
if
not
rr
.
can_edit_user
(
user
):
raise
werkzeug
.
exceptions
.
Forbidden
()
participant
=
sess
.
query
(
db
.
Participant
).
filter_by
(
user_id
=
user
.
user_id
).
filter_by
(
year
=
year
).
one_or_none
()
if
participant
is
None
:
raise
werkzeug
.
exceptions
.
NotFound
()
form
=
ParticipantEditForm
(
obj
=
participant
)
if
form
.
validate_on_submit
():
form
.
populate_obj
(
participant
)
if
sess
.
is_modified
(
participant
):
changes
=
db
.
get_object_changes
(
participant
)
app
.
logger
.
info
(
f
"
Participant id
{
id
}
year
{
year
}
modified, changes:
{
changes
}
"
)
mo
.
util
.
log
(
type
=
db
.
LogType
.
participant
,
what
=
user_id
,
details
=
{
'
action
'
:
'
edit-participant
'
,
'
year
'
:
year
,
'
changes
'
:
changes
},
)
sess
.
commit
()
flash
(
'
Změny registrace uloženy
'
,
'
success
'
)
else
:
flash
(
'
Žádné změny k uložení
'
,
'
info
'
)
return
redirect
(
url_for
(
'
org_user
'
,
id
=
user_id
))
return
render_template
(
'
org_user_participant_edit.html
'
,
user
=
user
,
year
=
year
,
form
=
form
)
This diff is collapsed.
Click to expand it.
mo/web/templates/org_user.html
+
2
−
1
View file @
2ef024f7
...
...
@@ -43,7 +43,7 @@
<table
class=
"data full"
>
<thead>
<tr>
<th>
Ročník
<th>
Škola
<th>
Třída
<th>
Rok narození
<th>
Ročník
<th>
Škola
<th>
Třída
<th>
Rok narození
<th>
Akce
</tr>
</thead>
{% for participant in participants %}
...
...
@@ -52,6 +52,7 @@
<td><a
href=
"{{ url_for('org_place', id=participant.school) }}"
>
{{ participant.school_place.name }}
</a>
<td>
{{ participant.grade }}
<td>
{{ participant.birth_year }}
<td><a
class=
"btn btn-xs btn-primary"
href=
"{{ url_for('org_user_participant_edit', user_id=user.user_id, year=participant.year) }}"
>
Editovat
</a>
</tr>
{% endfor %}
</table>
...
...
This diff is collapsed.
Click to expand it.
mo/web/templates/org_user_participant_edit.html
0 → 100644
+
8
−
0
View file @
2ef024f7
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}Editace registrace soutěžícího {{ user.full_name() }} v {{ year }}. ročníku{% endblock %}
{% block body %}
{{ wtf.quick_form(form, form_type='horizontal', button_map={'submit': 'primary'}) }}
{% endblock %}
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