diff --git a/teraserver/python/alembic/versions/dbe0ef5395eb_revised_test_types_tables.py b/teraserver/python/alembic/versions/dbe0ef5395eb_revised_test_types_tables.py index bbc65149d..ea468da1e 100644 --- a/teraserver/python/alembic/versions/dbe0ef5395eb_revised_test_types_tables.py +++ b/teraserver/python/alembic/versions/dbe0ef5395eb_revised_test_types_tables.py @@ -40,8 +40,12 @@ def upgrade(): sa.Column('id_test_type', sa.Integer, sa.Sequence('id_test_type_sequence'), primary_key=True, autoincrement=True), sa.Column('id_service', sa.Integer, sa.ForeignKey('t_services.id_service'), nullable=False), + sa.Column('test_type_uuid', sa.String(36), nullable=False, unique=True), sa.Column('test_type_name', sa.String, nullable=False, unique=False), - sa.Column('test_type_description', sa.String, nullable=True) + sa.Column('test_type_description', sa.String, nullable=True), + sa.Column('test_type_has_json_format', sa.Boolean, nullable=False, default=False), + sa.Column('test_type_has_web_format', sa.Boolean, nullable=False, default=False), + sa.Column('test_type_has_web_editor', sa.Boolean, nullable=False, default=False) ) op.execute(CreateSequence(sa.Sequence('id_test_type_sequence'))) diff --git a/teraserver/python/opentera/db/models/TeraTestType.py b/teraserver/python/opentera/db/models/TeraTestType.py index cccc69cb8..c5fdf98ed 100644 --- a/teraserver/python/opentera/db/models/TeraTestType.py +++ b/teraserver/python/opentera/db/models/TeraTestType.py @@ -1,12 +1,20 @@ from opentera.db.Base import db, BaseModel +import uuid class TeraTestType(db.Model, BaseModel): __tablename__ = 't_tests_types' id_test_type = db.Column(db.Integer, db.Sequence('id_test_type_sequence'), primary_key=True, autoincrement=True) id_service = db.Column(db.Integer, db.ForeignKey("t_services.id_service"), nullable=False) + test_type_uuid = db.Column(db.String(36), nullable=False, unique=True) test_type_name = db.Column(db.String, nullable=False, unique=False) test_type_description = db.Column(db.String, nullable=True) + # Test type service provides TeraForm style json format? + test_type_has_json_format = db.Column(db.Boolean, nullable=False, default=False) + # Test type service provides a generated HTML form? + test_type_has_web_format = db.Column(db.Boolean, nullable=False, default=False) + # Test type service provides a web based editor? + test_type_has_web_editor = db.Column(db.Boolean, nullable=False, default=False) test_type_service = db.relationship("TeraService", cascade='delete') @@ -34,18 +42,26 @@ def create_defaults(test=False): test.test_type_name = 'Pre-session evaluation' test.test_type_description = 'Evaluation shown before a session' test.id_service = TeraService.get_service_by_key('VideoRehabService').id_service + test.test_type_uuid = str(uuid.uuid4()) + test.test_type_has_json_format = True db.session.add(test) test = TeraTestType() test.test_type_name = 'Post-session evaluation' test.test_type_description = 'Evaluation shown after a session' test.id_service = TeraService.get_service_by_key('VideoRehabService').id_service + test.test_type_uuid = str(uuid.uuid4()) + test.test_type_has_json_format = True + test.test_type_has_web_format = True db.session.add(test) test = TeraTestType() test.test_type_name = 'General survey' test.test_type_description = 'General satisfaction survey' test.id_service = TeraService.get_service_by_key('BureauActif').id_service + test.test_type_uuid = str(uuid.uuid4()) + test.test_type_has_web_format = True + test.test_type_has_web_editor = True db.session.add(test) db.session.commit() @@ -58,4 +74,9 @@ def get_test_type_by_id(test_type_id: int): def get_test_types_for_service(id_service: int): return TeraTestType.query.filter_by(id_service=id_service).all() + @classmethod + def insert(cls, test_type): + # Generate UUID + test_type.test_type_uuid = str(uuid.uuid4()) + super().insert(test_type) \ No newline at end of file diff --git a/teraserver/python/opentera/db/models/__init__.py b/teraserver/python/opentera/db/models/__init__.py index 1cdb91d9e..045ad6b11 100644 --- a/teraserver/python/opentera/db/models/__init__.py +++ b/teraserver/python/opentera/db/models/__init__.py @@ -24,7 +24,7 @@ from .TeraSessionTypeProject import TeraSessionTypeProject from .TeraSessionUsers import TeraSessionUsers from .TeraSite import TeraSite -from .TeraTest import TeraTest +# from .TeraTest import TeraTest from .TeraTestType import TeraTestType from .TeraUser import TeraUser from .TeraUserGroup import TeraUserGroup @@ -76,8 +76,10 @@ 'TeraSessionTypeSite', 'TeraSessionUsers', 'TeraSite', - 'TeraTest', + # 'TeraTest', 'TeraTestType', + 'TeraTestTypeSite', + 'TeraTestTypeProject', 'TeraUser', 'TeraUserGroup', 'TeraUserPreference',