From 278a1713a1ecc46bd05d7b8fa72cd14773f16af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20L=C3=B6fgren?= <viclo211@student.liu.se> Date: Sun, 18 Apr 2021 22:45:55 +0200 Subject: [PATCH] Get competition id from team when joining with a team code --- client/src/sockets.ts | 2 -- server/app/core/sockets.py | 11 ++++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/client/src/sockets.ts b/client/src/sockets.ts index e4e9b923..874bfc46 100644 --- a/client/src/sockets.ts +++ b/client/src/sockets.ts @@ -28,8 +28,6 @@ export const socket_connect = () => { socket.on('set_timer', (data: SetTimerInterface) => { setPresentationTimer(data.timer)(store.dispatch) - // store.dispatch(setTimerEnabled(data.timer.enabled)) - // store.dispatch(setTimer(data.timer.value)) }) socket.on('end_presentation', () => { diff --git a/server/app/core/sockets.py b/server/app/core/sockets.py index 9c6137ca..f4909531 100644 --- a/server/app/core/sockets.py +++ b/server/app/core/sockets.py @@ -1,6 +1,6 @@ import app.database.controller as dbc from app.core import db -from app.database.models import Competition, Slide, ViewType +from app.database.models import Competition, Slide, Team, ViewType from flask.globals import request from flask_socketio import SocketIO, emit, join_room @@ -83,10 +83,11 @@ def join_presentation(data): print("CODE DOES NOT EXIST") return - if item_code.view_type_id == team_view_id: - pass # TODO: Get competition_id from team instead - else: - competition_id = item_code.pointer + competition_id = ( + item_code.pointer + if item_code.view_type_id != team_view_id + else db.session.query(Team).filter(Team.id == item_code.pointer).one().competition_id + ) if competition_id not in presentations: print("THAT COMPETITION IS CURRENTLY NOT ACTIVE") -- GitLab