From 2036ec25153532967555b8aa97e981d02e50b256 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 7 Oct 2018 21:26:53 +0200 Subject: [PATCH] asdadsasdasda --- db.py | 21 ++---------- discordbot.py | 2 +- ohciaovedochestaileggendoilmiostato.py | 11 ++++--- templates/minis/halloween.html | 2 +- templates/ohciaodinuovo.html | 44 ++++++++------------------ 5 files changed, 26 insertions(+), 54 deletions(-) diff --git a/db.py b/db.py index fef2eb28..0d3ffa88 100644 --- a/db.py +++ b/db.py @@ -898,9 +898,6 @@ class Halloween(Base): puzzle_piece_e = Column(DateTime) puzzle_piece_f = Column(DateTime) puzzle_piece_g = Column(DateTime) - puzzle_piece_h = Column(DateTime) - puzzle_piece_i = Column(DateTime) - puzzle_piece_j = Column(DateTime) boss_battle = Column(DateTime) @@ -921,12 +918,6 @@ class Halloween(Base): return self.puzzle_piece_f elif item == 7: return self.puzzle_piece_g - elif item == 8: - return self.puzzle_piece_h - elif item == 9: - return self.puzzle_piece_i - elif item == 10: - return self.puzzle_piece_j else: raise ValueError("No such puzzle piece") @@ -947,18 +938,12 @@ class Halloween(Base): self.puzzle_piece_f = value elif key == 7: self.puzzle_piece_g = value - elif key == 8: - self.puzzle_piece_h = value - elif key == 9: - self.puzzle_piece_i = value - elif key == 10: - self.puzzle_piece_j = value else: raise ValueError("No such puzzle piece") def pieces_completed(self) -> int: count = 0 - for i in range(1, 11): + for i in range(1, 8): if self[i]: count += 1 return count @@ -969,9 +954,9 @@ class Halloween(Base): halloweens = session.query(Halloween).all() session.close() started = bool(halloweens) - completed = [False for _ in range(10)] + completed = [False for _ in range(7)] for h in halloweens: - for i in range(10): + for i in range(7): if h[i+1]: completed[i] = True return started, completed diff --git a/discordbot.py b/discordbot.py index 4262db2a..172a760c 100644 --- a/discordbot.py +++ b/discordbot.py @@ -526,7 +526,7 @@ class RoyalDiscordBot(discord.Client): if "ghostbusters" in now_playing.plain_text().lower(): halloween = await loop.run_in_executor(executor, session.query(db.Halloween) .filter_by(royal=enqueuer).one_or_none) - halloween[4] = True + halloween[5] = datetime.datetime.now() # END await loop.run_in_executor(executor, session.commit) await loop.run_in_executor(executor, session.close) diff --git a/ohciaovedochestaileggendoilmiostato.py b/ohciaovedochestaileggendoilmiostato.py index 69a845cb..8722a723 100644 --- a/ohciaovedochestaileggendoilmiostato.py +++ b/ohciaovedochestaileggendoilmiostato.py @@ -47,12 +47,15 @@ def page_voiceofevil(): if request.form.get("solution", "") != "1": abort(400) return + if "user_id" not in request.form: + abort(403) + return db_session = db.Session() - halloween = db_session.query(db.Halloween).filter_by(royal_id=fl_session["user_id"]).one_or_none() + halloween = db_session.query(db.Halloween).filter_by(royal_id=request.form["user_id"]).one_or_none() if halloween is None: abort(403) return - halloween[3] = True + halloween[4] = datetime.datetime.now() db_session.commit() return redirect(url_for("page_owlcaptain")) @@ -63,11 +66,11 @@ def page_mansion(): abort(400) return db_session = db.Session() - halloween = db_session.query(db.Halloween).filter_by(royal_id=fl_session["user_id"]).one_or_none() + halloween = db_session.query(db.Halloween).filter_by(royal_id=request.form["user_id"]).one_or_none() if halloween is None: abort(403) return - halloween[5] = True + halloween[6] = datetime.datetime.now() db_session.commit() return redirect(url_for("page_owlcaptain")) diff --git a/templates/minis/halloween.html b/templates/minis/halloween.html index 407cae96..66e4dcd4 100644 --- a/templates/minis/halloween.html +++ b/templates/minis/halloween.html @@ -7,7 +7,7 @@ Lune ottenute
- {% for index in range(10) %} + {% for index in range(7) %} {% if record[index + 1] %} {% else %} diff --git a/templates/ohciaodinuovo.html b/templates/ohciaodinuovo.html index 8a5e81fd..d2818834 100644 --- a/templates/ohciaodinuovo.html +++ b/templates/ohciaodinuovo.html @@ -27,15 +27,18 @@ mode: "cors", credentials: "include" }).done((result) => { - data = result.json(); - if(data["user_id"] === null) { - document.getElementById("main").innerHTML = "i don't know you. " + - "try logging in first."; - return; - user_id = data["user_id"]; - username = data["username"]; - } - + result.json().done((result) => { + if(result["id"] === null) { + document.getElementById("main").innerHTML = "i don't know you. " + + "try logging in first."; + return; + } + user_id = result["id"]; + username = result["username"]; + document.getElementsByName("user_id").forEach((item) => { + item.setAttribute("value", user_id); + }) + }); }) } @@ -114,6 +117,7 @@
+
{% elif loop.index == 5 %} @@ -138,6 +142,7 @@
+
{% elif loop.index == 7 %} @@ -146,27 +151,6 @@
-
- {% elif loop.index == 8 %} -

- -

-
- -
- {% elif loop.index == 9 %} -

- -

-
- -
- {% elif loop.index == 10 %} -

- -

-
-
{% endif %}