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
a3af5b3e
Commit
a3af5b3e
authored
3 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Db: find_round
parent
a3558a99
No related branches found
No related tags found
1 merge request
!97
Import orgů
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/db.py
+24
-1
24 additions, 1 deletion
mo/db.py
with
24 additions
and
1 deletion
mo/db.py
+
24
−
1
View file @
a3af5b3e
...
...
@@ -9,7 +9,7 @@ import re
from
sqlalchemy
import
\
Boolean
,
Column
,
DateTime
,
ForeignKey
,
Integer
,
String
,
Text
,
UniqueConstraint
,
\
text
,
func
,
\
create_engine
,
inspect
,
select
create_engine
,
inspect
,
select
,
or_
,
and_
from
sqlalchemy.engine
import
Engine
from
sqlalchemy.orm
import
relationship
,
sessionmaker
,
Session
,
class_mapper
,
joinedload
,
aliased
from
sqlalchemy.orm.attributes
import
get_history
...
...
@@ -318,6 +318,29 @@ class Round(Base):
return
"
"
.
join
(
times
)
def
find_round
(
year
:
Optional
[
int
],
category
:
Optional
[
str
],
code
:
str
)
->
Round
:
if
not
year
:
raise
mo
.
CheckError
(
'
Neuveden ročník pro nalezení kola
'
)
if
not
category
:
raise
mo
.
CheckError
(
'
Neuvedena kategorie pro nalezení kola
'
)
try
:
seq
:
Optional
[
int
]
=
int
(
code
)
except
ValueError
:
seq
=
None
r
=
(
get_session
().
query
(
Round
)
.
filter_by
(
year
=
year
,
category
=
category
)
.
filter
(
or_
(
Round
.
code
==
code
,
and_
(
Round
.
code
==
""
,
Round
.
seq
==
seq
if
seq
else
False
)))
.
all
()
)
if
len
(
r
)
<
1
:
raise
mo
.
CheckError
(
f
'
Kolo
{
year
}
-
{
category
}
-
{
seq
}
nenalezeno
'
)
if
len
(
r
)
>
1
:
raise
mo
.
CheckError
(
f
'
Kolo
{
year
}
-
{
category
}
-
{
seq
}
nelze určit jednoznačně
'
)
return
r
[
0
]
class
User
(
Base
):
__tablename__
=
'
users
'
...
...
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