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
f2c19a28
Commit
f2c19a28
authored
3 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
parse_points na None vrátí také None
Může nastat při vyplňování bodů do formulářů.
parent
8f87d0a9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/util.py
+3
-3
3 additions, 3 deletions
mo/util.py
with
3 additions
and
3 deletions
mo/util.py
+
3
−
3
View file @
f2c19a28
...
@@ -136,16 +136,16 @@ def normalize_grade(grade: str) -> int:
...
@@ -136,16 +136,16 @@ def normalize_grade(grade: str) -> int:
def
parse_points
(
def
parse_points
(
raw_points
:
str
,
for_task
:
Optional
[
db
.
Task
]
=
None
,
for_round
:
Optional
[
db
.
Round
]
=
None
,
raw_points
:
Optional
[
str
]
,
for_task
:
Optional
[
db
.
Task
]
=
None
,
for_round
:
Optional
[
db
.
Round
]
=
None
,
)
->
Tuple
[
Optional
[
decimal
.
Decimal
],
Optional
[
str
]]:
)
->
Tuple
[
Optional
[
decimal
.
Decimal
],
Optional
[
str
]]:
"""
Naparsuje a zkontroluje body. Vrátí body (jako decimal.Decimal nebo None
"""
Naparsuje a zkontroluje body. Vrátí body (jako decimal.Decimal nebo None
při prázdných bodech) a případný error (None pokud nenastal, jinak text chyby).
"""
při prázdných bodech) a případný error (None pokud nenastal, jinak text chyby).
"""
if
raw_points
==
""
:
if
not
raw_points
or
raw_points
==
""
:
return
None
,
None
return
None
,
None
try
:
try
:
points
=
decimal
.
Decimal
(
raw_points
.
replace
(
'
,
'
,
'
.
'
))
points
=
decimal
.
Decimal
(
raw_points
.
replace
(
'
,
'
,
'
.
'
))
except
decimal
.
InvalidOperation
:
except
decimal
.
InvalidOperation
:
return
0
,
f
"
Hodnota
'
{
raw_points
}
'
není číslo
"
return
decimal
.
Decimal
(
0
)
,
f
"
Hodnota
'
{
raw_points
}
'
není číslo
"
return
points
,
check_points
(
points
,
for_task
,
for_round
)
return
points
,
check_points
(
points
,
for_task
,
for_round
)
...
...
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