From 5e76ce54201c6763c4f05ec15e055833518509b1 Mon Sep 17 00:00:00 2001 From: khansadaoudi Date: Thu, 31 Aug 2023 16:25:30 +0200 Subject: [PATCH] add language attribute to projet --- app/db_update.py | 1 + app/projects/controller.py | 2 ++ app/projects/interface.py | 1 + app/projects/model.py | 1 + app/projects/schema.py | 4 +++- 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/db_update.py b/app/db_update.py index f27f2cd..81e0f06 100644 --- a/app/db_update.py +++ b/app/db_update.py @@ -55,6 +55,7 @@ def migrate_add_validated_tree(engine): with engine.connect() as connection: connection.execute('ALTER TABLE projects RENAME COLUMN exercise_mode To blind_annotation_mode') connection.execute('ALTER TABLE projects ADD config STRING') + connection.execute('ALTER TABLE projects ADD language STRING') connection.execute('ALTER TABLE projects DROP show_all_trees') connection.execute('ALTER TABLE exerciselevel RENAME COLUMN exercise_level TO blind_annotation_level') connection.execute('ALTER TABLE exerciselevel RENAME TO blindannotationlevel') diff --git a/app/projects/controller.py b/app/projects/controller.py index 90b2dec..36667d3 100644 --- a/app/projects/controller.py +++ b/app/projects/controller.py @@ -105,6 +105,7 @@ def post(self) -> Project: parser.add_argument(name="blindAnnotationMode", type=bool) parser.add_argument(name="visibility", type=int) parser.add_argument(name="config", type=str) + parser.add_argument(name="language", type=str) args = parser.parse_args() # Sanitize the project name to correspond to Grew folders requirements @@ -117,6 +118,7 @@ def post(self) -> Project: "visibility": args.visibility, "freezed": False, "config": args.config, + "language": args.language } # KK : TODO : put all grew request in a seperated file and add error catching diff --git a/app/projects/interface.py b/app/projects/interface.py index 493a68d..ecff3d4 100644 --- a/app/projects/interface.py +++ b/app/projects/interface.py @@ -11,6 +11,7 @@ class ProjectInterface(TypedDict, total=False): blind_annotation_mode: bool freezed: bool config: str + language: str class ProjectExtendedInterface(ProjectInterface, total=False): diff --git a/app/projects/model.py b/app/projects/model.py index 33046ca..8478a2e 100644 --- a/app/projects/model.py +++ b/app/projects/model.py @@ -22,6 +22,7 @@ class Project(db.Model, BaseM): diff_user_id = Column(String(256), nullable=True) freezed = Column(Boolean, default=False) config = Column(String(256), nullable=True) + language = Column(String(256), nullable=True) feature = db.relationship("ProjectFeature", cascade="all,delete", backref="projects") meta_feature = db.relationship("ProjectMetaFeature", cascade="all,delete", backref="projects") diff --git a/app/projects/schema.py b/app/projects/schema.py index 100698e..37a85ed 100644 --- a/app/projects/schema.py +++ b/app/projects/schema.py @@ -30,7 +30,8 @@ class ProjectSchema(Schema): visibility = fields.Integer(attribute="visibility") blindAnnotationMode = fields.Boolean(attribute="blind_annotation_mode") freezed = fields.Boolean(attribute="freezed") - config = fields.Boolean(attribute="config") + config = fields.String(attribute="config") + language = fields.String(attribute="language") class ProjectExtendedSchema(ProjectSchema): @@ -61,6 +62,7 @@ class ProjectSchemaCamel(Schema): blindAnnotationMode = fields.Boolean(attribute="blind_annotation_mode") freezed = fields.Boolean(attribute="freezed") config = fields.String(attribute="config") + language = fields.String(attribute="language") diffMode = fields.Boolean(attribute="diff_mode") diffUserId = fields.String(attribute="diff_user_id")