diff --git a/client/src/pages/presentationEditor/components/slideSettingsComponents/Texts.tsx b/client/src/pages/presentationEditor/components/slideSettingsComponents/Texts.tsx index 03656614e3076e6048984e70b7ddd0ae711a492d..dd934e60319ab50419ea68ec0df3d1b8382dcdb5 100644 --- a/client/src/pages/presentationEditor/components/slideSettingsComponents/Texts.tsx +++ b/client/src/pages/presentationEditor/components/slideSettingsComponents/Texts.tsx @@ -1,12 +1,12 @@ -import { Divider, ListItem, ListItemText, Typography } from '@material-ui/core' +import { Divider, ListItem, ListItemText } from '@material-ui/core' +import axios from 'axios' import React from 'react' +import { getEditorCompetition } from '../../../../actions/editor' import { useAppDispatch, useAppSelector } from '../../../../hooks' import { TextComponent } from '../../../../interfaces/ApiModels' import { RichSlide } from '../../../../interfaces/ApiRichModels' import { AddButton, Center, SettingsList, TextCard } from '../styled' import TextComponentEdit from '../TextComponentEdit' -import axios from 'axios' -import { getEditorCompetition } from '../../../../actions/editor' type TextsProps = { activeViewTypeId: number @@ -27,7 +27,7 @@ const Texts = ({ activeViewTypeId, activeSlide, competitionId }: TextsProps) => if (activeSlide) { await axios.post(`/api/competitions/${competitionId}/slides/${activeSlide?.id}/components`, { type_id: 1, - text: 'Ny text', + text: '<p><span style="font-size: 24pt;">Ny text</span></p>', w: 315, h: 50, view_type_id: activeViewTypeId, diff --git a/server/app/core/rich_schemas.py b/server/app/core/rich_schemas.py index 9696f68e29d8ed091cd1b460bba16f8eca6a9729..1b21e5b5feba0bd52983d649c646282fbd1c2bd2 100644 --- a/server/app/core/rich_schemas.py +++ b/server/app/core/rich_schemas.py @@ -14,6 +14,7 @@ class RichSchema(ma.SQLAlchemySchema): strict = True load_instance = True include_relationships = True + ordered = False class QuestionSchemaRich(RichSchema): diff --git a/server/app/core/schemas.py b/server/app/core/schemas.py index 34547f572168aca42ec5f29c36853191c2411dec..64d9ca189293602fd70f8f05e70d96c0f9556721 100644 --- a/server/app/core/schemas.py +++ b/server/app/core/schemas.py @@ -13,6 +13,7 @@ class BaseSchema(ma.SQLAlchemySchema): strict = True load_instance = False include_relationships = False + ordered = False class IdNameSchema(BaseSchema): diff --git a/server/app/database/controller/get.py b/server/app/database/controller/get.py index ecdc506732c6e98051e1da440dffb26e769ff673..c888fc6dc86318321ecb8b9bd31d0495db062569 100644 --- a/server/app/database/controller/get.py +++ b/server/app/database/controller/get.py @@ -19,7 +19,7 @@ from app.database.models import ( User, ) from sqlalchemy import func -from sqlalchemy.orm import joinedload +from sqlalchemy.orm import joinedload, subqueryload from sqlalchemy.orm.util import with_polymorphic @@ -305,15 +305,15 @@ def component_list(competition_id, slide_id): def competition(competition_id): """ Get Competition and all it's sub-entities. """ - os1 = joinedload(Competition.slides).joinedload(Slide.components) - os2 = joinedload(Competition.slides).joinedload(Slide.questions).joinedload(Question.alternatives) - ot = joinedload(Competition.teams).joinedload(Team.question_alternative_answers) - ot1 = joinedload(Competition.teams).joinedload(Team.question_scores) + join_component = joinedload(Competition.slides).subqueryload(Slide.components) + join_alternatives = joinedload(Competition.slides).joinedload(Slide.questions).joinedload(Question.alternatives) + join_question_alternative_answer = joinedload(Competition.teams).joinedload(Team.question_alternative_answers) + join_question_score = joinedload(Competition.teams).joinedload(Team.question_scores) return ( Competition.query.filter(Competition.id == competition_id) - .options(os1) - .options(os2) - .options(ot) - .options(ot1) + .options(join_component) + .options(join_alternatives) + .options(join_question_alternative_answer) + .options(join_question_score) .first() ) diff --git a/server/configmodule.py b/server/configmodule.py index e38c4e04cf1b90ffff4edbe0cbcffffb347c5b4a..25978d378ee2e027730f91b7f025bb0080768e38 100644 --- a/server/configmodule.py +++ b/server/configmodule.py @@ -19,6 +19,7 @@ class Config: SQLALCHEMY_ECHO = False USER_LOGIN_LOCKED_ATTEMPTS = 12 USER_LOGIN_LOCKED_EXPIRES = timedelta(hours=3) + JSON_SORT_KEYS = False class DevelopmentConfig(Config): diff --git a/server/populate.py b/server/populate.py index 7b975504b3a214f0cd8eb5cc9bd473fbffc3210c..7a629ade28ee78455d0e21882fd8e92165025d26 100644 --- a/server/populate.py +++ b/server/populate.py @@ -86,13 +86,17 @@ def create_default_items(): y = random.randrange(1, 500) w = random.randrange(150, 400) h = random.randrange(150, 400) - dbc.add.component(1, item_slide.id, 1, x, y, w, h, text=f"hej{k}") + dbc.add.component( + 1, item_slide.id, 1, x, y, w, h, text=f"<p><span style='font-size: 24pt;'>{k}</span></p>" + ) for k in range(3): x = random.randrange(1, 500) y = random.randrange(1, 500) w = random.randrange(150, 400) h = random.randrange(150, 400) - dbc.add.component(1, item_slide.id, 3, x, y, w, h, text=f"hej{k}") + dbc.add.component( + 1, item_slide.id, 3, x, y, w, h, text=f"<p><span style='font-size: 24pt;'>{k}</span></p>" + ) # item_slide = dbc.add.slide(item_comp) # item_slide.title = f"Slide {len(item_comp.slides)}"