From 299484d7a00d10f451528398ac7b353999be4aa3 Mon Sep 17 00:00:00 2001
From: Peter Stanko <peter.stanko0@gmail.com>
Date: Sat, 18 Aug 2018 16:23:59 +0200
Subject: [PATCH] Schema update - added course and project id for the
 submission

---
 management/data/shared.py | 4 +++-
 portal/config.py          | 3 ++-
 portal/rest/schemas.py    | 4 +++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/management/data/shared.py b/management/data/shared.py
index 907df08..7d7248f 100644
--- a/management/data/shared.py
+++ b/management/data/shared.py
@@ -132,9 +132,11 @@ class DataFactory(object):
         role.description = desc or f"{name.capitalize()}'s role"
         return role
 
-    def create_project(self, course, name, codename, config=None) -> Project:
+    def create_project(self, course, name=None, codename=None, config=None) -> Project:
         config = config or {}
         desc = name + "'s description"
+        name = name or codename
+        codename = codename or name
         project = self.__create_entity(Project, course=course, name=name,
                                        codename=codename, description=desc)
         project.set_config(**config)
diff --git a/portal/config.py b/portal/config.py
index 9d72582..e902dc1 100644
--- a/portal/config.py
+++ b/portal/config.py
@@ -39,7 +39,8 @@ class Config(object):
 class DevelopmentConfig(Config):
     """Development configuration
     """
-    SQLALCHEMY_DATABASE_URI = f"sqlite:///{paths.ROOT_DIR}/devel.db"
+    #SQLALCHEMY_DATABASE_URI = f"sqlite:///{paths.ROOT_DIR}/devel.db"
+    SQLALCHEMY_DATABASE_URI = f"postgresql://postgres:postgres@localhost:5432/postgres"
     SQLALCHEMY_TRACK_MODIFICATIONS = True
     PORTAL_ENV = 'dev'
     PORTAL_ADMIN_USER_PASSWORD = '789789'
diff --git a/portal/rest/schemas.py b/portal/rest/schemas.py
index a263892..f9ab58d 100644
--- a/portal/rest/schemas.py
+++ b/portal/rest/schemas.py
@@ -53,7 +53,9 @@ class NestedCollection:
             'Course': ('id', 'codename'),
             'User': ('id', 'username', 'uco'),
             'Component': ('id', 'name', 'type'),
-            'Submission': ('id', 'state', 'user.id', 'user.username'),
+            'Submission': ('id', 'state', 'user.id', 'user.username',
+                           'project.id', 'project.codename',
+                           'project.course.id', 'project.course.codename'),
             'ReviewItem': ('id', 'review.id', 'line', 'content', 'file', 'user.id'),
             }
 
-- 
GitLab