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
c97d2d48
Commit
c97d2d48
authored
3 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
UsersFilterForm nepouživá f_
parent
41b61102
No related branches found
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_users.py
+18
-57
18 additions, 57 deletions
mo/web/org_users.py
with
18 additions
and
57 deletions
mo/web/org_users.py
+
18
−
57
View file @
c97d2d48
...
...
@@ -41,50 +41,11 @@ class UsersFilterForm(PagerForm):
submit
=
wtforms
.
SubmitField
(
"
Filtrovat
"
)
# Výstupní hodnoty filtru, None při nepoužitém filtru, prázdná db hodnota při
# nepovedené filtraci (neexistující místo a podobně)
f_search_name
:
Optional
[
str
]
=
None
f_search_email
:
Optional
[
str
]
=
None
f_year
:
Optional
[
int
]
=
None
f_school
:
Optional
[
db
.
Place
]
=
None
f_round_year
:
Optional
[
int
]
=
None
f_round_category
:
Optional
[
str
]
=
None
f_round_seq
:
Optional
[
int
]
=
None
f_contest_site
:
Optional
[
db
.
Place
]
=
None
f_participation_state
:
Optional
[
db
.
PartState
]
=
None
def
__init__
(
self
,
**
kwargs
):
super
().
__init__
(
**
kwargs
)
self
.
round_category
.
choices
=
[
'
*
'
]
+
sorted
(
db
.
get_categories
())
self
.
round_seq
.
choices
=
[
'
*
'
]
+
sorted
(
db
.
get_seqs
())
def
validate_search_name
(
self
,
field
):
self
.
f_search_name
=
f
"
%
{
field
.
data
}
%
"
def
validate_search_email
(
self
,
field
):
self
.
f_search_email
=
f
"
%
{
field
.
data
}
%
"
def
validate_year
(
self
,
field
):
self
.
f_year
=
field
.
data
def
validate_round_year
(
self
,
field
):
self
.
f_round_year
=
field
.
data
def
validate_school
(
self
,
field
):
self
.
f_school
=
field
.
place
def
validate_contest_site
(
self
,
field
):
self
.
f_contest_site
=
field
.
place
def
validate_round_category
(
self
,
field
):
self
.
f_round_category
=
None
if
field
.
data
==
'
*
'
else
field
.
data
def
validate_round_seq
(
self
,
field
):
self
.
f_round_seq
=
None
if
field
.
data
==
'
*
'
else
field
.
data
def
validate_participation_state
(
self
,
field
):
self
.
f_participation_state
=
None
if
field
.
data
==
'
*
'
else
field
.
data
@app.route
(
'
/org/user/
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_users
():
...
...
@@ -98,29 +59,29 @@ def org_users():
if
request
.
args
:
filter
.
validate
()
if
filter
.
f_
search_name
:
if
filter
.
search_name
.
data
:
q
=
q
.
filter
(
or_
(
db
.
User
.
first_name
.
ilike
(
filter
.
f_
search_name
),
db
.
User
.
last_name
.
ilike
(
filter
.
f_
search_name
)
db
.
User
.
first_name
.
ilike
(
f
"
%
{
filter
.
search_name
.
data
}
%
"
),
db
.
User
.
last_name
.
ilike
(
f
"
%
{
filter
.
search_name
.
data
}
%
"
)
))
if
filter
.
f_
search_email
:
q
=
q
.
filter
(
db
.
User
.
email
.
ilike
(
filter
.
f_
search_email
))
if
filter
.
search_email
.
data
:
q
=
q
.
filter
(
db
.
User
.
email
.
ilike
(
f
"
%
{
filter
.
search_email
.
data
}
%
"
))
if
filter
.
f_
year
or
filter
.
f_
school
:
if
filter
.
year
.
data
or
filter
.
school
.
place
:
participant_filter
=
sess
.
query
(
db
.
Participant
.
user_id
)
if
filter
.
f_
year
:
participant_filter
=
participant_filter
.
filter_by
(
year
=
filter
.
f_
year
)
if
filter
.
f_
school
:
participant_filter
=
participant_filter
.
filter_by
(
school
=
filter
.
f_
school
.
place_id
)
if
filter
.
year
.
data
:
participant_filter
=
participant_filter
.
filter_by
(
year
=
filter
.
year
.
data
)
if
filter
.
school
.
place
:
participant_filter
=
participant_filter
.
filter_by
(
school
=
filter
.
school
.
place
.
place
_id
)
q
=
q
.
filter
(
db
.
User
.
user_id
.
in_
(
participant_filter
))
round_filter
=
sess
.
query
(
db
.
Round
.
round_id
)
round_filter_apply
=
False
if
filter
.
f_
round_year
:
round_filter
=
round_filter
.
filter_by
(
year
=
filter
.
f_
round_year
)
if
filter
.
round_year
.
data
:
round_filter
=
round_filter
.
filter_by
(
year
=
filter
.
round_year
.
data
)
round_filter_apply
=
True
if
filter
.
f_
round_category
:
round_filter
=
round_filter
.
filter_by
(
category
=
filter
.
f_
round_category
)
if
filter
.
round_category
.
data
and
filter
.
round_category
.
data
!=
"
*
"
:
round_filter
=
round_filter
.
filter_by
(
category
=
filter
.
round_category
.
data
)
round_filter_apply
=
True
if
filter
.
round_seq
.
data
and
filter
.
round_seq
.
data
!=
"
*
"
:
round_filter
=
round_filter
.
filter_by
(
seq
=
filter
.
round_seq
.
data
)
...
...
@@ -131,8 +92,8 @@ def org_users():
if
round_filter_apply
:
contest_filter
=
contest_filter
.
filter
(
db
.
Contest
.
round_id
.
in_
(
round_filter
))
contest_filter_apply
=
True
if
filter
.
f_
contest_site
:
contest_filter
=
contest_filter
.
filter_by
(
place_id
=
filter
.
f_
contest_site
.
place_id
)
if
filter
.
contest_site
.
place
:
contest_filter
=
contest_filter
.
filter_by
(
place_id
=
filter
.
contest_site
.
place
.
place
_id
)
contest_filter_apply
=
True
participation_filter
=
sess
.
query
(
db
.
Participation
.
user_id
)
...
...
@@ -140,8 +101,8 @@ def org_users():
if
contest_filter_apply
:
participation_filter
=
participation_filter
.
filter
(
db
.
Participation
.
contest_id
.
in_
(
contest_filter
))
participation_filter_apply
=
True
if
filter
.
f_
participation_state
:
participation_filter
=
participation_filter
.
filter_by
(
state
=
filter
.
f_
participation_state
)
if
filter
.
participation_state
.
data
and
filter
.
participation_state
.
data
!=
'
*
'
:
participation_filter
=
participation_filter
.
filter_by
(
state
=
filter
.
participation_state
.
data
)
participation_filter_apply
=
True
if
participation_filter_apply
:
...
...
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