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
889e7469
Project 'mj/mo-submit' was moved to 'mo-p/osmo'. Please update any links and bookmarks that may still have the old path.
Commit
889e7469
authored
Jan 11, 2023
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Skript na mazání submitů
parent
02769733
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
bin/delete-submits
+57
-0
57 additions, 0 deletions
bin/delete-submits
with
57 additions
and
0 deletions
bin/delete-submits
0 → 100755
+
57
−
0
View file @
889e7469
#!/usr/bin/env python3
import
argparse
import
mo.config
as
config
import
mo.db
as
db
from
mo.util
import
init_standalone
,
die
,
log
parser
=
argparse
.
ArgumentParser
(
description
=
'
Smaže všechny submity uživatele v aktuálním ročníku
'
)
parser
.
add_argument
(
'
--uid
'
,
type
=
int
,
required
=
True
,
help
=
'
user_id
'
)
parser
.
add_argument
(
'
-n
'
,
'
--dry-run
'
,
default
=
False
,
action
=
'
store_true
'
,
help
=
'
mazání jenom simuluje
'
)
args
=
parser
.
parse_args
()
action
=
"
Smažu
"
if
args
.
dry_run
else
"
Mažu
"
init_standalone
()
sess
=
db
.
get_session
()
user
=
sess
.
query
(
db
.
User
).
get
(
args
.
uid
)
if
user
is
None
:
die
(
f
'
Uživatel s UID
{
args
.
uid
}
neexistuje
'
)
print
(
f
'
{
action
}
odevzdaná řešení uživatele
{
user
.
full_name
()
}
<
{
user
.
email
}
>
'
)
task_subq
=
(
sess
.
query
(
db
.
Task
.
task_id
)
.
join
(
db
.
Round
)
.
filter
(
db
.
Round
.
year
==
config
.
CURRENT_YEAR
))
sols
=
(
sess
.
query
(
db
.
Solution
)
.
filter_by
(
user
=
user
)
.
filter
(
db
.
Solution
.
task_id
.
in_
(
task_subq
))
.
all
())
for
sol
in
sols
:
print
(
f
'
{
action
}
řešení úlohy #
{
sol
.
task_id
}
{
sol
.
task
.
code
}
(
{
sol
.
task
.
name
}
)
'
)
sess
.
delete
(
sol
)
papers
=
(
sess
.
query
(
db
.
Paper
)
.
filter_by
(
for_user_obj
=
user
)
.
filter
(
db
.
Paper
.
for_task
.
in_
(
task_subq
))
.
all
())
for
paper
in
papers
:
print
(
f
'
{
action
}
papír #
{
paper
.
paper_id
}
(úloha #
{
paper
.
for_task
}
, odevzdáno
{
paper
.
uploaded_at
}
)
'
)
sess
.
delete
(
paper
)
log
(
type
=
db
.
LogType
.
participant
,
what
=
user
.
user_id
,
details
=
{
'
action
'
:
'
delete-submits
'
,
'
reason
'
:
'
script
'
,
},
)
if
not
args
.
dry_run
:
sess
.
commit
()
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