Merge branch 'master' of git.etztech.xyz:24CarrotCraft/MinecraftManagerDjango into reminder
commit
32000792fb
10
api/views.py
10
api/views.py
|
@ -46,7 +46,7 @@ def clean(model, data):
|
||||||
attr = d
|
attr = d
|
||||||
if '__' in d:
|
if '__' in d:
|
||||||
attr = d.split('__')[0]
|
attr = d.split('__')[0]
|
||||||
if hasattr(model, attr):
|
if hasattr(model, attr) and attr != "api":
|
||||||
cleaned[d] = data[d]
|
cleaned[d] = data[d]
|
||||||
return cleaned
|
return cleaned
|
||||||
|
|
||||||
|
@ -279,11 +279,13 @@ class PluginAPI(View):
|
||||||
json['message'] = "Updated {0}".format(post['username'])
|
json['message'] = "Updated {0}".format(post['username'])
|
||||||
elif "register" == keyword:
|
elif "register" == keyword:
|
||||||
player = Player.objects.get(uuid=post['uuid'])
|
player = Player.objects.get(uuid=post['uuid'])
|
||||||
|
password = mcm_api.generate_password()
|
||||||
if player.auth_user:
|
if player.auth_user:
|
||||||
json['status'] = False
|
player.auth_user.password = password
|
||||||
json['message'] = "You are already registered. To change your password, contact an Admin."
|
player.auth_user.is_active = True
|
||||||
|
player.auth_user.save()
|
||||||
|
json['message'] = password
|
||||||
else:
|
else:
|
||||||
password = mcm_api.generate_password()
|
|
||||||
user = User.objects.create_user(username=player.username.lower(), password=password)
|
user = User.objects.create_user(username=player.username.lower(), password=password)
|
||||||
user.save()
|
user.save()
|
||||||
player.auth_user = user
|
player.auth_user = user
|
||||||
|
|
|
@ -4,7 +4,8 @@ from django.contrib.auth.models import User
|
||||||
from django.db import close_old_connections
|
from django.db import close_old_connections
|
||||||
|
|
||||||
from minecraft_manager.api import api
|
from minecraft_manager.api import api
|
||||||
from minecraft_manager.bot.utils import get_application, build_info
|
from minecraft_manager.bot.utils import get_application
|
||||||
|
from minecraft_manager.utils import build_application
|
||||||
from minecraft_manager.models import Application, Player
|
from minecraft_manager.models import Application, Player
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,6 +80,7 @@ class Commands(commands.Cog):
|
||||||
except:
|
except:
|
||||||
is_id = False
|
is_id = False
|
||||||
|
|
||||||
|
application = None
|
||||||
if is_id:
|
if is_id:
|
||||||
application = get_application(key)
|
application = get_application(key)
|
||||||
if not application:
|
if not application:
|
||||||
|
@ -99,7 +101,7 @@ class Commands(commands.Cog):
|
||||||
if not found:
|
if not found:
|
||||||
await self.bot.discord_message(ctx.message.channel, "An exact Application could not be found. Try search instead.")
|
await self.bot.discord_message(ctx.message.channel, "An exact Application could not be found. Try search instead.")
|
||||||
return
|
return
|
||||||
await self.bot.discord_message(ctx.message.channel, build_info(application))
|
await self.bot.discord_message(ctx.message.channel, build_application(application))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def accept(self, ctx, app_id: int):
|
async def accept(self, ctx, app_id: int):
|
||||||
|
@ -164,7 +166,7 @@ class Commands(commands.Cog):
|
||||||
count = Application.objects.filter(username__icontains=search).count()
|
count = Application.objects.filter(username__icontains=search).count()
|
||||||
if count > 0:
|
if count > 0:
|
||||||
if count == 1:
|
if count == 1:
|
||||||
info = build_info(applications[0])
|
info = build_application(applications[0])
|
||||||
else:
|
else:
|
||||||
info = "**Found the following applications**"
|
info = "**Found the following applications**"
|
||||||
for app in applications:
|
for app in applications:
|
||||||
|
@ -177,7 +179,7 @@ class Commands(commands.Cog):
|
||||||
if count > 0:
|
if count > 0:
|
||||||
if count == 1:
|
if count == 1:
|
||||||
await self.bot.discord_message(ctx.message.channel, "**No applications matched, however there is a player match**")
|
await self.bot.discord_message(ctx.message.channel, "**No applications matched, however there is a player match**")
|
||||||
info = build_info(players[0].application)
|
info = build_application(players[0].application)
|
||||||
else:
|
else:
|
||||||
info = "**No applications matched, however there are player matches**"
|
info = "**No applications matched, however there are player matches**"
|
||||||
for player in players:
|
for player in players:
|
||||||
|
|
21
bot/utils.py
21
bot/utils.py
|
@ -1,23 +1,4 @@
|
||||||
import discord
|
from minecraft_manager.models import Application
|
||||||
from minecraft_manager.models import Application, Player
|
|
||||||
|
|
||||||
|
|
||||||
def build_info(application):
|
|
||||||
embed = discord.Embed(colour=discord.Colour(0x417505))
|
|
||||||
embed.set_thumbnail(
|
|
||||||
url="https://minotar.net/helm/{0}/100.png".format(application.username))
|
|
||||||
embed.add_field(name="Application ID", value=application.id)
|
|
||||||
embed.add_field(name="Username", value=application.username.replace("_", "\\_"))
|
|
||||||
embed.add_field(name="Age", value=application.age)
|
|
||||||
embed.add_field(name="Type of Player", value=application.player_type)
|
|
||||||
embed.add_field(name="Ever been banned", value=application.ever_banned)
|
|
||||||
if application.ever_banned:
|
|
||||||
embed.add_field(name="Reason for being banned", value=application.ever_banned_explanation)
|
|
||||||
embed.add_field(name="Reference", value=application.reference)
|
|
||||||
embed.add_field(name="Read the Rules", value=application.read_rules)
|
|
||||||
embed.add_field(name="Date", value=application.date_display)
|
|
||||||
embed.add_field(name="Status", value=application.status)
|
|
||||||
return embed
|
|
||||||
|
|
||||||
|
|
||||||
def get_application(app_id):
|
def get_application(app_id):
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -13,9 +13,6 @@ class MinecraftManagerUser(User):
|
||||||
class Meta:
|
class Meta:
|
||||||
proxy = True
|
proxy = True
|
||||||
permissions = (
|
permissions = (
|
||||||
('coreprotect_partial', 'Can use CoreProtect GUI except Command/Chat searches'),
|
|
||||||
('coreprotect_full', 'Can use full CoreProtect GUI'),
|
|
||||||
('coreprotect_activity', 'Can use CoreProtect Activity Monitor'),
|
|
||||||
('bots', 'Can use the bot control page'),
|
('bots', 'Can use the bot control page'),
|
||||||
('chat', 'Can use chat page'),
|
('chat', 'Can use chat page'),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{% extends "minecraft_manager/dashboard.html" %}
|
{% if show_gui and show_activity %}
|
||||||
{% load template_settings %}
|
<li class="dropdown">
|
||||||
{% block title %}CoreProtect GUI{% endblock %}
|
<a class="dropdown-toggle " href="#" role="button" data-toggle="dropdown" id="cpDropdown">CoreProtect</a>
|
||||||
{% block section %}
|
<ul class="dropdown-menu" aria-labelledby="cpDropdown">
|
||||||
<a href="{% template_settings 'COREPROTECT_WEB_URL' %}?username={{ user.username }}" target="_blank">Fullscreen</a>
|
<li><a target="_blank" href="{{ url_gui }}">Web GUI</a></li>
|
||||||
<iframe id="cpgui" width="100%" height="750px" src="{% template_settings 'COREPROTECT_WEB_URL' %}?username={{ user.username }}">Loading...</iframe>
|
<li><a target="_blank" href="{{ url_activity }}">Activity Monitor</a></li>
|
||||||
|
</ul>
|
||||||
<script>
|
</li>
|
||||||
var height = $(window).height();
|
{% elif show_gui %}
|
||||||
//$("#cpgui").height(height * .8);
|
<li><a target="_blank" class="dropdown-item btn" href="{{ url_gui }}">CoreProtect GUI</a></li>
|
||||||
</script>
|
{% elif show_activity %}
|
||||||
{% endblock section %}
|
<li><a target="_blank" class="dropdown-item btn" href="{{ url_activity }}">Activity Monitor</a></li>
|
||||||
|
{% endif %}
|
|
@ -3,6 +3,7 @@
|
||||||
{% load csrf_html %}
|
{% load csrf_html %}
|
||||||
{% load sidebar %}
|
{% load sidebar %}
|
||||||
{% load template_settings %}
|
{% load template_settings %}
|
||||||
|
{% load coreprotect %}
|
||||||
{% block bootstrap %}
|
{% block bootstrap %}
|
||||||
{% if user.usersettings.default_theme == 'DA' %}
|
{% if user.usersettings.default_theme == 'DA' %}
|
||||||
<link rel="stylesheet" href="{% static "minecraft_manager/css/bootswatch-darkly.css" %}">
|
<link rel="stylesheet" href="{% static "minecraft_manager/css/bootswatch-darkly.css" %}">
|
||||||
|
@ -23,21 +24,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="navbar" class="navbar-collapse collapse">
|
<div id="navbar" class="navbar-collapse collapse">
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
{% template_settings 'COREPROTECT_WEB_URL' as CPW %}
|
{% coreprotect %}
|
||||||
{% template_settings 'COREPROTECT_ACTIVITY_URL' as CPA %}
|
|
||||||
{% if CPW %}
|
|
||||||
{% if perms.auth.coreprotect_activity and CPA %}
|
|
||||||
<li class="dropdown">
|
|
||||||
<a class="dropdown-toggle " href="#" role="button" data-toggle="dropdown" id="cpDropdown">CoreProtect</a>
|
|
||||||
<ul class="dropdown-menu" aria-labelledby="cpDropdown">
|
|
||||||
<li><a target="_blank" href="{{ CPW }}">Web GUI</a></li>
|
|
||||||
<li><a target="_blank" href="{{ CPA }}">Activity Monitor</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
{% elif perms.auth.coreprotect_partial or perms.auth.coreprotect_full %}
|
|
||||||
<li><a target="_blank" class="dropdown-item btn" href="{{ CPW }}">CoreProtect</a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a class="dropdown-toggle " href="#" role="button" data-toggle="dropdown" id="accountDropdown">{{ user.username }}</a>
|
<a class="dropdown-toggle " href="#" role="button" data-toggle="dropdown" id="accountDropdown">{{ user.username }}</a>
|
||||||
<ul class="dropdown-menu" role="menu" aria-labelledby="accountDropdown">
|
<ul class="dropdown-menu" role="menu" aria-labelledby="accountDropdown">
|
||||||
|
|
|
@ -3,22 +3,37 @@
|
||||||
{% block title %}Overview{% endblock %}
|
{% block title %}Overview{% endblock %}
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<script src="{% static 'minecraft_manager/js/chart.min.js' %}"></script>
|
<script src="{% static 'minecraft_manager/js/chart.min.js' %}"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$(".staff-inactive").hide();
|
||||||
|
$("#active-only").change(function() {
|
||||||
|
if ($(this)[0].checked) {
|
||||||
|
$(".staff-inactive").hide();
|
||||||
|
} else {
|
||||||
|
$(".staff-inactive").show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block section %}
|
{% block section %}
|
||||||
<div id="content">
|
<div id="content">
|
||||||
{% if request.user.is_staff %}
|
{% if request.user.is_staff %}
|
||||||
<div class="panel panel-danger">
|
<div class="panel panel-danger">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h4><span class="label label-danger">Admin Area</span></h4>
|
<h4><span class="label label-danger">Admin Area</span></h4>
|
||||||
<h3>Resolved Tickets</h3>
|
<h3>Resolved Tickets</h3>
|
||||||
<div class="row">
|
<label>Active Only
|
||||||
{% for staff in data.resolved %}
|
<input id="active-only" type="checkbox" checked/>
|
||||||
<div class="col-xs-6 col-md-4">
|
</label>
|
||||||
<p><span class="label label-{% if staff.active %}success{% else %}danger{% endif %}">{% if staff.active %}Active{% else %}Inactive{% endif %}</span> {{ staff.username }}: {{ staff.tickets }}</p>
|
<div class="row">
|
||||||
|
{% for staff in data.resolved %}
|
||||||
|
<div class="col-xs-6 col-md-4{% if not staff.active %} staff-inactive{% endif %}">
|
||||||
|
<p><span class="label label-{% if staff.active %}success{% else %}danger{% endif %}">{% if staff.active %}Active{% else %}Inactive{% endif %}</span> {{ staff.username }}: {{ staff.tickets }}</p>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<hr/>
|
<hr/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
from django.template import Library
|
||||||
|
from django.shortcuts import reverse
|
||||||
|
|
||||||
|
register = Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.inclusion_tag('minecraft_manager/coreprotect.html', takes_context=True)
|
||||||
|
def coreprotect(context):
|
||||||
|
user = context.get("user", None)
|
||||||
|
data = {"show_gui": False, "show_activity": False, "url_gui": "", "url_activity": ""}
|
||||||
|
if user:
|
||||||
|
try:
|
||||||
|
data["show_gui"] = user.has_perm("django_coreprotect.gui")
|
||||||
|
data["url_gui"] = reverse("coreprotect_gui")
|
||||||
|
data["show_activity"] = user.has_perm("django_coreprotect.activity")
|
||||||
|
data["url_activity"] = reverse("coreprotect_activity")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return data
|
3
urls.py
3
urls.py
|
@ -8,9 +8,6 @@ urlpatterns = [
|
||||||
#Dashboard
|
#Dashboard
|
||||||
url(r'^dashboard/overview/$', login_required(mcm.Overview.as_view()), name="overview"),
|
url(r'^dashboard/overview/$', login_required(mcm.Overview.as_view()), name="overview"),
|
||||||
url(r'^dashboard/ban/$', login_required(mcm.Ban.as_view()), name="ban"),
|
url(r'^dashboard/ban/$', login_required(mcm.Ban.as_view()), name="ban"),
|
||||||
#CoreProtect
|
|
||||||
url(r'^dashboard/coreprotect/$', login_required(mcm.CoreProtect.as_view()), name="coreprotect"),
|
|
||||||
url(r'^dashboard/activity/$', login_required(mcm.Activity.as_view()), name="activity"),
|
|
||||||
#Alerts
|
#Alerts
|
||||||
url(r'^dashboard/alert/$', login_required(mcm.Alert.as_view()), name="alert"),
|
url(r'^dashboard/alert/$', login_required(mcm.Alert.as_view()), name="alert"),
|
||||||
url(r'^dashboard/alert/(?P<alert_id>[0-9]{1,5})/$', login_required(mcm.AlertInfo.as_view())),
|
url(r'^dashboard/alert/(?P<alert_id>[0-9]{1,5})/$', login_required(mcm.AlertInfo.as_view())),
|
||||||
|
|
1
utils.py
1
utils.py
|
@ -38,6 +38,7 @@ def build_application(application):
|
||||||
embed.add_field(name="Read the Rules", value=application.read_rules)
|
embed.add_field(name="Read the Rules", value=application.read_rules)
|
||||||
embed.add_field(name="Date", value=application.date_display)
|
embed.add_field(name="Date", value=application.date_display)
|
||||||
embed.add_field(name="Status", value=application.status)
|
embed.add_field(name="Status", value=application.status)
|
||||||
|
embed.add_field(name="Link", value="{}".format(url_path(settings.MCM_BASE_LINK, 'dashboard/application', application.id)))
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue