Skip to content
Snippets Groups Projects
Commit 89a7cdf4 authored by Victor Löfgren's avatar Victor Löfgren
Browse files

Merge branch 'dev' of gitlab.liu.se:tddd96-grupp11/teknikattan-scoring-system...

Merge branch 'dev' of gitlab.liu.se:tddd96-grupp11/teknikattan-scoring-system into 170-add-server-comments
parents ef10c47c 93baed60
No related branches found
No related tags found
1 merge request!135Resolve "Add server comments"
Pipeline #45925 passed
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 React from 'react'
import { getEditorCompetition } from '../../../../actions/editor'
import { useAppDispatch, useAppSelector } from '../../../../hooks' import { useAppDispatch, useAppSelector } from '../../../../hooks'
import { TextComponent } from '../../../../interfaces/ApiModels' import { TextComponent } from '../../../../interfaces/ApiModels'
import { RichSlide } from '../../../../interfaces/ApiRichModels' import { RichSlide } from '../../../../interfaces/ApiRichModels'
import { AddButton, Center, SettingsList, TextCard } from '../styled' import { AddButton, Center, SettingsList, TextCard } from '../styled'
import TextComponentEdit from '../TextComponentEdit' import TextComponentEdit from '../TextComponentEdit'
import axios from 'axios'
import { getEditorCompetition } from '../../../../actions/editor'
type TextsProps = { type TextsProps = {
activeViewTypeId: number activeViewTypeId: number
...@@ -27,7 +27,7 @@ const Texts = ({ activeViewTypeId, activeSlide, competitionId }: TextsProps) => ...@@ -27,7 +27,7 @@ const Texts = ({ activeViewTypeId, activeSlide, competitionId }: TextsProps) =>
if (activeSlide) { if (activeSlide) {
await axios.post(`/api/competitions/${competitionId}/slides/${activeSlide?.id}/components`, { await axios.post(`/api/competitions/${competitionId}/slides/${activeSlide?.id}/components`, {
type_id: 1, type_id: 1,
text: 'Ny text', text: '<p><span style="font-size: 24pt;">Ny text</span></p>',
w: 315, w: 315,
h: 50, h: 50,
view_type_id: activeViewTypeId, view_type_id: activeViewTypeId,
......
...@@ -14,6 +14,7 @@ class RichSchema(ma.SQLAlchemySchema): ...@@ -14,6 +14,7 @@ class RichSchema(ma.SQLAlchemySchema):
strict = True strict = True
load_instance = True load_instance = True
include_relationships = True include_relationships = True
ordered = False
class QuestionSchemaRich(RichSchema): class QuestionSchemaRich(RichSchema):
......
...@@ -13,6 +13,7 @@ class BaseSchema(ma.SQLAlchemySchema): ...@@ -13,6 +13,7 @@ class BaseSchema(ma.SQLAlchemySchema):
strict = True strict = True
load_instance = False load_instance = False
include_relationships = False include_relationships = False
ordered = False
class IdNameSchema(BaseSchema): class IdNameSchema(BaseSchema):
......
...@@ -19,7 +19,7 @@ from app.database.models import ( ...@@ -19,7 +19,7 @@ from app.database.models import (
User, User,
) )
from sqlalchemy import func from sqlalchemy import func
from sqlalchemy.orm import joinedload from sqlalchemy.orm import joinedload, subqueryload
from sqlalchemy.orm.util import with_polymorphic from sqlalchemy.orm.util import with_polymorphic
...@@ -305,15 +305,15 @@ def component_list(competition_id, slide_id): ...@@ -305,15 +305,15 @@ def component_list(competition_id, slide_id):
def competition(competition_id): def competition(competition_id):
""" Get Competition and all it's sub-entities. """ """ Get Competition and all it's sub-entities. """
os1 = joinedload(Competition.slides).joinedload(Slide.components) join_component = joinedload(Competition.slides).subqueryload(Slide.components)
os2 = joinedload(Competition.slides).joinedload(Slide.questions).joinedload(Question.alternatives) join_alternatives = joinedload(Competition.slides).joinedload(Slide.questions).joinedload(Question.alternatives)
ot = joinedload(Competition.teams).joinedload(Team.question_alternative_answers) join_question_alternative_answer = joinedload(Competition.teams).joinedload(Team.question_alternative_answers)
ot1 = joinedload(Competition.teams).joinedload(Team.question_scores) join_question_score = joinedload(Competition.teams).joinedload(Team.question_scores)
return ( return (
Competition.query.filter(Competition.id == competition_id) Competition.query.filter(Competition.id == competition_id)
.options(os1) .options(join_component)
.options(os2) .options(join_alternatives)
.options(ot) .options(join_question_alternative_answer)
.options(ot1) .options(join_question_score)
.first() .first()
) )
...@@ -19,6 +19,7 @@ class Config: ...@@ -19,6 +19,7 @@ class Config:
SQLALCHEMY_ECHO = False SQLALCHEMY_ECHO = False
USER_LOGIN_LOCKED_ATTEMPTS = 12 USER_LOGIN_LOCKED_ATTEMPTS = 12
USER_LOGIN_LOCKED_EXPIRES = timedelta(hours=3) USER_LOGIN_LOCKED_EXPIRES = timedelta(hours=3)
JSON_SORT_KEYS = False
class DevelopmentConfig(Config): class DevelopmentConfig(Config):
......
...@@ -86,13 +86,17 @@ def create_default_items(): ...@@ -86,13 +86,17 @@ def create_default_items():
y = random.randrange(1, 500) y = random.randrange(1, 500)
w = random.randrange(150, 400) w = random.randrange(150, 400)
h = 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): for k in range(3):
x = random.randrange(1, 500) x = random.randrange(1, 500)
y = random.randrange(1, 500) y = random.randrange(1, 500)
w = random.randrange(150, 400) w = random.randrange(150, 400)
h = 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 = dbc.add.slide(item_comp)
# item_slide.title = f"Slide {len(item_comp.slides)}" # item_slide.title = f"Slide {len(item_comp.slides)}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment