File size: 1,326 Bytes
4dd778b
 
df42f36
 
 
 
 
 
 
 
 
 
c90fe2b
 
df42f36
 
4dd778b
df42f36
c90fe2b
 
df42f36
044d0ec
df42f36
 
b3393c0
df42f36
 
 
 
c90fe2b
df42f36
4dd778b
 
 
 
 
c90fe2b
4dd778b
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from collections import Counter

from flask import Blueprint
from flask import flash
from flask import g
from flask import redirect
from flask import render_template
from flask import request
from flask import url_for
from werkzeug.exceptions import abort
from flask import session

from threading import Thread

from .auth import login_required
from .db import get_db
from ice_breaking_challenge.google_sheets import get_team_numbers

from background_task import background_task


bp = Blueprint("qr", __name__, url_prefix="/qr")


@bp.route("/", methods=["GET", "POST"])
def qr() -> None:
    match request.method:
        case "GET":
            return render_template("qr.html")

        case "POST":   # qr.htmlμ—μ„œ `λ‹€μŒ` λ²„νŠΌ λˆŒλ €μ„ λ•Œ
            counter = Counter(get_team_numbers())
            if session.get("team_number") not in counter:
                flash("ν•΄λ‹Ή νŒ€ λ²ˆν˜Έκ°€ μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.")
                return render_template("index.html")
            if counter[session.get("team_number")] == session["team_size"]:
                Thread(target=background_task).start()  
                return render_template("introduction.html")
            else:
                flash("섀문을 μ™„λ£Œν•˜μ§€ μ•Šμ€ νŒ€μ›μ΄ μžˆμŠ΅λ‹ˆλ‹€.")
                return render_template("qr.html")