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
93895747
Verified
Commit
93895747
authored
Apr 15, 2019
by
Peter Stanko
Browse files
Fix when course state is None
parent
5ece2f58
Pipeline
#31395
passed with stage
in 7 minutes and 26 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
portal/service/resource_definition.py
View file @
93895747
import
logging
from
datetime
import
datetime
from
typing
import
Dict
,
List
import
marshmallow
from
portal.database
import
Course
,
Group
,
Project
,
Role
from
portal.database.enums
import
CourseState
from
portal.service.general
import
GeneralService
log
=
logging
.
getLogger
(
__name__
)
class
ResourceDefinitionService
(
GeneralService
):
def
sync_course
(
self
,
definition
:
Dict
,
save
:
bool
=
True
):
...
...
@@ -17,7 +21,11 @@ class ResourceDefinitionService(GeneralService):
"""
definition
=
definition
.
get
(
'course'
)
or
definition
if
'state'
in
definition
:
try
:
definition
[
'state'
]
=
CourseState
(
definition
[
'state'
])
except
Exception
as
ex
:
log
.
error
(
f
"State error:
{
ex
}
"
)
course
=
self
.
_get_course
(
definition
[
'codename'
])
params
=
self
.
_course_params
...
...
@@ -129,7 +137,7 @@ class ResourceDefinitionService(GeneralService):
Returns(Dict): Course dump
"""
schema
=
_extract_params
(
course
,
self
.
_course_params
)
schema
[
'state'
]
=
course
.
state
.
value
schema
[
'state'
]
=
course
.
state
.
value
if
course
.
state
else
None
schema
[
'projects'
]
=
[
self
.
dump_project
(
project
)
for
project
in
course
.
projects
]
schema
[
'roles'
]
=
[
self
.
dump_role
(
role
,
with_clients
=
with_users
)
for
role
in
course
.
roles
]
schema
[
'groups'
]
=
[
...
...
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