Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Portal API Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kontr 2.0
Portal API Backend
Commits
434dddac
There was an error fetching the commit references. Please try again later.
Verified
Commit
434dddac
authored
6 years ago
by
Peter Stanko
Browse files
Options
Downloads
Patches
Plain Diff
Submissions cancelation
parent
47526e8d
No related branches found
No related tags found
1 merge request
!10
Submissions cancellation support
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app.py
+21
-1
21 additions, 1 deletion
app.py
management/data/__init__.py
+22
-2
22 additions, 2 deletions
management/data/__init__.py
with
43 additions
and
3 deletions
app.py
+
21
−
1
View file @
434dddac
...
@@ -3,8 +3,9 @@ Main application module
...
@@ -3,8 +3,9 @@ Main application module
- Creates instance of the flask app named app
- Creates instance of the flask app named app
- registers commands
- registers commands
"""
"""
import
click
import
logging
as
logger
import
logging
as
logger
import
click
from
flask
import
Flask
from
flask
import
Flask
from
flask.cli
import
AppGroup
,
run_command
from
flask.cli
import
AppGroup
,
run_command
...
@@ -145,5 +146,24 @@ def cli_projects_list(course):
...
@@ -145,5 +146,24 @@ def cli_projects_list(course):
manager
.
list_projects
(
course
)
manager
.
list_projects
(
course
)
@submissions_cli.command
(
'
cancel-all
'
,
help
=
"
Cancel all submissions
"
)
def
cli_submissions_cancel_all
():
log
.
info
(
f
"
[CMD] Cancelling all submissions
"
)
manager
.
cancel_all_submissions
()
@submissions_cli.command
(
'
cancel
'
,
help
=
"
Cancel submission
"
)
@click.argument
(
'
sid
'
)
def
cli_submissions_cancel
(
sid
):
log
.
info
(
f
"
[CMD] Cancelling all submissions
"
)
manager
.
cancel_submission
(
sid
)
@submissions_cli.command
(
'
list
'
,
help
=
"
List all submissions
"
)
def
cli_submissions_cancel_all
():
log
.
info
(
f
"
[CMD] List all submissions
"
)
manager
.
list_all_submissions
()
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
cli_run_devel
()
cli_run_devel
()
This diff is collapsed.
Click to expand it.
management/data/__init__.py
+
22
−
2
View file @
434dddac
...
@@ -6,7 +6,7 @@ from management.data import shared
...
@@ -6,7 +6,7 @@ from management.data import shared
from
management.data.data_test
import
init_test_data
from
management.data.data_test
import
init_test_data
from
management.data.data_dev
import
init_dev_data
from
management.data.data_dev
import
init_dev_data
from
management.data.data_prod
import
init_prod_data
from
management.data.data_prod
import
init_prod_data
from
portal.database.models
import
Course
,
Role
,
User
from
portal.database.models
import
Course
,
Role
,
User
,
Submission
,
SubmissionState
from
portal.service
import
general
from
portal.service
import
general
from
portal.service.general
import
write_entity
from
portal.service.general
import
write_entity
from
portal.tools
import
time
from
portal.tools
import
time
...
@@ -121,7 +121,6 @@ class DataManagement(object):
...
@@ -121,7 +121,6 @@ class DataManagement(object):
project
.
config
.
archive_from
=
None
project
.
config
.
archive_from
=
None
project
.
config
.
submissions_allowed_to
=
days_allow_to
project
.
config
.
submissions_allowed_to
=
days_allow_to
write_entity
(
project
)
write_entity
(
project
)
self
.
db
.
session
.
commit
()
return
project
return
project
def
list_projects
(
self
,
course
:
str
):
def
list_projects
(
self
,
course
:
str
):
...
@@ -134,3 +133,24 @@ class DataManagement(object):
...
@@ -134,3 +133,24 @@ class DataManagement(object):
with
self
.
app
.
app_context
():
with
self
.
app
.
app_context
():
for
course
in
Course
.
query
.
all
():
for
course
in
Course
.
query
.
all
():
print
(
f
"
{
course
.
codename
}
:
{
course
.
name
}
"
)
print
(
f
"
{
course
.
codename
}
:
{
course
.
name
}
"
)
def
list_all_submissions
(
self
):
with
self
.
app
.
app_context
():
for
submission
in
Submission
.
query
.
all
():
print
(
f
"
{
submission
.
id
}
[
{
submission
.
state
}
]:
{
submission
.
user
.
username
}
"
)
def
cancel_all_submissions
(
self
):
with
self
.
app
.
app_context
():
for
submission
in
Submission
.
query
.
all
():
submission
.
change_state
(
SubmissionState
.
CANCELLED
)
write_entity
(
submission
)
self
.
db
.
session
.
commit
()
def
cancel_submission
(
self
,
sid
):
with
self
.
app
.
app_context
():
submission
=
general
.
find_submission
(
sid
)
submission
.
change_state
(
SubmissionState
.
CANCELLED
)
write_entity
(
submission
)
self
.
db
.
session
.
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
register
or
sign in
to comment