{% extends 'base.html' %} {% block content %} {% set is_admin = current_user.is_authenticated and current_user.role and current_user.role.name == 'Администратор' %} {% set is_user_role = current_user.is_authenticated and current_user.role and current_user.role.name == 'Пользователь' %}

Управление пользователями

CRUD-приложение · Лабораторная работа №5

{% if is_admin %}  Создать пользователя {% endif %}
{% if users %}
{% for user in users %} {% endfor %}
# ФИО Роль Действия
{{ loop.index }}
{{ (user.first_name[0] if user.first_name else '?') | upper }}
{{ user.get_full_name() or user.login }}
{% if user.role %} {{ user.role.name }} {% else %} {% endif %}
{% if is_admin or (is_user_role and user.id == current_user.id) %} Просмотр {% endif %} {% if is_admin or (is_user_role and user.id == current_user.id) %} {% endif %} {% if is_admin %} {% endif %}
{% else %}

Пользователи не найдены

{% endif %}
{% if is_admin %} {% endif %} {% endblock %}