From 52a65272ea3ff3056122cc328035c632d805f049 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Wed, 10 Oct 2018 21:42:55 -0500 Subject: [PATCH] Bug Fixes Fixed #7 Fixed #9 Fixed #11 --- external/stats.py | 10 ++++++++-- templates/minecraft_manager/external/base.html | 11 +---------- templates/minecraft_manager/external/stats_all.html | 12 ++++++++++++ .../minecraft_manager/external/stats_single.html | 10 ++++++++++ views.py | 8 ++------ 5 files changed, 33 insertions(+), 18 deletions(-) diff --git a/external/stats.py b/external/stats.py index 32922d7..94b8764 100644 --- a/external/stats.py +++ b/external/stats.py @@ -3,6 +3,8 @@ from minecraft_manager.models import Player from django.conf import settings stats_dir = os.path.join(settings.MINECRAFT_BASE_DIR, getattr(settings, "WORLD", "world"), "stats") +stats_filter = getattr(settings, 'STATS_FILTER', []) + def get_score(data): return data['score'] @@ -12,9 +14,13 @@ def get_stats(): stats = {} for filename in os.listdir(stats_dir): with open(stats_dir + "/" + filename) as json_file: - j = json.load(json_file)['stats'] + raw = json.load(json_file)['stats'] + clean = {} + for r in raw: + if not any(sf.lower() in r.lower() for sf in stats_filter): + clean[r] = raw[r] uuid = filename.replace(".json", "") - stats[uuid] = j + stats[uuid] = clean return stats diff --git a/templates/minecraft_manager/external/base.html b/templates/minecraft_manager/external/base.html index 8fa1dda..3819580 100644 --- a/templates/minecraft_manager/external/base.html +++ b/templates/minecraft_manager/external/base.html @@ -30,21 +30,12 @@ \ No newline at end of file diff --git a/templates/minecraft_manager/external/stats_all.html b/templates/minecraft_manager/external/stats_all.html index f2a886a..3116f58 100644 --- a/templates/minecraft_manager/external/stats_all.html +++ b/templates/minecraft_manager/external/stats_all.html @@ -43,4 +43,16 @@ {% endif %} +{% endblock %} +{% block script %} + var $dataTable = $("#dataTable"); + $dataTable.hide(); + $dataTable.DataTable({ + 'initComplete': function(settings, json) { + $dataTable.show(); + }, + 'lengthChange': false, + 'searching': false, + 'paging': false + }); {% endblock %} \ No newline at end of file diff --git a/templates/minecraft_manager/external/stats_single.html b/templates/minecraft_manager/external/stats_single.html index b6a4b0d..5326b6f 100644 --- a/templates/minecraft_manager/external/stats_single.html +++ b/templates/minecraft_manager/external/stats_single.html @@ -41,4 +41,14 @@ {% endif %} +{% endblock %} + +{% block script %} + var $dataTable = $("#dataTable"); + $dataTable.hide(); + $dataTable.DataTable({ + 'initComplete': function(settings, json) { + $dataTable.show(); + } + }); {% endblock %} \ No newline at end of file diff --git a/views.py b/views.py index 88dfdb1..f5a977a 100644 --- a/views.py +++ b/views.py @@ -268,7 +268,7 @@ class TicketInfo(View): request.user.username)) ticket.priority = post['priority'] if 'staff' in post and 'resolved' not in post: - if post['staff']: + if not ticket.staff or request.user.is_staff: staff = User.objects.get(id=post['staff']) if post['staff'] != str(getattr(ticket.staff, 'id', '-1')): if post['staff'] == str(request.user.id): @@ -277,11 +277,7 @@ class TicketInfo(View): else: API.discord_mcm( "Ticket #**{0}** was given to **{1}** by **{2}**".format(ticket.id, staff.username, request.user.username)) - else: - staff = None - API.discord_mcm( - "Ticket #**{0}** was unclaimed by **{1}**".format(ticket.id, request.user.username)) - ticket.staff = staff + ticket.staff = staff if 'resolved' in post: API.discord_mcm("Ticket #**{0}** was resolved by **{1}**".format(ticket.id, request.user.username)) ticket.resolved = True