From 656fb17df2d01e024f78e363f6b8cad814dcb4a5 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Sat, 28 Sep 2019 14:52:11 -0500 Subject: [PATCH] Add block clause Cast all actions to string for comparison Signed-off-by: Etzelia --- gui.py | 13 +++++++++++-- models.py | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gui.py b/gui.py index 86d2fee..47c1fb6 100644 --- a/gui.py +++ b/gui.py @@ -114,6 +114,13 @@ def gui_results(form): players.append(player.strip()) players_clause = " AND ({})".format(" OR ".join(["cu.user LIKE '{}%%'".format(p) for p in players])) + blocks = [] + blocks_clause = "" + if form.blocks: + for block in form.blocks.split(","): + blocks.append(block.strip()) + blocks_clause = " AND ({})".format(" OR ".join(["cmm.material LIKE 'minecraft:{}%'".format(b) for b in blocks])) + worlds_clause = "" worlds = [world["id"] for world in form.worlds if world["checked"]] if len(worlds): @@ -147,10 +154,11 @@ def gui_results(form): {ignore_environment} {players} {coords} + {blocks} {worlds} {time} '''.format(action=",".join(block_actions), ignore_environment=ignore_environment, players=players_clause, - coords=coords_clause, worlds=worlds_clause, time=time_clause)) + coords=coords_clause, blocks=blocks_clause, worlds=worlds_clause, time=time_clause)) # Chat if form.chat: @@ -175,8 +183,9 @@ def gui_results(form): {worlds} {players} {coords} + {blocks} {time} - '''.format(worlds=worlds_clause, players=players_clause, coords=coords_clause, time=time_clause)) + '''.format(worlds=worlds_clause, players=players_clause, coords=coords_clause, blocks=blocks_clause, time=time_clause)) # Commands if form.command: diff --git a/models.py b/models.py index 2252b50..4a1885f 100644 --- a/models.py +++ b/models.py @@ -310,15 +310,15 @@ class GUIResult(models.Model): @property def display_action(self): if self.type == "block": - return "Block Break" if self.action == "0" else "Block Place" if self.action == "1" else "Interact/Used" + return "Block Break" if str(self.action) == "0" else "Block Place" if str(self.action) == "1" else "Interact/Used" if self.type == "chat": return "Chat" if self.type == "container": - return "Took from Container" if self.action == "0" else "Placed in Container" + return "Took from Container" if str(self.action) == "0" else "Placed in Container" if self.type == "command": return "Command" if self.type == "session": - return "Logout" if self.action == "0" else "Login" + return "Logout" if str(self.action) == "0" else "Login" if self.type == "sign": return "Sign" return self.action