forked from Minecraft/minecraft_manager
parent
c8c8e5eeda
commit
52a65272ea
|
@ -3,6 +3,8 @@ from minecraft_manager.models import Player
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
stats_dir = os.path.join(settings.MINECRAFT_BASE_DIR, getattr(settings, "WORLD", "world"), "stats")
|
stats_dir = os.path.join(settings.MINECRAFT_BASE_DIR, getattr(settings, "WORLD", "world"), "stats")
|
||||||
|
stats_filter = getattr(settings, 'STATS_FILTER', [])
|
||||||
|
|
||||||
|
|
||||||
def get_score(data):
|
def get_score(data):
|
||||||
return data['score']
|
return data['score']
|
||||||
|
@ -12,9 +14,13 @@ def get_stats():
|
||||||
stats = {}
|
stats = {}
|
||||||
for filename in os.listdir(stats_dir):
|
for filename in os.listdir(stats_dir):
|
||||||
with open(stats_dir + "/" + filename) as json_file:
|
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", "")
|
uuid = filename.replace(".json", "")
|
||||||
stats[uuid] = j
|
stats[uuid] = clean
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,21 +30,12 @@
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var $dataTable = $("#dataTable");
|
|
||||||
if ($dataTable.length) {
|
|
||||||
$dataTable.hide();
|
|
||||||
$dataTable.DataTable({
|
|
||||||
'initComplete': function(settings, json) {
|
|
||||||
$dataTable.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var $filter = $("#filter");
|
var $filter = $("#filter");
|
||||||
if ($filter.length) {
|
if ($filter.length) {
|
||||||
$("#stats").filterByText($filter);
|
$("#stats").filterByText($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
{% block script %}{% endblock %}
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
|
@ -43,4 +43,16 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
{% block script %}
|
||||||
|
var $dataTable = $("#dataTable");
|
||||||
|
$dataTable.hide();
|
||||||
|
$dataTable.DataTable({
|
||||||
|
'initComplete': function(settings, json) {
|
||||||
|
$dataTable.show();
|
||||||
|
},
|
||||||
|
'lengthChange': false,
|
||||||
|
'searching': false,
|
||||||
|
'paging': false
|
||||||
|
});
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -41,4 +41,14 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
var $dataTable = $("#dataTable");
|
||||||
|
$dataTable.hide();
|
||||||
|
$dataTable.DataTable({
|
||||||
|
'initComplete': function(settings, json) {
|
||||||
|
$dataTable.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
{% endblock %}
|
{% endblock %}
|
8
views.py
8
views.py
|
@ -268,7 +268,7 @@ class TicketInfo(View):
|
||||||
request.user.username))
|
request.user.username))
|
||||||
ticket.priority = post['priority']
|
ticket.priority = post['priority']
|
||||||
if 'staff' in post and 'resolved' not in post:
|
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'])
|
staff = User.objects.get(id=post['staff'])
|
||||||
if post['staff'] != str(getattr(ticket.staff, 'id', '-1')):
|
if post['staff'] != str(getattr(ticket.staff, 'id', '-1')):
|
||||||
if post['staff'] == str(request.user.id):
|
if post['staff'] == str(request.user.id):
|
||||||
|
@ -277,11 +277,7 @@ class TicketInfo(View):
|
||||||
else:
|
else:
|
||||||
API.discord_mcm(
|
API.discord_mcm(
|
||||||
"Ticket #**{0}** was given to **{1}** by **{2}**".format(ticket.id, staff.username, request.user.username))
|
"Ticket #**{0}** was given to **{1}** by **{2}**".format(ticket.id, staff.username, request.user.username))
|
||||||
else:
|
ticket.staff = staff
|
||||||
staff = None
|
|
||||||
API.discord_mcm(
|
|
||||||
"Ticket #**{0}** was unclaimed by **{1}**".format(ticket.id, request.user.username))
|
|
||||||
ticket.staff = staff
|
|
||||||
if 'resolved' in post:
|
if 'resolved' in post:
|
||||||
API.discord_mcm("Ticket #**{0}** was resolved by **{1}**".format(ticket.id, request.user.username))
|
API.discord_mcm("Ticket #**{0}** was resolved by **{1}**".format(ticket.id, request.user.username))
|
||||||
ticket.resolved = True
|
ticket.resolved = True
|
||||||
|
|
Loading…
Reference in New Issue