Add configuration page: implement ConfigurationForm, update views, templates, and routes to enable superusers to manage club settings and toggle features using django-waffle.
This commit is contained in:
@@ -4,17 +4,18 @@
|
||||
|
||||
{% block sidebar %}
|
||||
{% url "backend:members:list" as members_list %}
|
||||
{% url "backend:configuration" as configuration %}
|
||||
|
||||
{% has_perm "members.member_manager" request.user as is_member_manager %}
|
||||
|
||||
{% if is_member_manager %}
|
||||
<li class="menu-title">Members</li>
|
||||
<li><a href="{{ members_list }}" class="menu-item {% if members_list in request.path %}menu-active{% endif %}" data-menu="members" hx-get="{% url "backend:members:list" %}" hx-target="#content"><i class="fa-solid fa-users"></i> Members</a></li>
|
||||
<li><a href="{{ members_list }}" class="menu-item {% if members_list in request.path %}menu-active{% endif %}" data-menu="members" hx-get="{% url "backend:members:list" %}" hx-target="#content"><i class="fa-solid fa-users"></i> Members</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<li class="menu-title mt-4">Navigation</li>
|
||||
<li><a href="#"><i class="fa-solid fa-house"></i> Dashboard</a></li>
|
||||
<li><a href="#"><i class="fa-solid fa-calendar"></i> Calendar</a></li>
|
||||
<li><a href="#"><i class="fa-solid fa-users"></i> Members</a></li>
|
||||
<li><a href="#"><i class="fa-solid fa-gear"></i> Settings</a></li>
|
||||
{% if request.user.is_superuser %}
|
||||
<li class="menu-title mt-4">Configuration</li>
|
||||
<li><a href="{% url "backend:configuration" %}" class="menu-item {% if configuration in request.path %}menu-active{% endif %}" data-menu="configuration"><i class="fa-solid fa-screwdriver-wrench"></i> Settings</a></li>
|
||||
{% endif %}
|
||||
{% endblock sidebar %}
|
||||
76
templates/backend/configuration.html
Normal file
76
templates/backend/configuration.html
Normal file
@@ -0,0 +1,76 @@
|
||||
{% extends "backend/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load form_field %}
|
||||
{% load avatar %}
|
||||
{% load waffle_tags %}
|
||||
|
||||
{% block content %}
|
||||
{% partialdef content inline %}
|
||||
<h1 class="page-title">{% translate "Configuration" %}</h1>
|
||||
|
||||
{% blocktranslate %}
|
||||
<article class="prose text-justify max-w-none">
|
||||
<p>Use the below options to configure your TeamForge instance. Options marked as required will need to be set in order for TeamForge to function properly.</p>
|
||||
<p>You can also use this form to enable or disable certain pieces of functionality for your users.</p>
|
||||
</article>
|
||||
{% endblocktranslate %}
|
||||
|
||||
{% if form.errors %}
|
||||
<div class="flex flex-row items-center gap-2 p-2 m-4 rounded-lg bg-error">
|
||||
<i class="mr-2 text-3xl fa-solid fa-exclamation-triangle text-error-content"></i>
|
||||
|
||||
<div class="flex flex-col">
|
||||
<div class="mb-1 font-semibold text-error-content">{% translate "Error" %}</div>
|
||||
<div class="text-sm text-error-content">{% translate "Please correct the errors below before saving again." %}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
<h2 class="page-subtitle">{% translate "General configuration" %}</h2>
|
||||
<div class="grid grid-cols-1 gap-4 mt-2 lg:grid-cols-2 xl:grid-cols-3">
|
||||
{% form_field form.club_name %}
|
||||
{% form_field form.club_location %}
|
||||
{% form_field form.club_logo %}
|
||||
</div>
|
||||
|
||||
<h2 class="page-subtitle">{% translate "Module configuration" %}</h2>
|
||||
<div class="grid grid-cols-1 gap-1 mt-2 gap-x-4 lg:grid-cols-3 xl:grid-cols-5">
|
||||
<div class="flex flex-row gap-2">
|
||||
<span class="font-semibold">{% translate "Teams" %}</span>
|
||||
{% form_field form.enable_teams show_label=False show_as_toggle=True %}
|
||||
|
||||
{% switch "TF_TEAMS" %}
|
||||
<div class="badge badge-success"><i class="fa-solid fa-check"></i>{% translate "Enabled" %}</div>
|
||||
{% else %}
|
||||
<div class="badge badge-error"><i class="fa-solid fa-times"></i>{% translate "Disabled" %}</div>
|
||||
{% endswitch %}
|
||||
</div>
|
||||
|
||||
<div></div>
|
||||
|
||||
<div class="flex flex-row gap-2">
|
||||
<span class="font-semibold">{% translate "Activities" %}</span>
|
||||
{% form_field form.enable_activities show_label=False show_as_toggle=True %}
|
||||
|
||||
{% switch "TF_ACTIVITIES" %}
|
||||
<div class="badge badge-success"><i class="fa-solid fa-check"></i>{% translate "Enabled" %}</div>
|
||||
{% else %}
|
||||
<div class="badge badge-error"><i class="fa-solid fa-times"></i>{% translate "Disabled" %}</div>
|
||||
{% endswitch %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="w-full mt-8 btn btn-neutral" type="submit">
|
||||
<i class="fa-solid fa-floppy-disk"></i>{% translate "Save" %}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
new Choices(document.querySelector("#id_family_members"));
|
||||
</script>
|
||||
{% endpartialdef content %}
|
||||
{% endblock content %}
|
||||
Reference in New Issue
Block a user