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
8f26714f
Verified
Commit
8f26714f
authored
Oct 14, 2018
by
Peter Stanko
Browse files
SubmissionDifftime better message
parent
e2ac8aae
Changes
3
Hide whitespace changes
Inline
Side-by-side
portal/logger.py
View file @
8f26714f
...
...
@@ -54,7 +54,6 @@ LOGGERS = {
'management'
:
{
'handlers'
:
[
'console'
],
'level'
:
'INFO'
,
'propagate'
:
True
},
'app'
:
{
'handlers'
:
[
'console'
],
'level'
:
'DEBUG'
,
'propagate'
:
True
},
'flask'
:
{
'handlers'
:
[
'console'
,
'flask_file'
],
'level'
:
'DEBUG'
,
'propagate'
:
True
},
'flask_cors'
:
{
'handlers'
:
[
'console'
],
'level'
:
'DEBUG'
,
'propagate'
:
True
},
'werkzeug'
:
{
'handlers'
:
[
'console'
],
'level'
:
'DEBUG'
,
'propagate'
:
True
},
'storage'
:
{
'handlers'
:
[
'console'
,
'storage_file'
],
'level'
:
'INFO'
,
'propagate'
:
True
},
}
...
...
portal/service/errors.py
View file @
8f26714f
...
...
@@ -5,6 +5,7 @@ import json
from
typing
import
Union
from
portal.database
import
Project
,
User
from
portal.tools
import
time
class
PortalError
(
Exception
):
...
...
@@ -151,10 +152,20 @@ class WorkerNotAvailable(PortalError):
class
SubmissionDiffTimeError
(
PortalAPIError
):
def
__init__
(
self
,
project
:
Project
,
diff_time
,
user
:
User
=
None
):
log_user
=
f
'by
{
user
.
log_name
}
'
if
user
else
''
when
=
time
.
current_time
()
+
diff_time
message
=
f
"Submission cannot be created for
{
project
.
log_name
}
,
{
log_user
}
"
\
f
"you can create submission in
{
diff_time
}
."
f
"you can create submission in
{
diff_time
}
(when)."
full_message
=
{
'text'
:
message
,
'log_user'
:
log_user
,
'project'
:
project
.
codename
,
'course'
:
project
.
course
.
codename
,
'author'
:
user
.
username
,
'diff_time'
:
str
(
diff_time
),
'when'
:
when
.
strftime
(
time
.
DEFAULT_FORMAT
)
}
super
().
__init__
(
code
=
429
,
message
=
message
)
super
().
__init__
(
code
=
429
,
message
=
full_
message
)
class
SuiteStatsNotExists
(
PortalError
):
...
...
@@ -165,4 +176,4 @@ class SuiteStatsNotExists(PortalError):
class
ResultsAreNotUploaded
(
PortalAPIError
):
def
__init__
(
self
,
submission
):
message
=
f
"Submission
{
submission
.
log_name
}
results are not ready."
super
().
__init__
(
code
=
404
,
message
=
message
)
\ No newline at end of file
super
().
__init__
(
code
=
404
,
message
=
message
)
portal/tools/time.py
View file @
8f26714f
...
...
@@ -13,6 +13,8 @@ UTC = pytz.UTC
portal_timezone
=
pytz
.
timezone
(
'Europe/Prague'
)
DEFAULT_FORMAT
=
"%d-%m-%Y %H:%M:%S."
def
current_time
()
->
datetime
:
return
datetime
.
datetime
.
now
(
tz
=
portal_timezone
)
...
...
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