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
|
||||
from crispy_forms.bootstrap import PrependedText
|
||||
from crispy_forms.helper import FormHelper
|
||||
from crispy_forms.layout import Layout, Submit, HTML, Div, Field
|
||||
from django import forms
|
||||
@@ -210,7 +211,7 @@ class GatekeeperIPAddressForm(forms.ModelForm):
|
||||
),
|
||||
Div(
|
||||
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'
|
||||
),
|
||||
Div(
|
||||
@@ -245,7 +246,7 @@ class AuthMethodAllowedDomainForm(forms.ModelForm):
|
||||
self.helper.layout = Layout(
|
||||
Div(
|
||||
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'
|
||||
),
|
||||
Div(
|
||||
|
||||
@@ -21,16 +21,15 @@ def view_gatekeeper_list(request):
|
||||
"""Main list view containing tabs for Users, Groups, and Auth Methods"""
|
||||
if not UserAcl.objects.filter(user=request.user).filter(user_level__gte=20).exists():
|
||||
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')
|
||||
groups = GatekeeperGroup.objects.all().order_by('name')
|
||||
auth_methods = AuthMethod.objects.all().order_by('name')
|
||||
auth_domains = AuthMethodAllowedDomain.objects.all().order_by('domain')
|
||||
auth_emails = AuthMethodAllowedEmail.objects.all().order_by('email')
|
||||
auth_ips = GatekeeperIPAddress.objects.all().order_by('address')
|
||||
|
||||
tab = request.GET.get('tab', 'users')
|
||||
|
||||
context = {
|
||||
'users': users,
|
||||
'groups': groups,
|
||||
@@ -38,7 +37,7 @@ def view_gatekeeper_list(request):
|
||||
'auth_domains': auth_domains,
|
||||
'auth_emails': auth_emails,
|
||||
'auth_ips': auth_ips,
|
||||
'active_tab': tab,
|
||||
'active_tab': active_tab,
|
||||
}
|
||||
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.'))
|
||||
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 = {
|
||||
'form': form,
|
||||
'title': title,
|
||||
'page_title': title,
|
||||
'form_description': form_description,
|
||||
}
|
||||
return render(request, 'generic_form.html', context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user