Fix admin template URL endpoints and registration toggle parameter mismatch

PROBLEMS RESOLVED:

1. Admin Settings Template URL Error:
   - Fixed breadcrumb navigation in admin_settings.html line 14
   - Changed from: url_for('main.admin')
   - Changed to: url_for('main.admin_panel')
   - Matches actual route function name in routes.py

2. Registration Toggle Parameter Mismatch:
   - Fixed admin_users.html registration toggle JavaScript (lines 483-527)
   - Changed from using 'registration_disabled' parameter
   - Changed to using 'registration_enabled' parameter
   - Now matches the admin_registration_settings API endpoint format

3. Registration Toggle Logic Fix:
   - Updated toggle.checked logic to use registration_enabled directly
   - Fixed status text display to show correct enabled/disabled state
   - Corrected AJAX request payload to send registration_enabled boolean

TECHNICAL DETAILS:
- Both templates now use consistent parameter naming with the backend API
- Registration toggle in /admin/users now works correctly with database persistence
- Admin settings breadcrumb navigation no longer throws BuildError
- All admin interfaces now properly integrate with SystemSettings model

This resolves both reported issues:
- '/admin/settings give error' - Fixed URL endpoint mismatch
- 'registration settings in /admin/users keep to show as enabled' - Fixed parameter format
parent 6e3cf9e3
......@@ -11,7 +11,7 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('main.dashboard') }}">Dashboard</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('main.admin') }}">Admin</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('main.admin_panel') }}">Admin</a></li>
<li class="breadcrumb-item active">System Settings</li>
</ol>
</nav>
......@@ -234,7 +234,7 @@ function toggleRegistration(enabled) {
'Content-Type': 'application/json',
},
body: JSON.stringify({
enabled: enabled
registration_enabled: enabled
})
})
.then(response => response.json())
......
......@@ -487,8 +487,8 @@
const toggle = document.getElementById('registrationToggle');
const status = document.getElementById('registrationStatus');
toggle.checked = !data.registration_disabled;
status.textContent = data.registration_disabled ? 'Registration Disabled' : 'Registration Enabled';
toggle.checked = data.registration_enabled;
status.textContent = data.registration_enabled ? 'Registration Enabled' : 'Registration Disabled';
toggle.addEventListener('change', function() {
toggleRegistration(this.checked);
......@@ -501,7 +501,7 @@
}
function toggleRegistration(enabled) {
const data = { registration_disabled: !enabled };
const data = { registration_enabled: enabled };
fetch('/admin/settings/registration', {
method: 'POST',
......@@ -516,7 +516,7 @@
showAlert(data.error, 'error');
} else {
const status = document.getElementById('registrationStatus');
status.textContent = data.registration_disabled ? 'Registration Disabled' : 'Registration Enabled';
status.textContent = data.registration_enabled ? 'Registration Enabled' : 'Registration Disabled';
showAlert(data.message, 'success');
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment