Browse Source

Estadísticas de usuarios

politica
Celestino Rey 7 months ago
parent
commit
2bbbfd1c5f
11 changed files with 115 additions and 13 deletions
  1. +1
    -1
      JugarAlPadel/K8S/Makefile
  2. +2
    -0
      JugarAlPadel/K8S/env-prod-configmap.yaml
  3. +6
    -1
      JugarAlPadel/K8S/jugaralpadel-deployment.yaml
  4. +2
    -0
      JugarAlPadel/gestion_reservas/eventos/urls.py
  5. +11
    -0
      JugarAlPadel/gestion_reservas/eventos/views.py
  6. +2
    -0
      JugarAlPadel/gestion_reservas/gestion_reservas/settings.py
  7. +2
    -0
      JugarAlPadel/gestion_reservas/gestion_reservas/urls.py
  8. +21
    -11
      JugarAlPadel/gestion_reservas/gestion_reservas/views.py
  9. +21
    -0
      JugarAlPadel/gestion_reservas/templates/acerca_de.html
  10. +24
    -0
      JugarAlPadel/gestion_reservas/templates/base.html
  11. +23
    -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 ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':')
export REGISTRY=registry.reymota.es export REGISTRY=registry.reymota.es
export IMG_VERSION = 0.70.46
export IMG_VERSION = 0.70.57
export IMG_NGINX_VERSION = 2.3 export IMG_NGINX_VERSION = 2.3
export APP_VERSION = 12.0 export APP_VERSION = 12.0


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

@ -1,6 +1,8 @@
apiVersion: v1 apiVersion: v1
data: data:
DEBUG: "False" DEBUG: "False"
APP_VERSION: 12.0.0
DATABASE: postgres
kind: ConfigMap kind: ConfigMap
metadata: metadata:
labels: labels:


+ 6
- 1
JugarAlPadel/K8S/jugaralpadel-deployment.yaml View File

@ -39,8 +39,13 @@ spec:
name: jugaralpadel name: jugaralpadel
image: $REGISTRY/jugaralpadel-$ARQUITECTURA:$IMG_VERSION image: $REGISTRY/jugaralpadel-$ARQUITECTURA:$IMG_VERSION
env: env:
- name: IMG_VERSION
value: "$IMG_VERSION"
- name: APP_VERSION - name: APP_VERSION
value: "$APP_VERSION"
valueFrom:
configMapKeyRef:
key: APP_VERSION
name: env-prod
- name: DEBUG - name: DEBUG
valueFrom: valueFrom:
configMapKeyRef: configMapKeyRef:


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

@ -36,4 +36,6 @@ urlpatterns = [
path('api/noticias/', api_lista_noticias, name='api_lista_noticias'), path('api/noticias/', api_lista_noticias, name='api_lista_noticias'),
path('api/noticias/<int:noticia_id>/', api_detalle_noticia, name='api_detalle_noticia'), 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 .models import Evento, Reserva, ListaEspera, Noticia
from .forms import ListaEsperaForm, EventoForm, MensajeCorreoForm 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__) logger = logging.getLogger(__name__)
@ -363,3 +368,9 @@ def enviar_correo_inscritos(request, evento_id):
return render(request, 'eventos/enviar_correo_inscritos.html', {'form': form, 'evento': evento}) 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
- 0
JugarAlPadel/gestion_reservas/gestion_reservas/settings.py View File

@ -14,7 +14,9 @@ from pathlib import Path
import os import os
import logging import logging
APP_NAME = "Jugaralpadel.es"
APP_VERSION = os.environ.get("APP_VERSION", "0.0.0-dev") # Valor por defecto si no está definido APP_VERSION = os.environ.get("APP_VERSION", "0.0.0-dev") # Valor por defecto si no está definido
IMG_VERSION = os.environ.get("IMG_VERSION", "0.0.0-dev") # Valor por defecto si no está definido
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent


+ 2
- 0
JugarAlPadel/gestion_reservas/gestion_reservas/urls.py View File

@ -40,6 +40,8 @@ urlpatterns = [
path('politica-privacidad/', views.politica_privacidad, name='politica_privacidad'), path('politica-privacidad/', views.politica_privacidad, name='politica_privacidad'),
path('api/ayuda/', api_lista_ayuda, name='api_lista_ayuda'), path('api/ayuda/', api_lista_ayuda, name='api_lista_ayuda'),
path("acerca-de/", views.acerca_de, name="acerca_de"),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

+ 21
- 11
JugarAlPadel/gestion_reservas/gestion_reservas/views.py View File

@ -1,28 +1,29 @@
from rest_framework.response import Response
from django.utils import timezone
from rest_framework import status
# Imports
from datetime import date
import os
from django.conf import settings from django.conf import settings
from django.contrib.auth.decorators import user_passes_test from django.contrib.auth.decorators import user_passes_test
from django.shortcuts import render, get_object_or_404
from datetime import date
from django.http import HttpResponseForbidden from django.http import HttpResponseForbidden
from django.shortcuts import render, get_object_or_404
from django.utils import timezone
from eventos.models import Noticia, Evento
from .models import Ayuda
from rest_framework import status
from rest_framework.decorators import api_view from rest_framework.decorators import api_view
from rest_framework.response import Response
from eventos.models import Noticia, Evento
from .serializers import AyudaSerializer from .serializers import AyudaSerializer
from .models import Ayuda
import markdown # Importa la biblioteca de markdown import markdown # Importa la biblioteca de markdown
import os
@user_passes_test(lambda u: u.is_staff) @user_passes_test(lambda u: u.is_staff)
def ver_variables_entorno(request): def ver_variables_entorno(request):
if not settings.DEBUG:
return HttpResponseForbidden("Acceso prohibido")
# Variables a excluir por motivos de seguridad # Variables a excluir por motivos de seguridad
variables_excluidas = {'SECRET_KEY', 'DATABASES', 'EMAIL_HOST_PASSWORD', 'API_KEY'} variables_excluidas = {'SECRET_KEY', 'DATABASES', 'EMAIL_HOST_PASSWORD', 'API_KEY'}
@ -69,6 +70,15 @@ def politica_privacidad(request):
return render(request, 'politica_privacidad.html', {'fecha_actual': date.today()}) return render(request, 'politica_privacidad.html', {'fecha_actual': date.today()})
def acerca_de(request):
context = {
"app_name": settings.APP_NAME,
"app_version": settings.APP_VERSION,
"img_version": settings.IMG_VERSION
}
return render(request, "acerca_de.html", context)
# #
# API # API
# #


+ 21
- 0
JugarAlPadel/gestion_reservas/templates/acerca_de.html View File

@ -0,0 +1,21 @@
{% extends "base.html" %}
{% block content %}
<div class="container-xl">
<h1 class="app-page-title">Acerca de...</h1>
<div class="row g-4">
<div class="col-12 col-md-6">
<div class="app-card app-card-basic d-flex flex-column align-items-start shadow-sm">
<div class="app-card-body px-4">
<ul class="list-unstyled">
<li><strong>Nombre de la aplicación:</strong> {{ app_name }}</li>
<li><strong>Versión:</strong> {{ app_version }}</li>
<li><strong>Versión de la imagen:</strong> {{ img_version }}</li>
</ul>
</div><!--//app-card-body-->
</div><!--//app-card-->
</div><!--//col-->
</div><!--//row-->
</div>
{% endblock %}

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

@ -122,6 +122,17 @@
<span class="nav-link-text">Crear un nuevo evento</span> <span class="nav-link-text">Crear un nuevo evento</span>
</a><!--//nav-link--> </a><!--//nav-link-->
</li><!--//nav-item--> </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 %} {% endif %}
@ -138,6 +149,19 @@
</a><!--//nav-link--> </a><!--//nav-link-->
</li><!--//nav-item--> </li><!--//nav-item-->
<li class="nav-item">
<!--//Bootstrap Icons: https://icons.getbootstrap.com/ -->
<a class="nav-link" href="{% url 'acerca_de' %}">
<span class="nav-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-exclamation-square" viewBox="0 0 16 16">
<path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
<path d="M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0M7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0z"/>
</svg>
</span>
<span class="nav-link-text">Acerca de...</span>
</a><!--//nav-link-->
</li><!--//nav-item-->
</ul><!--//app-menu--> </ul><!--//app-menu-->
</nav><!--//app-nav--> </nav><!--//app-nav-->
</div><!--//sidepanel-inner--> </div><!--//sidepanel-inner-->


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

@ -0,0 +1,23 @@
{% 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