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
2c7efac2
Commit
2c7efac2
authored
3 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Přesunutí mo.web.org_round.MODateTimeField na mo.web.fields.DateTime
parent
068d4f37
No related branches found
No related tags found
1 merge request
!92
Používání mo.web.fields
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/web/fields.py
+15
-0
15 additions, 0 deletions
mo/web/fields.py
mo/web/org_round.py
+4
-20
4 additions, 20 deletions
mo/web/org_round.py
with
19 additions
and
20 deletions
mo/web/fields.py
+
15
−
0
View file @
2c7efac2
...
@@ -186,3 +186,18 @@ class RepeatPassword(wtforms.PasswordField):
...
@@ -186,3 +186,18 @@ class RepeatPassword(wtforms.PasswordField):
def
pre_validate
(
field
,
form
):
def
pre_validate
(
field
,
form
):
if
field
.
data
!=
form
.
new_passwd
.
data
:
if
field
.
data
!=
form
.
new_passwd
.
data
:
raise
wtforms
.
ValidationError
(
'
Hesla se neshodují.
'
)
raise
wtforms
.
ValidationError
(
'
Hesla se neshodují.
'
)
class
DateTime
(
wtforms
.
DateTimeField
):
def
__init__
(
self
,
label
,
format
=
'
%Y-%m-%d %H:%M
'
,
description
=
'
Ve formátu 2000-01-01 12:34
'
,
**
kwargs
):
super
().
__init__
(
label
,
format
=
format
,
description
=
description
,
**
kwargs
)
def
process_data
(
self
,
valuelist
):
super
().
process_data
(
valuelist
)
if
self
.
data
is
not
None
:
self
.
data
=
self
.
data
.
astimezone
()
def
process_formdata
(
self
,
valuelist
):
super
().
process_formdata
(
valuelist
)
if
self
.
data
is
not
None
:
self
.
data
=
self
.
data
.
astimezone
()
This diff is collapsed.
Click to expand it.
mo/web/org_round.py
+
4
−
20
View file @
2c7efac2
...
@@ -419,22 +419,6 @@ def org_round_import(id: int):
...
@@ -419,22 +419,6 @@ def org_round_import(id: int):
return
generic_import
(
round
,
master_round
,
None
,
None
)
return
generic_import
(
round
,
master_round
,
None
,
None
)
class
MODateTimeField
(
wtforms
.
DateTimeField
):
def
__init__
(
self
,
label
,
format
=
'
%Y-%m-%d %H:%M
'
,
description
=
'
Ve formátu 2000-01-01 12:34
'
,
**
kwargs
):
super
().
__init__
(
label
,
format
=
format
,
description
=
description
,
**
kwargs
)
def
process_data
(
self
,
valuelist
):
super
().
process_data
(
valuelist
)
if
self
.
data
is
not
None
:
self
.
data
=
self
.
data
.
astimezone
()
def
process_formdata
(
self
,
valuelist
):
super
().
process_formdata
(
valuelist
)
if
self
.
data
is
not
None
:
self
.
data
=
self
.
data
.
astimezone
()
class
RoundEditForm
(
FlaskForm
):
class
RoundEditForm
(
FlaskForm
):
_for_round
:
Optional
[
db
.
Round
]
=
None
_for_round
:
Optional
[
db
.
Round
]
=
None
...
@@ -445,10 +429,10 @@ class RoundEditForm(FlaskForm):
...
@@ -445,10 +429,10 @@ class RoundEditForm(FlaskForm):
)
)
# Only the desktop Firefox does not support datetime-local field nowadays,
# Only the desktop Firefox does not support datetime-local field nowadays,
# other browsers does provide date and time picker UI :(
# other browsers does provide date and time picker UI :(
ct_tasks_start
=
MO
DateTime
Field
(
"
Čas zveřejnění úloh pro účastníky
"
,
validators
=
[
validators
.
Optional
()])
ct_tasks_start
=
mo_fields
.
DateTime
(
"
Čas zveřejnění úloh pro účastníky
"
,
validators
=
[
validators
.
Optional
()])
pr_tasks_start
=
MO
DateTime
Field
(
"
Čas zveřejnění úloh pro dozor
"
,
validators
=
[
validators
.
Optional
()])
pr_tasks_start
=
mo_fields
.
DateTime
(
"
Čas zveřejnění úloh pro dozor
"
,
validators
=
[
validators
.
Optional
()])
ct_submit_end
=
MO
DateTime
Field
(
"
Konec odevzdávání pro účastníky
"
,
validators
=
[
validators
.
Optional
()])
ct_submit_end
=
mo_fields
.
DateTime
(
"
Konec odevzdávání pro účastníky
"
,
validators
=
[
validators
.
Optional
()])
pr_submit_end
=
MO
DateTime
Field
(
"
Konec odevzdávání pro dozor
"
,
validators
=
[
validators
.
Optional
()])
pr_submit_end
=
mo_fields
.
DateTime
(
"
Konec odevzdávání pro dozor
"
,
validators
=
[
validators
.
Optional
()])
score_mode
=
wtforms
.
SelectField
(
"
Výsledková listina
"
,
choices
=
db
.
RoundScoreMode
.
choices
(),
coerce
=
db
.
RoundScoreMode
.
coerce
)
score_mode
=
wtforms
.
SelectField
(
"
Výsledková listina
"
,
choices
=
db
.
RoundScoreMode
.
choices
(),
coerce
=
db
.
RoundScoreMode
.
coerce
)
score_winner_limit
=
mo_fields
.
Points
(
score_winner_limit
=
mo_fields
.
Points
(
"
Hranice bodů pro vítěze
"
,
validators
=
[
validators
.
Optional
(),
validators
.
NumberRange
(
min
=
0
)],
"
Hranice bodů pro vítěze
"
,
validators
=
[
validators
.
Optional
(),
validators
.
NumberRange
(
min
=
0
)],
...
...
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