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
5ece2f58
Verified
Commit
5ece2f58
authored
Apr 15, 2019
by
Peter Stanko
Browse files
Fixed course state by definition
parent
7b25ecb2
Pipeline
#31394
passed with stage
in 7 minutes and 37 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
portal/database/models.py
View file @
5ece2f58
...
@@ -812,7 +812,7 @@ class Submission(db.Model, EntityBase):
...
@@ -812,7 +812,7 @@ class Submission(db.Model, EntityBase):
project: Associated project for the submission
project: Associated project for the submission
review: Review associated with the submission
review: Review associated with the submission
"""
"""
LISTABLE
=
[
'id'
,
'state'
,
'points'
,
'result'
,
'scheduled_for'
]
LISTABLE
=
[
'id'
,
'state'
,
'points'
,
'result'
,
'scheduled_for'
,
'created_at'
,
'updated_at'
]
BASE_PARAMS
=
[
'parameters'
,
'source_hash'
,
*
LISTABLE
]
BASE_PARAMS
=
[
'parameters'
,
'source_hash'
,
*
LISTABLE
]
__tablename__
=
'submission'
__tablename__
=
'submission'
id
=
db
.
Column
(
db
.
String
(
length
=
36
),
default
=
lambda
:
str
(
id
=
db
.
Column
(
db
.
String
(
length
=
36
),
default
=
lambda
:
str
(
...
...
portal/rest/schemas.py
View file @
5ece2f58
...
@@ -128,7 +128,7 @@ class PasswordChangeSchema(Schema):
...
@@ -128,7 +128,7 @@ class PasswordChangeSchema(Schema):
class
CourseSchema
(
BaseSchema
,
NamedSchema
,
Schema
):
class
CourseSchema
(
BaseSchema
,
NamedSchema
,
Schema
):
"""Course Schema
"""Course Schema
"""
"""
state
=
EnumField
(
CourseState
)
state
=
EnumField
(
CourseState
,
by_value
=
True
)
roles
=
NESTED
[
'roles'
]
roles
=
NESTED
[
'roles'
]
groups
=
NESTED
[
'groups'
]
groups
=
NESTED
[
'groups'
]
projects
=
NESTED
[
'projects'
]
projects
=
NESTED
[
'projects'
]
...
...
portal/service/resource_definition.py
View file @
5ece2f58
...
@@ -2,7 +2,8 @@ from datetime import datetime
...
@@ -2,7 +2,8 @@ from datetime import datetime
from
typing
import
Dict
,
List
from
typing
import
Dict
,
List
import
marshmallow
import
marshmallow
from
portal.database
import
Course
,
Group
,
Project
,
Role
,
ProjectConfig
from
portal.database
import
Course
,
Group
,
Project
,
Role
from
portal.database.enums
import
CourseState
from
portal.service.general
import
GeneralService
from
portal.service.general
import
GeneralService
...
@@ -15,8 +16,11 @@ class ResourceDefinitionService(GeneralService):
...
@@ -15,8 +16,11 @@ class ResourceDefinitionService(GeneralService):
Returns(Course): Synchronized course
Returns(Course): Synchronized course
"""
"""
definition
=
definition
.
get
(
'course'
)
or
definition
definition
=
definition
.
get
(
'course'
)
or
definition
if
'state'
in
definition
:
definition
[
'state'
]
=
CourseState
(
definition
[
'state'
])
course
=
self
.
_get_course
(
definition
[
'codename'
])
course
=
self
.
_get_course
(
definition
[
'codename'
])
params
=
self
.
_course_params
params
=
self
.
_course_params
_update_params
(
course
,
definition
,
params
)
_update_params
(
course
,
definition
,
params
)
projects
=
definition
.
get
(
'projects'
)
projects
=
definition
.
get
(
'projects'
)
if
projects
:
if
projects
:
...
@@ -125,6 +129,7 @@ class ResourceDefinitionService(GeneralService):
...
@@ -125,6 +129,7 @@ class ResourceDefinitionService(GeneralService):
Returns(Dict): Course dump
Returns(Dict): Course dump
"""
"""
schema
=
_extract_params
(
course
,
self
.
_course_params
)
schema
=
_extract_params
(
course
,
self
.
_course_params
)
schema
[
'state'
]
=
course
.
state
.
value
schema
[
'projects'
]
=
[
self
.
dump_project
(
project
)
for
project
in
course
.
projects
]
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
[
'roles'
]
=
[
self
.
dump_role
(
role
,
with_clients
=
with_users
)
for
role
in
course
.
roles
]
schema
[
'groups'
]
=
[
schema
[
'groups'
]
=
[
...
@@ -178,7 +183,7 @@ class ResourceDefinitionService(GeneralService):
...
@@ -178,7 +183,7 @@ class ResourceDefinitionService(GeneralService):
Returns:
Returns:
"""
"""
schema
=
_extract_params
(
group
,
self
.
_ro
le
_params
)
schema
=
_extract_params
(
group
,
self
.
_
g
ro
up
_params
)
if
with_users
:
if
with_users
:
schema
[
'users'
]
=
[
client
.
id
for
client
in
group
.
users
]
schema
[
'users'
]
=
[
client
.
id
for
client
in
group
.
users
]
if
with_projects
:
if
with_projects
:
...
@@ -209,8 +214,8 @@ class ResourceDefinitionService(GeneralService):
...
@@ -209,8 +214,8 @@ class ResourceDefinitionService(GeneralService):
@
property
@
property
def
_course_params
(
self
)
->
List
[
str
]:
def
_course_params
(
self
)
->
List
[
str
]:
params
=
[
'codename'
,
'name'
,
'descriptio
n'
,
params
=
Course
.
updatable_params
()
+
[
'notes_access_toke
n'
]
'notes_access_token'
,
'faculty_id'
,
'stat
us'
]
params
.
remove
(
'stat
e'
)
return
params
return
params
@
property
@
property
...
@@ -220,11 +225,11 @@ class ResourceDefinitionService(GeneralService):
...
@@ -220,11 +225,11 @@ class ResourceDefinitionService(GeneralService):
@
property
@
property
def
_role_params
(
self
)
->
List
[
str
]:
def
_role_params
(
self
)
->
List
[
str
]:
return
[
'codename'
,
'name'
,
'description'
]
return
Role
.
updatable_params
()
@
property
@
property
def
_group_params
(
self
)
->
List
[
str
]:
def
_group_params
(
self
)
->
List
[
str
]:
return
[
'codename'
,
'name'
,
'description'
]
return
Group
.
updatable_params
()
def
_update_params
(
entity
,
schema
:
Dict
,
params
):
def
_update_params
(
entity
,
schema
:
Dict
,
params
):
...
...
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