BS5 Theme

This commit is contained in:
Aaron Kable
2023-10-07 08:20:22 +00:00
committed by Ariel Rin
parent 567d97f38a
commit 2e78aa5f26
161 changed files with 3198 additions and 1655 deletions

View File

@@ -1,7 +1,7 @@
from django.utils.translation import gettext_lazy as _
from allianceauth import hooks
from django.utils.translation import gettext_lazy as _
from .hooks import MenuItemHook
from ..menu.hooks import MenuItemHook
from .hooks import ServicesHook

View File

@@ -1,5 +1,5 @@
from django.urls import include, re_path
from string import Formatter
from django.urls import include, re_path
from typing import Iterable, Optional
from django.conf import settings
@@ -9,6 +9,11 @@ from django.urls import include, re_path
from django.utils.functional import cached_property
from allianceauth.hooks import get_hooks
from allianceauth.menu.hooks import MenuItemHook
from django.conf import settings
from django.urls import include, re_path
from django.core.exceptions import ObjectDoesNotExist
from django.utils.functional import cached_property
from .models import NameFormatConfig
@@ -136,26 +141,15 @@ class ServicesHook:
yield fn()
class MenuItemHook:
def __init__(self, text, classes, url_name, order=None, navactive=list([])):
self.text = text
self.classes = classes
self.url_name = url_name
self.template = 'public/menuitem.html'
self.order = order if order is not None else 9999
class MenuItemHook(MenuItemHook):
"""
MenuItemHook shim to allianceauth.menu.hooks
# count is an integer shown next to the menu item as badge when count != None
# apps need to set the count in their child class, e.g. in render() method
self.count = None
navactive = navactive or []
navactive.append(url_name)
self.navactive = navactive
def render(self, request):
return render_to_string(self.template,
{'item': self},
request=request)
:param MenuItemHook: _description_
:type MenuItemHook: _type_
"""
def __init_subclass__(cls) -> None:
return super().__init_subclass__()
class UrlHook:

View File

@@ -1,37 +1,34 @@
{% load i18n %}
<tr>
<td class="text-center">{% translate "Discord" %}</td>
<td class="text-center">
<div class="card text-center m-4" style="min-width: 18rem; min-height: 18rem;">
<div class="card-body ">
<h5 class="card-title ">{% translate "Discord" %}</h5>
<p class="card-text">{% if server_name %}{{ server_name }}{% else %}{% translate "Unlinked Server" %}{% endif %}</p>
<p class="card-text"><span class="badge {% if user_has_account %}bg-success{% else %}bg-warning{% endif %}">{% if user_has_account %}{% translate "Active" %}{% else %}{% translate "Disabled" %}{% endif %}</span></p>
<p class="card-text">
{% if not user_has_account %}
(not activated)
{% translate "(not activated)" %}
{% else %}
{{discord_username}}
{{ discord_username }}
{% endif %}
</td>
<td class="text-center">
{{server_name}}
</td>
<td class="text-center">
</p>
</div>
<div class="card-footer">
{% if not user_has_account %}
<a href="{% url 'discord:activate' %}" title="{% translate 'Join the Discord server' %}" class="btn btn-primary">
<span class="glyphicon glyphicon-ok"></span>
<span class="fas fa-check fa-fw"></span>
</a>
{% else %}
<a href="{% url 'discord:reset' %}" title="{% translate 'Leave- and rejoin the Discord Server (Reset)' %}" class="btn btn-warning">
<span class="glyphicon glyphicon-refresh"></span>
<span class="fas fa-sync fa-fw"></span>
</a>
<a href="{% url 'discord:deactivate' %}" title="{% translate 'Leave the Discord server' %}" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span>
<span class="fas fa-times fa-fw"></span>
</a>
{% endif %}
{% if request.user.is_superuser %}
<div class="text-center" style="padding-top:5px;">
<a type="button" id="btnLinkDiscordServer" class="btn btn-default" href="{% url 'discord:add_bot' %}">
{% translate "Link Discord Server" %}
</a>
</div>
<a type="button" id="btnLinkDiscordServer" class="btn btn-primary" href="{% url 'discord:add_bot' %}">
<span class="fas fa-link fa-fw"></span>
</a>
{% endif %}
</td>
</tr>
</div>
</div>

View File

@@ -1,10 +1,20 @@
{% extends "services/services_ctrl_base.html" %}
{% load i18n %}
<tr>
<td class="text-center">Discourse</td>
<td class="text-center">{{ char.character_name }}</td>
<td class="text-center"><a href="{{ DISCOURSE_URL }}">{{ DISCOURSE_URL }}</a></td>
<td class="text-center">
<a title="Go To Forums" class="btn btn-success" href="{{ DISCOURSE_URL }}"><span class="glyphicon glyphicon-arrow-right"></span></a>
</td>
</tr>
{% block title %}
{% translate "Discourse" %}
{% endblock %}
{% block url %}
<a href="{{ DISCOURSE_URL }}">{{ DISCOURSE_URL }}</a>
{% endblock %}
{% block user %}
Username: {{ char.character_name }}
{% endblock %}
{% block controls %}
<a title="Go To Forums" href="{{ DISCOURSE_URL }}" class="btn btn-success" title="Connect">
<span class="fas fa-arrow-right fa-fw"></span>
</a>
{% endblock %}

View File

@@ -1,28 +1,34 @@
<tr>
<td class="text-center">{{ service_name }}</td>
<td class="text-center">{{ username }}</td>
{% load i18n %}
<div class="card text-center m-4" style="min-width: 18rem; min-height: 18rem;">
<div class="card-body ">
<h5 class="card-title ">{{ service_name }}</h5>
<p class="card-text"><a href="mumble://{{ service_url }}">{{ service_url }}</a></p>
<p class="card-text"><span class="badge {% if username != '' %}bg-success{% else %}bg-warning{% endif %}">{% if username != '' %}Active{% else %}Disabled{% endif %}</span></p>
<p class="card-text">Username: <span class="badge bg-secondary text-end">{{ username }}</span></p>
</div>
<div class="card-footer">
{% if username == "" %}
<td class="text-center">{{ service_url }}</td>
<td class="text-center">
<a href="{% url 'mumble:activate' %}" title="Activate" class="btn btn-warning">
<span class="glyphicon glyphicon-ok"></span>
</a>
</td>
<a href="{% url 'mumble:activate' %}" title="Activate" class="btn btn-warning">
<span class="fas fa-check fa-fw"></span>
</a>
</td>
{% else %}
<td class="text-center"><a href="mumble://{{ connect_url }}">{{ service_url }}</a></td>
<td class="text-center">
<a href="{% url 'mumble:set_password' %}" title="Set Password" class="btn btn-warning">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<a href="{% url 'mumble:reset_password' %}" title="Reset Password" class="btn btn-primary">
<span class="glyphicon glyphicon-refresh"></span>
</a>
<a href="{% url 'mumble:deactivate' %}" title="Deactivate" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span>
</a>
<a href="mumble://{{ connect_url }}" class="btn btn-success" title="Connect">
<span class="glyphicon glyphicon-arrow-right"></span>
</a>
</td>
<a href="{% url 'mumble:set_password' %}" title="Set Password" class="btn btn-warning">
<span class="fas fa-edit fa-fw"></span>
</a>
<a href="{% url 'mumble:reset_password' %}" title="Reset Password" class="btn btn-primary">
<span class="fas fa-sync fa-fw"></span>
</a>
<a href="{% url 'mumble:deactivate' %}" title="Deactivate" class="btn btn-danger">
<span class="fas fa-times fa-fw"></span>
</a>
<a href="mumble://{{ connect_url }}" class="btn btn-success" title="Connect">
<span class="fas fa-arrow-right fa-fw"></span>
</a>
</td>
{% endif %}
</tr>
</div>
</div>

View File

@@ -5,7 +5,8 @@ from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _
from allianceauth import hooks
from allianceauth.services.hooks import ServicesHook, MenuItemHook
from allianceauth.menu.hooks import MenuItemHook
from allianceauth.services.hooks import ServicesHook
from .tasks import OpenfireTasks
from .urls import urlpatterns

View File

@@ -1,27 +1,39 @@
{% extends "services/services_ctrl_base.html" %}
{% load i18n %}
<tr>
<td class="text-center">Teamspeak 3</td>
<td class="text-center">{{ authinfo.teamspeak3_uid }}</td>
<td class="text-center"><a href="ts3server://{{ TEAMSPEAK3_PUBLIC_URL }}">{{ TEAMSPEAK3_PUBLIC_URL }}</a></td>
<td class="text-center">
{% if authinfo.teamspeak3_uid == "" %}
<a href="{% url 'teamspeak3:activate' %}" title="Activate" class="btn btn-warning">
<span class="glyphicon glyphicon-ok"></span>
</a>
{% else %}
<a href="{% url 'teamspeak3:verify' %}" title="Verify Client ID" class="btn btn-success">
<span class="glyphicon glyphicon-log-in"></span>
</a>
<a href="{% url 'teamspeak3:reset_perm' %}" title="Refresh Token" class="btn btn-primary">
<span class="glyphicon glyphicon-refresh"></span>
</a>
<a href="{% url 'teamspeak3:deactivate' %}" title="Deactivate" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span>
</a>
<a href="ts3server://{{ TEAMSPEAK3_PUBLIC_URL }}?nickname={{ authinfo.teamspeak3_uid }}" title="Connect" class="btn btn-success">
<span class="glyphicon glyphicon-arrow-right"></span>
</a>
{% block title %}
{% translate "Teamspeak 3" %}
{% endblock %}
{% block url %}
<a href="ts3server://{{ TEAMSPEAK3_PUBLIC_URL }}">{{ TEAMSPEAK3_PUBLIC_URL }}</a>
{% endblock %}
{% block active %}
<span class="badge {% if authinfo.teamspeak3_uid != '' %}bg-success{% else %}bg-warning{% endif %}">{% if authinfo.teamspeak3_uid != '' %}Active{% else %}Disabled{% endif %}</span>
{% endblock %}
{% block user %}
{{ authinfo.teamspeak3_uid }}
{% endblock %}
{% block controls %}
{% if authinfo.teamspeak3_uid == "" %}
<a href="{% url 'teamspeak3:activate' %}" title="Activate" class="btn btn-warning">
<span class="fas fa-check fa-fw"></span>
</a>
{% else %}
<a href="{% url 'teamspeak3:verify' %}" title="Verify Client ID" class="btn btn-success">
<span class="far fa-sign-in fa-fw"></span>
</a>
<a href="{% url 'teamspeak3:reset_perm' %}" title="Refresh Token" class="btn btn-primary">
<span class="fas fa-sync fa-fw"></span>
</a>
<a href="{% url 'teamspeak3:deactivate' %}" title="Deactivate" class="btn btn-danger">
<span class="fas fa-times fa-fw"></span>
</a>
<a href="ts3server://{{ TEAMSPEAK3_PUBLIC_URL }}?nickname={{ authinfo.teamspeak3_uid }}" title="Connect" class="btn btn-success">
<span class="fas fa-arrow-right fa-fw"></span>
</a>
{% endif %}
</td>
</tr>
{% endblock %}

View File

@@ -1,4 +1,4 @@
{% extends "allianceauth/base.html" %}
{% extends "allianceauth/base-bs5.html" %}
{% load bootstrap %}
{% load i18n %}

View File

@@ -1,29 +1,48 @@
{% extends "allianceauth/base.html" %}
{% extends "allianceauth/base-bs5.html" %}
{% load i18n %}
{% block page_title %}{% translate "Services Management" %}{% endblock page_title %}
{% block extra_css %}{% endblock extra_css %}
{% block header_nav_brand %}{% translate "Available Services" %}{% endblock header_nav_brand %}
{% block content %}
<div class="col-lg-12">
<h1 class="page-header text-center">{% translate "Available Services" %}</h1>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th class="text-center">{% translate "Service" %}</th>
<th class="text-center">{% translate "Username" %}</th>
<th class="text-center">{% translate "Domain" %}</th>
<th class="text-center">{% translate "Action" %}</th>
</tr>
</thead>
<tbody>
{% for svc in service_ctrls %}
{{ svc }}
{% endfor %}
</tbody>
</table>
<div class="d-flex p-2 bd-highlight justify-content-center flex-wrap">
{% for svc in service_ctrls %}
{{ svc }}
{% endfor %}
</div>
<div class="w-100 text-center">
<h4>Legend</h4>
<div class="d-inline-flex bd-highlight justify-content-center flex-wrap">
<div class="d-inline-flex m-3">
<a title="Activate" class="btn btn-warning">
<span class="fas fa-check fa-fw"></span>
</a>
<p class="m-2 p-0 align-self-center">{% translate "Click to activate the service for your user." %}</p>
</div>
<div class="d-inline-flex m-3">
<a title="Set Password" class="btn btn-warning">
<span class="fas fa-edit fa-fw"></span>
</a>
<p class="m-2 p-0 align-self-center">{% translate "Click to manually set your password." %}</p>
</div>
<div class="d-inline-flex m-3">
<a title="Reset Password" class="btn btn-primary">
<span class="fas fa-sync fa-fw"></span>
</a>
<p class="m-2 p-0 align-self-center">{% translate "Click to randomly generate your password." %}</p>
</div>
<div class="d-inline-flex m-3">
<a title="Deactivate" class="btn btn-danger">
<span class="fas fa-times fa-fw"></span>
</a>
<p class="m-2 p-0 align-self-center">{% translate "Click to deactivate the service for your user" %}</p>
</div>
</div>
<p class="m-2 p-0 align-self-center">{% translate "Some services provide different options. Hover over the buttons to see more." %}</p>
</div>
{% endblock content %}

View File

@@ -1,32 +1,44 @@
{% extends "services/services_ctrl_base.html" %}
{% load i18n %}
<tr>
<td class="text-center">{{ service_name }}</td>
<td class="text-center">{{ username }}</td>
<td class="text-center"><a href="{{ service_url }}">{{ service_url }}</a></td>
<td class="text-center">
{% if username == "" %}
{% if urls.auth_activate %}
<a href="{% url urls.auth_activate %}" title="Activate" class="btn btn-warning">
<span class="glyphicon glyphicon-ok"></span>
</a>
{% endif %}
{% else %}
{% if urls.auth_set_password %}
<a href="{% url urls.auth_set_password %}" title="Set Password" class="btn btn-warning">
<span class="glyphicon glyphicon-pencil"></span>
</a>
{% endif %}
{% if urls.auth_reset_password %}
<a href="{% url urls.auth_reset_password %}" title="Reset Password" class="btn btn-primary">
<span class="glyphicon glyphicon-refresh"></span>
</a>
{% endif %}
{% if urls.auth_deactivate %}
<a href="{% url urls.auth_deactivate %}" title="Deactivate" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span>
</a>
{% endif %}
{% block title %}
{{ service_name }}
{% endblock %}
{% block url %}
<a href="{{ service_url }}">{{ service_url }}</a>
{% endblock %}
{% block active %}
<span class="badge {% if username != '' %}bg-success{% else %}bg-warning{% endif %}">{% if username != '' %}Active{% else %}Disabled{% endif %}</span>
{% endblock %}
{% block user %}
Username: <span class="badge bg-secondary">{{ username }}</span>
{% endblock %}
{% block controls %}
{% if username == "" %}
{% if urls.auth_activate %}
<a href="{% url urls.auth_activate %}" title="Activate" class="btn btn-warning">
<span class="fas fa-check fa-fw"></span>
</a>
{% endif %}
</td>
</tr>
{% else %}
{% if urls.auth_set_password %}
<a href="{% url urls.auth_set_password %}" title="Set Password" class="btn btn-warning">
<span class="fas fa-edit fa-fw"></span>
</a>
{% endif %}
{% if urls.auth_reset_password %}
<a href="{% url urls.auth_reset_password %}" title="Reset Password" class="btn btn-primary">
<span class="fas fa-sync fa-fw"></span>
</a>
{% endif %}
{% if urls.auth_deactivate %}
<a href="{% url urls.auth_deactivate %}" title="Deactivate" class="btn btn-danger">
<span class="fas fa-times fa-fw"></span>
</a>
{% endif %}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,15 @@
{% load i18n %}
<div class="card text-center m-4" style="min-width: 18rem; min-height: 18rem">
<div class="card-body">
<h5 class="card-title">{% block title %}{% endblock title %}</h5>
<p class="card-text">{% block url %}{% endblock url %}</p>
<p class="card-text">
{% block active %}
<span class="badge bg-success">Active</span>
{% endblock active %}
</p>
<p class="card-text">{% block user %}{% endblock user %}</p>
{% block extra %}{% endblock extra %}
</div>
<div class="card-footer">{% block controls %}{% endblock controls %}</div>
</div>