Open the role confirmation


Drag the divider or use the arrow keys to compare themes.
Django Chassis 1.0.23 · training site with Russian UI
- The dialog names the role transition.
- The operator confirms the proposed access change.
How to add it
On another user’s card, open Change role as an active staff superuser. The built-in dialog submits the selected transition and confirmation in a CSRF-protected POST. Add this check to src/apps/admins/tests/test_user_accounts.py for the standard Django user model and cookie-based CSRF configuration used by the demo.
src/apps/admins/tests/test_user_accounts.py
import pytest
from django.conf import settings
from django.contrib.auth.models import User
from django.test import Client
from django.urls import reverse
from django_chassis.enums import AccountActionType
from django_chassis.models import AccountAction
@pytest.mark.django_db
def test_confirm_staff_role() -> None:
operator = User.objects.create_superuser(username='operator')
account = User.objects.create_user(username='ordinary')
client = Client(enforce_csrf_checks=True)
client.force_login(operator)
url = reverse('admin:auth_user_object_action', args=[account.pk, 'administrator'])
assert client.get(url, headers={'X-Chassis-Modal': '1'}).status_code == 200
account.refresh_from_db()
assert not account.is_staff
csrf_token = client.cookies[settings.CSRF_COOKIE_NAME].value
action = AccountActionType.GRANT_STAFF.value
response = client.post(url, {'operation': action, 'confirm': 'yes', 'csrfmiddlewaretoken': csrf_token})
assert response.status_code == 302
account.refresh_from_db()
assert account.is_staff and not account.is_superuser
assert AccountAction.objects.filter(actor=operator, target=account, action=action).exists()