Verified Commit 5ece2f58 authored by Peter Stanko's avatar Peter Stanko
Browse files

Fixed course state by definition

parent 7b25ecb2
Pipeline #31394 passed with stage
in 7 minutes and 37 seconds
......@@ -812,7 +812,7 @@ class Submission(db.Model, EntityBase):
project: Associated project for 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]
__tablename__ = 'submission'
id = db.Column(db.String(length=36), default=lambda: str(
......
......@@ -128,7 +128,7 @@ class PasswordChangeSchema(Schema):
class CourseSchema(BaseSchema, NamedSchema, Schema):
"""Course Schema
"""
state = EnumField(CourseState)
state = EnumField(CourseState, by_value=True)
roles = NESTED['roles']
groups = NESTED['groups']
projects = NESTED['projects']
......
......@@ -2,7 +2,8 @@ from datetime import datetime
from typing import Dict, List
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
......@@ -15,8 +16,11 @@ class ResourceDefinitionService(GeneralService):
Returns(Course): Synchronized course
"""
definition = definition.get('course') or definition
if 'state' in definition:
definition['state'] = CourseState(definition['state'])
course = self._get_course(definition['codename'])
params = self._course_params
_update_params(course, definition, params)
projects = definition.get('projects')
if projects:
......@@ -125,6 +129,7 @@ class ResourceDefinitionService(GeneralService):
Returns(Dict): Course dump
"""
schema = _extract_params(course, self._course_params)
schema['state'] = course.state.value
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'] = [
......@@ -178,7 +183,7 @@ class ResourceDefinitionService(GeneralService):
Returns:
"""
schema = _extract_params(group, self._role_params)
schema = _extract_params(group, self._group_params)
if with_users:
schema['users'] = [client.id for client in group.users]
if with_projects:
......@@ -209,8 +214,8 @@ class ResourceDefinitionService(GeneralService):
@property
def _course_params(self) -> List[str]:
params = ['codename', 'name', 'description',
'notes_access_token', 'faculty_id', 'status']
params = Course.updatable_params() + ['notes_access_token']
params.remove('state')
return params
@property
......@@ -220,11 +225,11 @@ class ResourceDefinitionService(GeneralService):
@property
def _role_params(self) -> List[str]:
return ['codename', 'name', 'description']
return Role.updatable_params()
@property
def _group_params(self) -> List[str]:
return ['codename', 'name', 'description']
return Group.updatable_params()
def _update_params(entity, schema: Dict, params):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment