Integrate DjangoCoreProtect (#39)

reminder^2
Etzelia 2019-09-30 21:42:55 +02:00 committed by Gitea
parent 8eb43887cd
commit d658f5fa85
6 changed files with 83 additions and 33 deletions

File diff suppressed because one or more lines are too long

View File

@ -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'),
) )

View File

@ -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 %}

View File

@ -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">

View File

@ -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

View File

@ -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())),