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
MO-P
Odevzdávací Systém MO
Commits
cc06abe8
Project 'mj/mo-submit' was moved to 'mo-p/osmo'. Please update any links and bookmarks that may still have the old path.
Commit
cc06abe8
authored
Jul 31, 2021
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Fields: PlaceMoveForm
parent
6128e5f5
Branches
Branches containing commit
No related tags found
1 merge request
!92
Používání mo.web.fields
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/web/org_place.py
+37
-34
37 additions, 34 deletions
mo/web/org_place.py
with
37 additions
and
34 deletions
mo/web/org_place.py
+
37
−
34
View file @
cc06abe8
...
...
@@ -13,6 +13,7 @@ import mo.imports
import
mo.rights
import
mo.util
from
mo.web
import
app
import
mo.web.fields
as
mo_fields
import
wtforms.validators
as
validators
...
...
@@ -177,14 +178,14 @@ def org_place_edit(id: int):
class
PlaceMoveForm
(
FlaskForm
):
code
=
wtforms
.
StringField
(
validators
=
[
validators
.
DataRequired
()],
render_kw
=
{
'
autofocus
'
:
True
})
new_parent
=
mo_fields
.
Place
(
validators
=
[
validators
.
DataRequired
()],
render_kw
=
{
'
autofocus
'
:
True
})
submit
=
wtforms
.
SubmitField
(
'
Najít místo
'
)
reset
=
wtforms
.
HiddenField
()
move
=
wtforms
.
HiddenField
()
class
PlaceMoveConfirmForm
(
FlaskForm
):
code
=
wtforms
.
Hidden
Field
()
new_parent
=
mo_fields
.
Place
(
widget
=
wtforms
.
widgets
.
Hidden
Input
()
)
reset
=
wtforms
.
SubmitField
(
'
Zrušit
'
)
move
=
wtforms
.
SubmitField
(
'
Přesunout
'
)
...
...
@@ -206,14 +207,14 @@ def org_place_move(id: int):
form
=
PlaceMoveForm
()
form_confirm
=
None
if
form
.
validate_on_submit
():
if
not
form
.
validate_on_submit
():
if
form
.
new_parent
.
place_error
:
search_error
=
form
.
new_parent
.
place_error
else
:
if
form
.
reset
.
data
:
return
redirect
(
url_for
(
'
org_place_move
'
,
id
=
id
))
new_parent
=
db
.
get_place_by_code
(
form
.
code
.
data
)
if
not
new_parent
:
search_error
=
'
Místo s tímto kódem se nepovedlo nalézt
'
else
:
new_parent
=
form
.
new_parent
.
place
new_parents
=
reversed
(
g
.
gatekeeper
.
get_parents
(
new_parent
))
(
_
,
levels
)
=
db
.
place_type_names_and_levels
[
place
.
type
]
...
...
@@ -241,7 +242,9 @@ def org_place_move(id: int):
else
:
# OK but not confirmed yet, display the confirm form
form_confirm
=
PlaceMoveConfirmForm
()
form_confirm
.
code
.
data
=
form
.
code
.
data
form_confirm
.
new_parent
.
data
=
form
.
new_parent
.
data
# tady se používá hnusný trik, že políčko new_parents z PlaceMoveConfirmForm se
# parsuje jako new_parents z PlaceMoveForm
return
render_template
(
'
org_place_move.html
'
,
...
...
...
...
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
sign in
to comment