{% extends "dashboard/base.html" %} {% block title %}Access Management{% endblock %} {% block content %}

Access Management

Manage user groups, feature permissions, and user assignments.

Create New Group

{% csrf_token %}
{% if not groups %}

No Groups Found

Create a group to get started.

{% else %} {% for group in groups %}

{{ group.group_name }}

{% if group.description %}

{{ group.description }}

{% endif %}
{{ group.permission_level|title }} Access {% if group.is_active %} Active {% else %} Inactive {% endif %}
{% csrf_token %}
{% csrf_token %}
{% csrf_token %}

Feature Permissions

Select the features this group can access.

{% if features %}
{% for feature in features %} {% if feature.url_name != 'access_management' %} {% endif %} {% endfor %}
{% else %}

No Features Available

Create features first to assign permissions.

{% endif %}
{% if features %}
{% endif %}
{% csrf_token %}

User Assignment

Assign users to this group by searching below.

Start typing to search for users

{% if users %}
{% for user in users %} {% if user.role != 'superadmin' and user.role != 'super_admin' %} {% endif %} {% endfor %}
{% else %}

No Users Available

No users found to assign to groups.

{% endif %}
{% if users %}
{% endif %}
{% endfor %} {% endif %}
{% endblock %} {% block extra_js %} {% endblock %} ``` ```python:dashboard_rbac/ldc_dashboard_rbac/templates/ldc_dashboard_rbac/feature_management.html {% extends "dashboard/base.html" %} {% block title %}Feature Management{% endblock %} {% block content %}

Feature Management

Add, edit, and manage system features available for user groups.

Create New Feature

{% csrf_token %}

Must match the URL name in your urls.py

Available Features

{% if features %}
    {% for feature in features %}
  • {{ feature.name }}

    {% if feature.is_active %} Active {% else %} Inactive {% endif %} {% if feature.category %} {{ feature.category }} {% endif %}
    {% if feature.description %}

    {{ feature.description }}

    {% endif %}

    {{ feature.url_name }}

    Created: {{ feature.created_dtm|date:"M d, Y" }} {% if feature.updated_dtm != feature.created_dtm %} • Updated: {{ feature.updated_dtm|date:"M d, Y" }} {% endif %}
    Edit
    {% csrf_token %}
    {% csrf_token %}
  • {% endfor %}
{% else %}

No Features Found

Create your first feature to get started.

{% endif %}

Edit Feature

{% csrf_token %}
{% endblock %} {% block extra_js %} {% endblock %} ``` ```python:dashboard_rbac/ldc_dashboard_rbac/templates/ldc_dashboard_rbac/user_management.html {% extends "dashboard/base.html" %} {% block title %}User Management{% endblock %} {% block content %}

User Management

Manage users, their roles, and group memberships.

Total Users

{{ users|length }}

Active Users

{{ users|selectattr("is_active")|list|length }}

Admin Users

{{ users|selectattr("role", "in", ["admin", "superadmin"])|list|length }}

Pending Approval

{{ users|rejectattr("is_active")|list|length }}

Users

{% if users %}
{% for user in users %} {% endfor %}
User Role Status Groups Joined Actions
{{ user.name|first|upper }}
{{ user.name }}
{{ user.email }}
{{ user.role|title }} {% if user.is_active %} Active {% else %} Pending {% endif %}
{% for group in user.user_groups.all %} {{ group.group_name }} {% empty %} No groups {% endfor %}
{{ user.created_dtm|date:"M d, Y" }}
View Details {% if user.role != 'superadmin' %}
{% csrf_token %}
{% endif %}
{% else %}

No Users Found

Users will appear here once they register.

{% endif %}
{% for user in users %}

{{ user.name }}

{{ user.email }}

User Information

Role
{{ user.role|title }}
Status
{% if user.is_active %} Active {% else %} Pending {% endif %}
Joined
{{ user.created_dtm|date:"F d, Y" }}
Last Updated
{{ user.updated_dtm|date:"F d, Y" }}

Group Memberships

{% if user.user_groups.all %}
{% for group in user.user_groups.all %}

{{ group.group_name }}

{% if group.description %}

{{ group.description }}

{% endif %}
{{ group.permission_level|title }}
{% endfor %}
{% else %}

This user is not assigned to any groups.

{% endif %}
{% if user.user_groups.all %}

Available Features

{% with user_features=user.user_groups.all|map(attribute='features')|map('list')|sum(start=[]) %} {% if user_features %}
{% for feature in user_features|unique %}
{{ feature.name }}
{% endfor %}
{% else %}

No features available through group memberships.

{% endif %} {% endwith %}
{% endif %}
{% endfor %}
{% endblock %} {% block extra_js %} {% endblock %} ``` ```python:dashboard_rbac/ldc_dashboard_rbac/templates/ldc_dashboard_rbac/base_rbac.html {% block title %}RBAC Management{% endblock %} - {{ site_name|default:"Dashboard" }} {% block extra_css %}{% endblock %}
{% if messages %}
{% for message in messages %}
{% if message.tags == 'error' %} {% elif message.tags == 'warning' %} {% elif message.tags == 'success' %} {% else %} {% endif %}

{{ message }}

{% endfor %}
{% endif %}
{% block content %}{% endblock %}
{% block extra_js %}{% endblock %} ``` ```python:dashboard_rbac/ldc_dashboard_rbac/templates/ldc_dashboard_rbac/README.md # RBAC Templates This directory contains ready-to-use HTML templates for the LDC Dashboard RBAC package. These templates provide a complete UI for managing groups, features, users, and permissions. ## Templates Overview ### 1. `base_rbac.html` - **Purpose**: Base template with navigation, dark mode toggle, and common styling - **Features**: - Responsive navigation - Dark/light mode support - Flash message display - Tailwind CSS integration - Alpine.js ready ### 2. `access_management.html` - **Purpose**: Manage user groups and assign permissions - **Features**: - Create new groups - Assign features to groups - Assign users to groups - Interactive group selection - Search functionality for users ### 3. `feature_management.html` - **Purpose**: Manage system features - **Features**: - Create new features - Edit existing features - Enable/disable features - Category organization - Modal-based editing ### 4. `user_management.html` - **Purpose**: View and manage users - **Features**: - User statistics dashboard - User status management - Group membership overview - User details modal - Filter active/inactive users ## Usage Instructions ### Option 1: Extend the Base Template (Recommended) Create your own base template that extends the RBAC base: ```html {% extends "ldc_dashboard_rbac/base_rbac.html" %} {% block nav_title %}Your App Name{% endblock %} {% block extra_css %} {% endblock %} {% block extra_js %} {% endblock %} ``` ### Option 2: Copy and Customize 1. Copy the templates to your app's template directory 2. Modify them to match your design system 3. Update the `{% extends %}` tags to use your base template ### Option 3: Include as Template Fragments Use the templates as includes in your existing templates: ```html {% include "ldc_dashboard_rbac/access_management.html" %} ``` ## Required Context Variables ### For `access_management.html`: ```python context = { 'groups': Group.objects.all(), 'features': Feature.objects.all(), 'users': User.objects.all(), } ``` ### For `feature_management.html`: ```python context = { 'features': Feature.objects.all(), } ``` ### For `user_management.html`: ```python context = { 'users': User.objects.all(), } ``` ## Dependencies ### CSS Framework - **Tailwind CSS**: Loaded via CDN in base template - **Inter Font**: Google Fonts integration ### JavaScript Libraries - **Alpine.js**: For interactive components - **Tailwind CSS**: For styling ### Required Django Template Tags - `{% csrf_token %}`: For form security - `{% url %}`: For URL generation - `{% if %}`, `{% for %}`: Standard Django template tags ## Customization Guide ### Colors and Theming The templates use Tailwind's slate color palette with indigo accents. To customize: 1. **Primary Colors**: Replace `indigo-*` classes with your brand colors 2. **Background Colors**: Modify `slate-*` classes for different backgrounds 3. **Dark Mode**: Customize `dark:*` classes for dark theme ### Layout Modifications - **Grid Layout**: Modify `grid-cols-*` classes for different layouts - **Spacing**: Adjust `p-*`, `m-*`, `space-*` classes - **Responsive**: Use `sm:*`, `md:*`, `lg:*` prefixes ### Adding Custom Fields To add custom fields to forms: 1. Add input fields in the HTML 2. Update the corresponding Django views to handle the new fields 3. Update the model if necessary ## Form Actions The templates expect these form actions to be handled in your views: ### Access Management - `create_group`: Create a new group - `delete_group`: Delete a group - `toggle_group_status`: Activate/deactivate a group - `update_group_permissions`: Update group feature permissions - `update_group_users`: Update group user assignments ### Feature Management - `create_feature`: Create a new feature - `edit_feature`: Edit an existing feature - `toggle_feature_status`: Enable/disable a feature - `delete_feature`: Delete a feature ### User Management - `toggle_user_status`: Activate/deactivate a user ## Example View Integration ```python from django.shortcuts import render from django.contrib import messages from .models import Group, Feature, User def access_management(request): if request.method == 'POST': action = request.POST.get('action') if action == 'create_group': # Handle group creation group_name = request.POST.get('group_name') description = request.POST.get('description') permission_level = request.POST.get('permission_level') Group.objects.create( group_name=group_name, description=description, permission_level=permission_level ) messages.success(request, 'Group created successfully!') # Handle other actions... context = { 'groups': Group.objects.all(), 'features': Feature.objects.filter(is_active=True), 'users': User.objects.all(), } return render(request, 'ldc_dashboard_rbac/access_management.html', context) ``` ## Browser Support These templates support modern browsers with: - CSS Grid and Flexbox - ES6+ JavaScript (for Alpine.js) - CSS Custom Properties (for Tailwind) ## Accessibility Features - Semantic HTML structure - ARIA labels and roles - Keyboard navigation support - Screen reader friendly - High contrast mode support ## Performance Considerations - **CSS**: Tailwind CSS is loaded via CDN (consider using a build process for production) - **JavaScript**: Alpine.js is lightweight (~15KB gzipped) - **Images**: Uses SVG icons for scalability - **Fonts**: Inter font is preloaded for better performance ## Troubleshooting ### Common Issues 1. **Styles not loading**: Ensure Tailwind CSS CDN is accessible 2. **Interactive features not working**: Check Alpine.js is loaded 3. **Forms not submitting**: Verify CSRF tokens are included 4. **Dark mode not working**: Check JavaScript console for errors ### Debug Mode Add this to see Alpine.js data: ```html

``` ``` ## Summary I've created a comprehensive set of templates for the RBAC package that includes: ### ✅ **Complete Template Set** 1. **`base_rbac.html`** - Base template with navigation and theming 2. **`access_management.html`** - Group and permission management 3. **`feature_management.html`** - Feature creation and management 4. **`user_management.html`** - User overview and management 5. **`README.md`** - Comprehensive usage documentation ### ✅ ```