{% extends 'base.html' %} {% load static %} {% block title %}🔍 Pruebas de Permisos{% endblock %} {% block extra_head %} {% endblock %} {% block content %}

🧪 Panel de Pruebas del Sistema

Propósito: Verificar permisos, accesos y configuraciones de cada usuario. Esta página es accesible para todo el staff durante la fase de pruebas.

Última actualización: {{ request.META.HTTP_DATE|default:"Ahora" }}

Estado del Sistema:
{% if system_status.user_authenticated %}✅{% else %}❌{% endif %} Autenticado {% if system_status.has_team %}✅{% else %}❌{% endif %} Equipo Asignado {% if system_status.has_active_division %}✅{% else %}⚠️{% endif %} División Activa {% if system_status.has_players %}✅{% else %}⚠️{% endif %} Jugadores Registrados {% if system_status.has_matches %}✅{% else %}⚠️{% endif %} Partidos Jugados
{% if not team_info %}
⚠️ Usuario sin Equipo Asignado

Este usuario NO tiene un equipo asignado (internal_team_id = NULL).

Consecuencia: La mayoría de las vistas estarán ❌ BLOQUEADAS.


Para asignar un equipo: python manage.py shell
from dashboard.models import CustomUser
user = CustomUser.objects.get(username='{{ user.username }}')
user.internal_team_id = 1 # Cambiar por ID real
user.save()

{% endif %}
Auto-refresh: 5s

Información del Usuario

ID: {{ user_info.id }}
Username: {{ user_info.username }}
Email: {{ user_info.email }}
internal_team_id: {% if user_info.internal_team_id %} {{ user_info.internal_team_id }} {% else %} NULL (Sin equipo) {% endif %}
Staff: {% if user_info.is_staff %} ✅ SÍ {% else %} ❌ NO {% endif %}
Superusuario: {% if user_info.is_superuser %} ✅ SÍ {% else %} ❌ NO {% endif %}
Activo: {% if user_info.is_active %} ✅ SÍ {% else %} ❌ NO {% endif %}
Fecha de registro: {{ user_info.date_joined|date:"d/m/Y H:i" }}
Último login: {{ user_info.last_login|date:"d/m/Y H:i" }}

Equipo Asociado

{% if team_info %}
ID: {{ team_info.id }}
Nombre: {{ team_info.name }}
Logo: {% if team_info.has_logo %} {{ team_info.name }} ({{ team_info.logo }}) {% else %} Sin logo {% endif %}
{% else %}

No hay equipo asociado a este usuario

El campo internal_team_id está en NULL. Asigna un equipo para habilitar las funcionalidades.

{% endif %}

División Activa

{% if division_info %}
ID: {{ division_info.id }}
División: {{ division_info.division_name }}
Estado: ✅ Activa
{% if all_divisions|length > 1 %}
Todas las divisiones ({{ all_divisions|length }}):
{% for div in all_divisions %}
{{ div.division_name }} {% if div.is_active %} ✅ Activa {% else %} Inactiva {% endif %}
{% endfor %}
{% endif %} {% else %}

{% if team_info %} El equipo {{ team_info.name }} no tiene división activa. {% else %} No hay división activa (requiere tener equipo asignado). {% endif %}

{% endif %}

Permisos de Django

Todos los permisos:
{% if django_permissions.all_permissions %}
{% for perm in django_permissions.all_permissions %} {{ perm }} {% endfor %}
{% else %}

Sin permisos asignados (usuario estándar)

{% endif %}
Grupos:
{% if django_permissions.group_permissions %}
{% for group in django_permissions.group_permissions %} {{ group }} {% endfor %}
{% else %}

Sin grupos asignados

{% endif %}

Acceso a Vistas del Dashboard

Esto muestra qué páginas puede ver este usuario.

Dashboard Principal ✅ PERMITIDO
{{ access_reasons.dashboard }}
Perfil del Equipo {% if view_access.team_profile %} ✅ PERMITIDO {% else %} ❌ BLOQUEADO {% endif %}
{{ access_reasons.team_profile }}
Plantilla de Jugadores {% if view_access.team_roster %} ✅ PERMITIDO {% else %} ❌ BLOQUEADO {% endif %}
{{ access_reasons.team_roster }}
Perfil de Jugador {% if view_access.player_profile %} ✅ PERMITIDO {% else %} ❌ BLOQUEADO {% endif %}
{{ access_reasons.player_profile }}
Últimos Partidos {% if view_access.recent_matches %} ✅ PERMITIDO {% else %} ❌ BLOQUEADO {% endif %}
{{ access_reasons.recent_matches }}
Tabla de Posiciones {% if view_access.standings %} ✅ PERMITIDO {% else %} ❌ BLOQUEADO {% endif %}
{{ access_reasons.standings }}

Jugadores del Equipo {% if players_info.total > 0 %} {{ players_info.total }} total {% endif %}

{% if players_info.players %}

Mostrando los primeros 10 jugadores:

{% for player in players_info.players %}
{% if player.has_logo %} {{ player.name }} {% else %} Sin foto {% endif %}
#{{ player.jersey_number }} - {{ player.name }}
{{ player.position }}
{% endfor %} {% if players_info.total > 10 %}

... y {{ players_info.total|add:"-10" }} jugadores más

{% endif %} {% else %}

{% if team_info %} El equipo no tiene jugadores registrados en la división activa. {% else %} No hay jugadores (requiere tener equipo asignado). {% endif %}

{% endif %}

Últimos Partidos {% if matches_info.total > 0 %} {{ matches_info.total }} encontrados {% endif %}

{% if matches_info.matches %}
{% for match in matches_info.matches %} {% endfor %}
Fecha Partido Resultado
{{ match.date|date:"d/m/Y" }} {{ match.home_team }} vs {{ match.away_team }} {{ match.score_home }} - {{ match.score_away }}
{% else %}

{% if team_info %} El equipo no tiene partidos completados. {% else %} No hay partidos (requiere tener equipo asignado). {% endif %}

{% endif %}

Información de Sesión

Session Key: {{ session_info.session_key }}
Datos de sesión:
{{ session_info.session_data }}
{% endblock %}