Spaces:
Sleeping
Sleeping
Listado se sesiones creadas con datos registrados
Browse files
tecnicas/controllers/sesion_controller.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from django.db import DatabaseError
|
|
|
|
| 2 |
from ..models import Tecnica, Presentador, SesionSensorial
|
| 3 |
from ..utils import controller_error
|
| 4 |
|
|
@@ -39,3 +40,45 @@ class SesionController():
|
|
| 39 |
return self.sensorial_session
|
| 40 |
except DatabaseError as error:
|
| 41 |
return controller_error("Error al crear la session sensorial")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from django.db import DatabaseError
|
| 2 |
+
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
| 3 |
from ..models import Tecnica, Presentador, SesionSensorial
|
| 4 |
from ..utils import controller_error
|
| 5 |
|
|
|
|
| 40 |
return self.sensorial_session
|
| 41 |
except DatabaseError as error:
|
| 42 |
return controller_error("Error al crear la session sensorial")
|
| 43 |
+
|
| 44 |
+
@staticmethod
|
| 45 |
+
def getSessionsSavesByCretor(user_name: str, page: int):
|
| 46 |
+
elements_by_page = 9
|
| 47 |
+
|
| 48 |
+
try:
|
| 49 |
+
creator = Presentador.objects.get(nombre_usuario=user_name)
|
| 50 |
+
except Presentador.DoesNotExist:
|
| 51 |
+
return controller_error("presentador invalido")
|
| 52 |
+
|
| 53 |
+
try:
|
| 54 |
+
queryset = SesionSensorial.objects.select_related(
|
| 55 |
+
"tecnica",
|
| 56 |
+
"tecnica__tipo_tecnica",
|
| 57 |
+
"tecnica__id_estilo").only(
|
| 58 |
+
"codigo_sesion",
|
| 59 |
+
"nombre_sesion",
|
| 60 |
+
"fechaCreacion",
|
| 61 |
+
"tecnica__tipo_tecnica__nombre_tecnica",
|
| 62 |
+
"tecnica__id_estilo__nombre_estilo"
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
paginator = Paginator(queryset, elements_by_page)
|
| 66 |
+
sessions_in_page = paginator.get_page(page)
|
| 67 |
+
except PageNotAnInteger:
|
| 68 |
+
return controller_error("indice invalido")
|
| 69 |
+
except EmptyPage:
|
| 70 |
+
return controller_error("sin registros de sessiones")
|
| 71 |
+
|
| 72 |
+
return sessions_in_page
|
| 73 |
+
|
| 74 |
+
@staticmethod
|
| 75 |
+
def getNumberSessionsByCreator(user_name: str):
|
| 76 |
+
try:
|
| 77 |
+
creator = Presentador.objects.get(nombre_usuario=user_name)
|
| 78 |
+
except Presentador.DoesNotExist:
|
| 79 |
+
return controller_error("presentador invalido")
|
| 80 |
+
|
| 81 |
+
number_sessions = SesionSensorial.objects.filter(
|
| 82 |
+
creadoPor=creator).count()
|
| 83 |
+
|
| 84 |
+
return number_sessions/9
|
tecnicas/templates/tecnicas/main-panel.html
CHANGED
|
@@ -38,7 +38,7 @@
|
|
| 38 |
</section>
|
| 39 |
|
| 40 |
<section class="flex flex-row flex-wrap gap-4 w-f ull justify-center">
|
| 41 |
-
<a href="{% url 'cata_system:panel_sesiones' %}"
|
| 42 |
class="text-white bg-blue-600 hover:bg-blue-700 active:outline-none active:ring-4 active:ring-blue-300 font-medium rounded-xl text-3xl px-8 py-4 text-center uppercase">Gestión
|
| 43 |
de sesiones <br> sensoriales</a>
|
| 44 |
</section>
|
|
|
|
| 38 |
</section>
|
| 39 |
|
| 40 |
<section class="flex flex-row flex-wrap gap-4 w-f ull justify-center">
|
| 41 |
+
<a href="{% url 'cata_system:panel_sesiones' page=1 %}"
|
| 42 |
class="text-white bg-blue-600 hover:bg-blue-700 active:outline-none active:ring-4 active:ring-blue-300 font-medium rounded-xl text-3xl px-8 py-4 text-center uppercase">Gestión
|
| 43 |
de sesiones <br> sensoriales</a>
|
| 44 |
</section>
|
tecnicas/templates/tecnicas/manage_sesions/sesiones-panel.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
|
| 6 |
{% block content %}
|
| 7 |
<article class="w-full flex flex-col justify-center items-center bg-gray-600 mt-10 mb-10">
|
| 8 |
-
<article class="flex flex-col gap-8 bg-gray-400 p-10 rounded-2xl
|
| 9 |
<header class="text-center flex flex-row gap-8 items-center w-full">
|
| 10 |
<div class="bg-gray-600 p-4 text-white rounded-xl flex-1">
|
| 11 |
<h1 class="font-bold text-2xl">Administra las<br>sesiones sensoriales</h1>
|
|
@@ -16,35 +16,32 @@
|
|
| 16 |
principal</a>
|
| 17 |
</div>
|
| 18 |
</header>
|
| 19 |
-
<section class="grid grid-cols-3 gap-4">
|
| 20 |
-
<article class="p-4 bg-gray-200 flex flex-row gap-4 justify-center items-center rounded-lg">
|
| 21 |
-
<div class="text-right *:not-last:mb-4">
|
| 22 |
-
<p><b>Código:</b></p>
|
| 23 |
-
<p><b>Fecha:</b></p>
|
| 24 |
-
<p><b>Técnica:</b></p>
|
| 25 |
-
</div>
|
| 26 |
-
<div class="*:not-last:mb-4">
|
| 27 |
-
<p>9J78GGHJK7V</p>
|
| 28 |
-
<p>12-07-2025</p>
|
| 29 |
-
<p>Intensidad</p>
|
| 30 |
-
</div>
|
| 31 |
-
</article>
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
<p><b>Código:</b></p>
|
| 37 |
<p><b>Fecha:</b></p>
|
| 38 |
<p><b>Técnica:</b></p>
|
|
|
|
| 39 |
</div>
|
| 40 |
-
<div class="*:not-last:mb-
|
| 41 |
-
|
| 42 |
-
<p>{{
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
</div>
|
| 45 |
</article>
|
| 46 |
{% endfor %}
|
| 47 |
</section>
|
|
|
|
| 48 |
<section class="flex justify-center items-center gap-2">
|
| 49 |
<button>
|
| 50 |
<img class="h-10" src="{% static 'img/less-than.svg' %}" alt="menor que">
|
|
|
|
| 5 |
|
| 6 |
{% block content %}
|
| 7 |
<article class="w-full flex flex-col justify-center items-center bg-gray-600 mt-10 mb-10">
|
| 8 |
+
<article class="flex flex-col gap-8 bg-gray-400 p-10 rounded-2xl">
|
| 9 |
<header class="text-center flex flex-row gap-8 items-center w-full">
|
| 10 |
<div class="bg-gray-600 p-4 text-white rounded-xl flex-1">
|
| 11 |
<h1 class="font-bold text-2xl">Administra las<br>sesiones sensoriales</h1>
|
|
|
|
| 16 |
principal</a>
|
| 17 |
</div>
|
| 18 |
</header>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
<section class="grid grid-cols-3 gap-4">
|
| 21 |
+
{% for sesion in sessions %}
|
| 22 |
+
<article class="p-4 bg-gray-200 flex flex-row gap-2 justify-center items-center rounded-lg">
|
| 23 |
+
<div class="text-right *:not-last:mb-2">
|
| 24 |
+
{% if sesion.nombre_sesion %}
|
| 25 |
+
<p><b>Nombre:</b></p>
|
| 26 |
+
{% endif %}
|
| 27 |
<p><b>Código:</b></p>
|
| 28 |
<p><b>Fecha:</b></p>
|
| 29 |
<p><b>Técnica:</b></p>
|
| 30 |
+
<p><b>Estilo:</b></p>
|
| 31 |
</div>
|
| 32 |
+
<div class="*:not-last:mb-2">
|
| 33 |
+
{% if sesion.nombre_sesion %}
|
| 34 |
+
<p>{{ sesion.nombre_sesion }}</p>
|
| 35 |
+
{% endif %}
|
| 36 |
+
<p>{{ sesion.codigo_sesion }}</p>
|
| 37 |
+
<p>{{ sesion.fechaCreacion }}</p>
|
| 38 |
+
<p class="uppercase">{{ sesion.tecnica.tipo_tecnica.nombre_tecnica }}</p>
|
| 39 |
+
<p class="uppercase">{{ sesion.tecnica.id_estilo.nombre_estilo }}</p>
|
| 40 |
</div>
|
| 41 |
</article>
|
| 42 |
{% endfor %}
|
| 43 |
</section>
|
| 44 |
+
|
| 45 |
<section class="flex justify-center items-center gap-2">
|
| 46 |
<button>
|
| 47 |
<img class="h-10" src="{% static 'img/less-than.svg' %}" alt="menor que">
|
tecnicas/urls.py
CHANGED
|
@@ -9,7 +9,7 @@ urlpatterns = [
|
|
| 9 |
path("autenticacion", views.autentication, name="autenticacion"),
|
| 10 |
path("catador-login", views.catadorLogin, name="catador_login"),
|
| 11 |
path("panel-catadores", views.managementCatadores, name="panel_catadores"),
|
| 12 |
-
path("panel-sesiones", views.sesionsPanel, name="panel_sesiones"),
|
| 13 |
path("seleccion-tecnica", views.selecionTecnica, name="seleccion_tecnica"),
|
| 14 |
path("panel-configuracion-basic", views.configurationPanelBasic, name="panel_configuracion_basic"),
|
| 15 |
path("panel-configuracion-tags", views.configurationPanelTags, name="panel_configuracion_tags"),
|
|
|
|
| 9 |
path("autenticacion", views.autentication, name="autenticacion"),
|
| 10 |
path("catador-login", views.catadorLogin, name="catador_login"),
|
| 11 |
path("panel-catadores", views.managementCatadores, name="panel_catadores"),
|
| 12 |
+
path("panel-sesiones/<int:page>", views.sesionsPanel, name="panel_sesiones"),
|
| 13 |
path("seleccion-tecnica", views.selecionTecnica, name="seleccion_tecnica"),
|
| 14 |
path("panel-configuracion-basic", views.configurationPanelBasic, name="panel_configuracion_basic"),
|
| 15 |
path("panel-configuracion-tags", views.configurationPanelTags, name="panel_configuracion_tags"),
|
tecnicas/views/sessions_panel.py
CHANGED
|
@@ -1,19 +1,25 @@
|
|
| 1 |
from django.shortcuts import render
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
-
def sesionsPanel(req):
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
self.fecha = fecha
|
| 19 |
-
self.tecnica = tecnica
|
|
|
|
| 1 |
from django.shortcuts import render
|
| 2 |
+
from ..controllers import SesionController
|
| 3 |
|
| 4 |
|
| 5 |
+
def sesionsPanel(req, page: int):
|
| 6 |
+
context = {}
|
| 7 |
|
| 8 |
+
sessions_in_page = SesionController.getSessionsSavesByCretor(
|
| 9 |
+
user_name="aguBido", page=page)
|
| 10 |
|
| 11 |
+
if isinstance(sessions_in_page, dict):
|
| 12 |
+
context["error"] = sessions_in_page["error"]
|
| 13 |
+
return render(req, "tecnicas/manage_sesions/sesiones-panel.html", context=context)
|
| 14 |
|
| 15 |
+
context["sessions"] = sessions_in_page
|
| 16 |
|
| 17 |
+
number_pages = SesionController.getNumberSessionsByCreator(
|
| 18 |
+
user_name="aguBido")
|
| 19 |
+
if isinstance(number_pages, dict):
|
| 20 |
+
context["num_paginas"] = sessions_in_page["error"]
|
| 21 |
+
return render(req, "tecnicas/manage_sesions/sesiones-panel.html", context=context)
|
| 22 |
|
| 23 |
+
context["num_paginas"] = number_pages
|
| 24 |
+
|
| 25 |
+
return render(req, "tecnicas/manage_sesions/sesiones-panel.html", context=context)
|
|
|
|
|
|