Compare commits

..

5 Commits

Author SHA1 Message Date
jolheiser fd3ffa6857
Fix coords clause
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2022-02-12 09:38:47 -06:00
jolheiser e1b3319247
Fix connection import
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2022-02-12 09:28:56 -06:00
jolheiser e3b0194ebd Fix coords and re-add presets (#4)
Co-authored-by: Etzelia <etzelia@hotmail.com>
Reviewed-on: #4
Co-authored-by: jolheiser <john.olheiser@gmail.com>
Co-committed-by: jolheiser <john.olheiser@gmail.com>
2022-02-11 03:20:48 +00:00
Etzelia e5160f3839 Check world instead of X because of false-y values (#3)
Check world instead of X because of false-y values

Signed-off-by: Etzelia <etzelia@hotmail.com>

Reviewed-on: https://git.canopymc.net/Canopy/django_coreprotect/pulls/3
Co-Authored-By: Etzelia <etzelia@hotmail.com>
Co-Committed-By: Etzelia <etzelia@hotmail.com>
2021-07-17 01:56:00 +00:00
Etzelia fbd29e2c70 concat (#1)
Fix concatenation for MySQL

Signed-off-by: Etzelia <etzelia@hotmail.com>

Add block clause (#1)

Change UNION to UNION ALL

Change action to compare with strings

Improve LIKE query

Signed-off-by: Etzelia <etzelia@hotmail.com>

Try to prevent corrupt activity

Signed-off-by: Etzelia <etzelia@hotmail.com>

Update user in activity query

Signed-off-by: Etzelia <etzelia@hotmail.com>

Convert to HAVING

Signed-off-by: Etzelia <etzelia@hotmail.com>

Escape percent signs in raw SQL

Signed-off-by: Etzelia <etzelia@hotmail.com>

Convert id to rowid

Signed-off-by: Etzelia <etzelia@hotmail.com>

New migration

Signed-off-by: Etzelia <etzelia@hotmail.com>

Add activity pages

Signed-off-by: Etzelia <etzelia@hotmail.com>

Finish pagination

Re-work permissions (and test)
Move form methods to separate file

Signed-off-by: Etzelia <etzelia@hotmail.com>

Start pagination

SQL is finished

Signed-off-by: Etzelia <etzelia@hotmail.com>

Half SQL completed

Signed-off-by: Etzelia <etzelia@hotmail.com>

Move to Bulma
Start UI work

Signed-off-by: Etzelia <etzelia@hotmail.com>

More work

Signed-off-by: Etzelia <etzelia@hotmail.com>

Add migration

Signed-off-by: Etzelia <etzelia@hotmail.com>

More work

Signed-off-by: Etzelia <etzelia@hotmail.com>

Initial local commit

Signed-off-by: Etzelia <etzelia@hotmail.com>

Reviewed-on: https://git.birbmc.com/BirbMC/django_coreprotect/pulls/1
Co-Authored-By: Etzelia <etzelia@hotmail.com>
Co-Committed-By: Etzelia <etzelia@hotmail.com>
2021-03-16 02:02:17 +00:00
2 changed files with 14 additions and 7 deletions

19
gui.py
View File

@ -1,5 +1,7 @@
from datetime import datetime
from django.db import connection
from django_coreprotect.models import CoWorld, GUIResult
from django_coreprotect.utils import safe_int, checkbox, time_to_form
@ -105,12 +107,14 @@ def gui_results(form):
coords = []
radius = form.radius if form.radius else "0"
if form.x:
coords.append(" AND x BETWEEN {0} - {1} AND {0} + {1}".format(form.x, radius))
coords.append(" x BETWEEN {0} - {1} AND {0} + {1}".format(form.x, radius))
if form.y:
coords.append(" AND y BETWEEN {0} - {1} AND {0} + {1}".format(form.y, radius))
coords.append(" y BETWEEN {0} - {1} AND {0} + {1}".format(form.y, radius))
if form.z:
coords.append(" AND z BETWEEN {0} - {1} AND {0} + {1}".format(form.z, radius))
coords_clause = " AND ".join(coords)
coords.append(" z BETWEEN {0} - {1} AND {0} + {1}".format(form.z, radius))
coords_clause = ""
if coords:
coords_clause = " AND ({})".format(" AND ".join(coords))
players = []
players_clause = ""
@ -183,8 +187,11 @@ def gui_results(form):
# Chest Use
if form.chest_use:
concat = 'CONCAT(cc.amount, " ", cmm.material)'
if connection.vendor == "sqlite":
concat = 'cc.amount || " " || cmm.material'
queries.append('''SELECT
0 AS id, "container" AS type, cc.time AS unix, cu.user AS player, cc.action, cc.amount || " " || cmm.material AS data, cc.x, cc.y, cc.z, cw.world
0 AS id, "container" AS type, cc.time AS unix, cu.user AS player, cc.action, {concat} AS data, cc.x, cc.y, cc.z, cw.world
FROM co_container cc
JOIN co_user cu ON cc.user = cu.rowid
JOIN co_material_map cmm ON cc.type = cmm.rowid
@ -195,7 +202,7 @@ def gui_results(form):
{coords}
{blocks}
{time}
'''.format(worlds=worlds_clause, players=players_clause, coords=coords_clause, blocks=blocks_clause, time=time_clause))
'''.format(concat=concat, worlds=worlds_clause, players=players_clause, coords=coords_clause, blocks=blocks_clause, time=time_clause))
# Commands
if form.command:

View File

@ -13,7 +13,7 @@
</thead>
<tbody>
{% for result in results %}
<tr {% if result.x %}class="click-row" data-prompt="/tp {{ result.x }} {{ result.y }} {{ result.z }}"{% endif %}>
<tr {% if result.world %}class="click-row" data-prompt="/tp {{ result.x }} {{ result.y }} {{ result.z }}"{% endif %}>
<td>{{ result.display_time }}</td>
<td>{{ result.player }}</td>
<td>{{ result.display_action }}</td>