Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Kontr 2.0
Portal API Backend
Commits
4525b390
Verified
Commit
4525b390
authored
Oct 12, 2018
by
Peter Stanko
Browse files
Ignore cancelled submission
parent
2e575a98
Changes
2
Hide whitespace changes
Inline
Side-by-side
portal/database/models.py
View file @
4525b390
...
...
@@ -927,6 +927,19 @@ class Submission(db.Model, EntityBase):
# open to extension (state transition validation, ...)
self
.
state
=
new_state
@
property
def
is_cancelled
(
self
)
->
bool
:
return
self
.
state
in
[
SubmissionState
.
CANCELLED
,
SubmissionState
.
ABORTED
]
@
property
def
is_finished
(
self
)
->
bool
:
return
self
.
state
in
[
SubmissionState
.
FINISHED
,
SubmissionState
.
ARCHIVED
]
@
property
def
is_processed
(
self
)
->
bool
:
return
self
.
state
in
[
SubmissionState
.
CREATED
,
SubmissionState
.
QUEUED
,
SubmissionState
.
READY
,
SubmissionState
.
IN_PROGRESS
]
def
__init__
(
self
,
user
:
User
,
project
:
Project
,
parameters
:
dict
=
None
,
review
:
'Review'
=
None
):
"""Creates a new submission instance
...
...
portal/service/projects.py
View file @
4525b390
...
...
@@ -148,7 +148,7 @@ class ProjectService(GeneralService):
return
True
def
_check_latest_submission
(
self
,
user
:
User
):
latest_submission
=
self
.
get_latest_submission
(
user
)
latest_submission
=
self
.
get_latest_submission
(
user
,
ignore_cancel
=
True
)
if
not
latest_submission
:
return
True
latest_time
=
latest_submission
.
created_at
...
...
@@ -165,10 +165,13 @@ class ProjectService(GeneralService):
raise
errors
.
SubmissionDiffTimeError
(
self
.
project
,
diff_time
,
user
=
user
)
return
True
def
get_latest_submission
(
self
,
user
)
->
Submission
:
return
Submission
.
query
.
filter
((
Submission
.
user
==
user
)
&
(
Submission
.
project
==
self
.
project
))
\
.
order_by
(
Submission
.
created_at
.
desc
()).
first
()
def
get_latest_submission
(
self
,
user
,
ignore_cancel
:
bool
=
False
)
->
Submission
:
query
=
Submission
.
query
.
filter
(
(
Submission
.
user
==
user
)
&
(
Submission
.
project
==
self
.
project
))
if
ignore_cancel
:
query
=
query
.
filter
((
Submission
.
state
!=
SubmissionState
.
CANCELLED
)
&
(
SubmissionState
!=
SubmissionState
.
ABORTED
))
return
query
.
order_by
(
Submission
.
created_at
.
desc
()).
first
()
def
find_all
(
self
,
course
:
Course
)
->
list
:
"""List of all projects
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment