mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-03-15 13:36:18 +00:00
enhance forms and views with PrependedText for better input clarity; update tab order in gatekeeper list
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import pyotp
|
import pyotp
|
||||||
|
from crispy_forms.bootstrap import PrependedText
|
||||||
from crispy_forms.helper import FormHelper
|
from crispy_forms.helper import FormHelper
|
||||||
from crispy_forms.layout import Layout, Submit, HTML, Div, Field
|
from crispy_forms.layout import Layout, Submit, HTML, Div, Field
|
||||||
from django import forms
|
from django import forms
|
||||||
@@ -210,7 +211,7 @@ class GatekeeperIPAddressForm(forms.ModelForm):
|
|||||||
),
|
),
|
||||||
Div(
|
Div(
|
||||||
Div('address', css_class='col-xl-6'),
|
Div('address', css_class='col-xl-6'),
|
||||||
Div('prefix_length', css_class='col-xl-6'),
|
Div(PrependedText('prefix_length', '/'), css_class='col-xl-6'),
|
||||||
css_class='row'
|
css_class='row'
|
||||||
),
|
),
|
||||||
Div(
|
Div(
|
||||||
@@ -245,7 +246,7 @@ class AuthMethodAllowedDomainForm(forms.ModelForm):
|
|||||||
self.helper.layout = Layout(
|
self.helper.layout = Layout(
|
||||||
Div(
|
Div(
|
||||||
Div('auth_method', css_class='col-md-6'),
|
Div('auth_method', css_class='col-md-6'),
|
||||||
Div('domain', css_class='col-md-6'),
|
Div(PrependedText('domain', '@'), css_class='col-xl-6'),
|
||||||
css_class='row'
|
css_class='row'
|
||||||
),
|
),
|
||||||
Div(
|
Div(
|
||||||
|
|||||||
@@ -22,15 +22,14 @@ def view_gatekeeper_list(request):
|
|||||||
if not UserAcl.objects.filter(user=request.user).filter(user_level__gte=20).exists():
|
if not UserAcl.objects.filter(user=request.user).filter(user_level__gte=20).exists():
|
||||||
return render(request, 'access_denied.html', {'page_title': _('Access Denied')})
|
return render(request, 'access_denied.html', {'page_title': _('Access Denied')})
|
||||||
|
|
||||||
|
active_tab = request.GET.get('tab', 'auth_methods')
|
||||||
|
auth_methods = AuthMethod.objects.all().order_by('name')
|
||||||
users = GatekeeperUser.objects.all().order_by('username')
|
users = GatekeeperUser.objects.all().order_by('username')
|
||||||
groups = GatekeeperGroup.objects.all().order_by('name')
|
groups = GatekeeperGroup.objects.all().order_by('name')
|
||||||
auth_methods = AuthMethod.objects.all().order_by('name')
|
|
||||||
auth_domains = AuthMethodAllowedDomain.objects.all().order_by('domain')
|
auth_domains = AuthMethodAllowedDomain.objects.all().order_by('domain')
|
||||||
auth_emails = AuthMethodAllowedEmail.objects.all().order_by('email')
|
auth_emails = AuthMethodAllowedEmail.objects.all().order_by('email')
|
||||||
auth_ips = GatekeeperIPAddress.objects.all().order_by('address')
|
auth_ips = GatekeeperIPAddress.objects.all().order_by('address')
|
||||||
|
|
||||||
tab = request.GET.get('tab', 'users')
|
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'users': users,
|
'users': users,
|
||||||
'groups': groups,
|
'groups': groups,
|
||||||
@@ -38,7 +37,7 @@ def view_gatekeeper_list(request):
|
|||||||
'auth_domains': auth_domains,
|
'auth_domains': auth_domains,
|
||||||
'auth_emails': auth_emails,
|
'auth_emails': auth_emails,
|
||||||
'auth_ips': auth_ips,
|
'auth_ips': auth_ips,
|
||||||
'active_tab': tab,
|
'active_tab': active_tab,
|
||||||
}
|
}
|
||||||
return render(request, 'gatekeeper/gatekeeper_list.html', context)
|
return render(request, 'gatekeeper/gatekeeper_list.html', context)
|
||||||
|
|
||||||
@@ -380,10 +379,29 @@ def view_manage_gatekeeper_ip(request):
|
|||||||
messages.success(request, _('IP Address saved successfully.'))
|
messages.success(request, _('IP Address saved successfully.'))
|
||||||
return redirect(cancel_url)
|
return redirect(cancel_url)
|
||||||
|
|
||||||
|
form_description = {
|
||||||
|
'size': 'col-lg-6',
|
||||||
|
'content': _('''
|
||||||
|
<h5>IP Address List</h5>
|
||||||
|
<p>Manage specific IP addresses or networks that are allowed or denied access when using the IP Address List authentication method.</p>
|
||||||
|
|
||||||
|
<h5>IP Address & Prefix</h5>
|
||||||
|
<p>Enter a single IP address (e.g., 192.168.1.50) or a network address. Use the prefix length for CIDR notation (e.g., 24 for a /24 network). Leave prefix blank for a single host (/32 for IPv4, /128 for IPv6).</p>
|
||||||
|
|
||||||
|
<h5>Action</h5>
|
||||||
|
<p><strong>Allow</strong>: Grants access to the specified IP/network.<br>
|
||||||
|
<strong>Deny</strong>: Specifically blocks access from the specified IP/network.</p>
|
||||||
|
|
||||||
|
<h5>Description</h5>
|
||||||
|
<p>An optional note to help identify this entry (e.g., "Office Network", "Blocked Attacker").</p>
|
||||||
|
''')
|
||||||
|
}
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'form': form,
|
'form': form,
|
||||||
'title': title,
|
'title': title,
|
||||||
'page_title': title,
|
'page_title': title,
|
||||||
|
'form_description': form_description,
|
||||||
}
|
}
|
||||||
return render(request, 'generic_form.html', context)
|
return render(request, 'generic_form.html', context)
|
||||||
|
|
||||||
|
|||||||
@@ -6,18 +6,18 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link {% if active_tab == 'users' or active_tab == 'groups' %}active{% endif %}"
|
|
||||||
href="{% url 'gatekeeper_list' %}?tab=users" role="tab">
|
|
||||||
{% trans 'Gatekeeper Users' %}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link {% if active_tab == 'auth_methods' %}active{% endif %}"
|
<a class="nav-link {% if active_tab == 'auth_methods' %}active{% endif %}"
|
||||||
href="{% url 'gatekeeper_list' %}?tab=auth_methods" role="tab">
|
href="{% url 'gatekeeper_list' %}?tab=auth_methods" role="tab">
|
||||||
{% trans 'Authentication Methods' %}
|
{% trans 'Authentication Methods' %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link {% if active_tab == 'users' or active_tab == 'groups' %}active{% endif %}"
|
||||||
|
href="{% url 'gatekeeper_list' %}?tab=users" role="tab">
|
||||||
|
{% trans 'Gatekeeper Users' %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link {% if active_tab == 'allowed_identities' %}active{% endif %}"
|
<a class="nav-link {% if active_tab == 'allowed_identities' %}active{% endif %}"
|
||||||
href="{% url 'gatekeeper_list' %}?tab=allowed_identities" role="tab">
|
href="{% url 'gatekeeper_list' %}?tab=allowed_identities" role="tab">
|
||||||
|
|||||||
Reference in New Issue
Block a user