digitalfabrik/integreat-cms

View on GitHub
integreat_cms/cms/templates/users/user_list_row.html

Summary

Maintainability
Test Coverage
{% load i18n %}
<tr class="border-t border-solid border-gray-200 hover:bg-gray-100">
    <td class="pl-4">
        <a href="{% url 'edit_user' user_id=user.id %}"
           class="block py-3 pr-2 text-gray-800">{{ user.username }}</a>
    </td>
    <td class="pr-2">
        {{ user.first_name }}
    </td>
    <td class="pr-2">
        {{ user.last_name }}
    </td>
    <td>
        <span class="hover:underline text-blue-500 hover:text-blue-600 pr-2">{{ user.email|urlize }}</span>
    </td>
    <td class="pr-2">
        {% if user.distinct_region %}
            {{ user.distinct_region }}
        {% endif %}
    </td>
    <td class="pr-2">
        {{ user.role }}
    </td>
    <td class="pr-2 whitespace-nowrap">
        {% if user.last_login %}
            {{ user.last_login }}
        {% else %}
            <span title="{% translate "No login yet" %}">
                <i icon-name="x" class="text-red-500"></i>
            </span>
        {% endif %}
    </td>
    <td class="pr-2 whitespace-nowrap">
        {% if user.is_active %}
            <span title="{% translate "Active" %}">
                <i icon-name="check" class="text-green-500"></i>
            </span>
        {% else %}
            <span title="{% translate "Inactive" %}">
                <i icon-name="x" class="text-red-500 align-text-top"></i>
            </span>
            <form method="post"
                  action="{% url 'resend_activation_link' user_id=user.id %}"
                  class="inline">
                {% csrf_token %}
                <button class="bg-transparent hover:underline text-blue-500 hover:text-blue-600 cursor-pointer">
                    {% translate "Resend activation link" %}
                </button>
            </form>
        {% endif %}
    </td>
    <td class="pr-2">
        {% if user.is_staff %}
            <span title="{% translate "Staff member" %}">
                <i icon-name="check" class="text-green-500"></i>
            </span>
        {% else %}
            <span title="{% translate "No staff member" %}">
                <i icon-name="x" class="text-red-500"></i>
            </span>
        {% endif %}
    </td>
    <td class="pr-4">
        {% if user.is_superuser %}
            <span title="{% translate "Administrator" %}">
                <i icon-name="check" class="text-green-500"></i>
            </span>
        {% else %}
            <span title="{% translate "No administrator" %}">
                <i icon-name="x" class="text-red-500"></i>
            </span>
        {% endif %}
    </td>
    <td class="pr-4">
        {% if user.has_fido_keys and user.has_totp %}
            <span title="{% translate "Multi-Factor-Authentication (TOTP + FIDO2)" %}">
                <i icon-name="check" class="text-green-500"></i>
            </span>
        {% elif user.has_fido_keys %}
            <span title="{% translate "2-Factor-Authentication (FIDO2)" %}">
                <i icon-name="check" class="text-green-500"></i>
            </span>
        {% elif user.has_totp %}
            <span title="{% translate "2-Factor-Authentication (TOTP)" %}">
                <i icon-name="check" class="text-green-500"></i>
            </span>
        {% else %}
            <span title="{% translate "Account security can be enhanced by configuring a second factor. Please consider setting up TOTP or FIDO2 to add an additional layer of protection to your account." %}">
                <i icon-name="x" class="text-red-500"></i>
            </span>
        {% endif %}
    </td>
</tr>