Browse Source

Añado estadísticas de usuarios y búsqueda por email y nombre en lista de usuarios

main
Celestino Rey 6 months ago
parent
commit
33b8c24809
10 changed files with 61 additions and 9 deletions
  1. +1
    -1
      JugarAlPadel/K8S/Makefile
  2. +1
    -0
      JugarAlPadel/K8S/env-prod-configmap.yaml
  3. +3
    -0
      JugarAlPadel/gestion_reservas/eventos/urls.py
  4. +11
    -0
      JugarAlPadel/gestion_reservas/eventos/views.py
  5. +2
    -2
      JugarAlPadel/gestion_reservas/gestion_reservas/settings.py
  6. +8
    -4
      JugarAlPadel/gestion_reservas/gestion_reservas/views.py
  7. +1
    -1
      JugarAlPadel/gestion_reservas/reymotausers/admin.py
  8. +1
    -1
      JugarAlPadel/gestion_reservas/templates/_branding.html
  9. +11
    -0
      JugarAlPadel/gestion_reservas/templates/base.html
  10. +22
    -0
      JugarAlPadel/gestion_reservas/templates/eventos/estadisticas_usuarios.html

+ 1
- 1
JugarAlPadel/K8S/Makefile View File

@ -1,7 +1,7 @@
export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':')
export REGISTRY=registry.reymota.es
export IMG_VERSION = 0.70.24
export IMG_VERSION = 0.70.26
export IMG_NGINX_VERSION = 2.3
# limpia todo


+ 1
- 0
JugarAlPadel/K8S/env-prod-configmap.yaml View File

@ -2,6 +2,7 @@ apiVersion: v1
data:
DEBUG: "False"
APP_VERSION: 13.0.1
DATABASE: postgres
kind: ConfigMap
metadata:
labels:


+ 3
- 0
JugarAlPadel/gestion_reservas/eventos/urls.py View File

@ -36,4 +36,7 @@ urlpatterns = [
path('api/noticias/', api_lista_noticias, name='api_lista_noticias'),
path('api/noticias/<int:noticia_id>/', api_detalle_noticia, name='api_detalle_noticia'),
path("estadisticas/usuarios/", views.estadisticas_por_usuario, name="estadisticas_por_usuario"),
]

+ 11
- 0
JugarAlPadel/gestion_reservas/eventos/views.py View File

@ -21,6 +21,11 @@ from .serializers import EventoSerializer, ReservaSerializer, ListaEsperaSeriali
from .models import Evento, Reserva, ListaEspera, Noticia
from .forms import ListaEsperaForm, EventoForm, MensajeCorreoForm
from django.contrib.auth import get_user_model
from django.db.models import Count
User = get_user_model()
logger = logging.getLogger(__name__)
@ -357,3 +362,9 @@ def enviar_correo_inscritos(request, evento_id):
return render(request, 'eventos/enviar_correo_inscritos.html', {'form': form, 'evento': evento})
@user_passes_test(es_admin)
def estadisticas_por_usuario(request):
usuarios = User.objects.annotate(num_eventos=Count("reserva__evento")).order_by("-num_eventos")
return render(request, "eventos/estadisticas_usuarios.html", {"usuarios": usuarios})

+ 2
- 2
JugarAlPadel/gestion_reservas/gestion_reservas/settings.py View File

@ -32,8 +32,8 @@ SECRET_KEY = 'hey'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ["DEBUG"] == 'True'
ALLOWED_HOSTS = [".ocp-cluster.reymota.lab", "jugaralpadel.rancher.reymota.lab", "jugaralpadel.es"]
CSRF_TRUSTED_ORIGINS = ["https://*.ocp-cluster.reymota.lab", "http://jugaralpadel.rancher.reymota.lab", "https://jugaralpadel.rancher.reymota.lab", "https://jugaralpadel.es"]
ALLOWED_HOSTS = [".ocp-cluster.reymota.lab", "jugaralpadel.rancher.reymota.lab", "jugaralpadel.es", ".reymota.es"]
CSRF_TRUSTED_ORIGINS = ["https://*.ocp-cluster.reymota.lab", "http://jugaralpadel.rancher.reymota.lab", "https://jugaralpadel.rancher.reymota.lab", "https://jugaralpadel.es", "https://*.reymota.es"]
# Application definition


+ 8
- 4
JugarAlPadel/gestion_reservas/gestion_reservas/views.py View File

@ -1,14 +1,18 @@
from rest_framework.response import Response
from django.utils import timezone
from rest_framework import status
# Imports
import os
from django.conf import settings
from django.contrib.auth.decorators import user_passes_test
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseForbidden
from django.shortcuts import render, get_object_or_404
from django.utils import timezone
from datetime import date
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
from eventos.models import Noticia, Evento
from .serializers import AyudaSerializer


+ 1
- 1
JugarAlPadel/gestion_reservas/reymotausers/admin.py View File

@ -56,7 +56,7 @@ class ReyMotaUserAdmin(UserAdmin):
("Personal", {"fields": ("nombre",)}),
("Varios", {"fields": ("foto",)}),
)
search_fields = ("email",)
search_fields = ("email", "nombre",)
ordering = ("email",)
actions = [enviar_email_prueba] # Añadir la acción a la lista de acciones


+ 1
- 1
JugarAlPadel/gestion_reservas/templates/_branding.html View File

@ -3,6 +3,6 @@
{% load filtros_de_entorno %}
<div class="app-branding">
<a class="app-logo" href="{% url 'principal' %}"><img class="logo-icon me-2" src="{% static 'images/palapadel.svg' %}" alt="logo"><span class="logo-text">JUGAR AL PADEL</span><span style="color: blue; font-size: 14px;"> v {{ "VERSION"|muestra_version }}</span></a>
<a class="app-logo" href="{% url 'principal' %}"><img class="logo-icon me-2" src="{% static 'images/palapadel.svg' %}" alt="logo"><span class="logo-text">JUGAR AL PADEL</span></a>
</div><!--//app-branding-->

+ 11
- 0
JugarAlPadel/gestion_reservas/templates/base.html View File

@ -122,6 +122,17 @@
<span class="nav-link-text">Crear un nuevo evento</span>
</a><!--//nav-link-->
</li><!--//nav-item-->
<li class="nav-item"></li>
<a class="nav-link" href="{% url 'eventos:estadisticas_por_usuario' %}">
<span class="nav-icon">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-bar-chart-line" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M11 2a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v12h.5a.5.5 0 0 1 0 1H.5a.5.5 0 0 1 0-1H1v-3a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v3h1V7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v7h1V2zm1 12h2V2h-2v12zm-3 0V7H7v7h2zm-5 0v-3H2v3h2z"/>
</svg>
</span>
<span class="nav-link-text">Estadísticas por usuario</span>
</a><!--//nav-link-->
</li><!--//nav-item-->
{% endif %}


+ 22
- 0
JugarAlPadel/gestion_reservas/templates/eventos/estadisticas_usuarios.html View File

@ -0,0 +1,22 @@
{% extends "base.html" %}
{% block content %}
<h2>Estadísticas de Inscripciones por Usuario</h2>
<table class="table table-bordered">
<thead>
<tr>
<th>Usuario</th>
<th>Eventos inscritos</th>
</tr>
</thead>
<tbody>
{% for usuario in usuarios %}
<tr>
<td>{{ usuario.get_full_name|default:usuario.nombre }}</td>
<td>{{ usuario.num_eventos }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

Loading…
Cancel
Save