Spaces:
Sleeping
Sleeping
Se plasma informacion sobre una sesion en vista de detalles
Browse files
tecnicas/controllers/__init__.py
CHANGED
|
@@ -7,3 +7,4 @@ from .estilo_palabras_controller import EstiloPalabrasController
|
|
| 7 |
from .palabras_controller import PalabrasController
|
| 8 |
from .sesion_controller import SesionController
|
| 9 |
from .calificacion_controller import CalificacionController
|
|
|
|
|
|
| 7 |
from .palabras_controller import PalabrasController
|
| 8 |
from .sesion_controller import SesionController
|
| 9 |
from .calificacion_controller import CalificacionController
|
| 10 |
+
from .detalles_sesion_controller import DetallesSesionController
|
tecnicas/controllers/detalles_sesion_controller.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ..models import SesionSensorial, Presentador
|
| 2 |
+
from . import CalificacionController, PalabrasController
|
| 3 |
+
from ..utils import controller_error
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class DetallesSesionController():
|
| 7 |
+
@staticmethod
|
| 8 |
+
def getContextForView(session_code: str):
|
| 9 |
+
context = {}
|
| 10 |
+
|
| 11 |
+
session = SesionSensorial.objects.get(codigo_sesion=session_code)
|
| 12 |
+
context["sesion"] = session
|
| 13 |
+
|
| 14 |
+
words = PalabrasController.getWordsInTechnique(session.tecnica)
|
| 15 |
+
context["palabras"] = words
|
| 16 |
+
|
| 17 |
+
rating = CalificacionController.getRatingsByTechnique(
|
| 18 |
+
technique=session.tecnica)
|
| 19 |
+
context["calificaciones"] = rating
|
| 20 |
+
|
| 21 |
+
return context
|
| 22 |
+
|
| 23 |
+
@staticmethod
|
| 24 |
+
def startRepetition(session_code: str, username: str):
|
| 25 |
+
try:
|
| 26 |
+
creator = Presentador.objects.get(nombre_usuario=username)
|
| 27 |
+
session = SesionSensorial.objects.get(codigo_sesion=session_code)
|
| 28 |
+
except Presentador.DoesNotExist:
|
| 29 |
+
return controller_error("no existe presentador")
|
| 30 |
+
except SesionSensorial.DoesNotExist:
|
| 31 |
+
return controller_error("no existe sesión sensorial")
|
| 32 |
+
|
| 33 |
+
if creator.nombre_usuario != session.creadoPor.nombre_usuario:
|
| 34 |
+
return controller_error("solo el presentador que crea la sesión puede iniciar la repetición")
|
| 35 |
+
elif session.activo:
|
| 36 |
+
return controller_error("la sesión ya está activada")
|
| 37 |
+
elif session.tecnica.repecion == session.tecnica.repeticiones_max:
|
| 38 |
+
return controller_error("se ha alcanzado el número de repeticiones máxima")
|
| 39 |
+
|
| 40 |
+
session.activo = True
|
| 41 |
+
rep = session.tecnica.repecion
|
| 42 |
+
session.tecnica.repecion = rep + 1
|
| 43 |
+
|
| 44 |
+
session.save()
|
| 45 |
+
|
| 46 |
+
return session
|
tecnicas/static/js/details-session.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const actionForm = document.querySelector(".form-action-session");
|
| 2 |
+
const notificationError = document.querySelector(".ct-notification-error");
|
| 3 |
+
|
| 4 |
+
if (notificationError) {
|
| 5 |
+
setTimeout(function () {
|
| 6 |
+
notificationError.classList.add("hidden");
|
| 7 |
+
}, 2000);
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
function startRepetition() {
|
| 11 |
+
const inputAction = document.createElement("input");
|
| 12 |
+
inputAction.type = "hidden";
|
| 13 |
+
inputAction.name = "action";
|
| 14 |
+
inputAction.value = "start_session";
|
| 15 |
+
|
| 16 |
+
const inputUser = document.createElement("input");
|
| 17 |
+
inputUser.type = "hidden";
|
| 18 |
+
inputUser.name = "username";
|
| 19 |
+
inputUser.value = "pollo";
|
| 20 |
+
|
| 21 |
+
actionForm.appendChild(inputAction);
|
| 22 |
+
actionForm.appendChild(inputUser);
|
| 23 |
+
|
| 24 |
+
actionForm.classList.remove("hidden");
|
| 25 |
+
actionForm.submit();
|
| 26 |
+
}
|
tecnicas/templates/tecnicas/manage_sesions/detalles-sesion.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
| 8 |
<article class="flex flex-col gap-8 bg-gray-400 p-10 rounded-2xl">
|
| 9 |
<header class="text-center flex-row w-full flex justify-around items-center flex-wrap gap-10">
|
| 10 |
<h1 class="text-white rounded-xl font-bold text-2xl bg-gray-600 p-4 flex-1">
|
| 11 |
-
Detalles de la
|
| 12 |
</h1>
|
| 13 |
<a href="{% url 'cata_system:index' %}">
|
| 14 |
<p
|
|
@@ -18,25 +18,33 @@
|
|
| 18 |
</a>
|
| 19 |
</header>
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
<p class="font-bold text-2xl border-b-2">
|
| 22 |
-
|
| 23 |
</p>
|
| 24 |
<article
|
| 25 |
class="text-white rounded-xl grid grid-cols-2 max-sm:grid-cols-1 gap-3 *:bg-gray-500 *:flex *:flex-wrap *:items-center *:justify-center *:max-sm:justify-normal *:gap-x-2 *:p-4 *:rounded-2xl">
|
| 26 |
<section class="col-span-2 max-sm:col-span-1">
|
| 27 |
-
<p class="
|
| 28 |
Código:
|
| 29 |
</p>
|
| 30 |
-
<p class="
|
| 31 |
{{ sesion.codigo_sesion }}
|
| 32 |
</p>
|
| 33 |
</section>
|
| 34 |
|
| 35 |
<section class="col-span-2 max-sm:col-span-1">
|
| 36 |
-
<p class="
|
| 37 |
Nombre:
|
| 38 |
</p>
|
| 39 |
-
<p class="
|
| 40 |
{% if sesion.nombre_sesion %}
|
| 41 |
{{ sesion.nombre_sesion }}
|
| 42 |
{% else %}
|
|
@@ -46,44 +54,71 @@
|
|
| 46 |
</section>
|
| 47 |
|
| 48 |
<section>
|
| 49 |
-
<p class="
|
| 50 |
Fecha creación:
|
| 51 |
</p>
|
| 52 |
-
<p class="
|
| 53 |
{{ sesion.fechaCreacion }}
|
| 54 |
</p>
|
| 55 |
</section>
|
| 56 |
|
| 57 |
<section>
|
| 58 |
-
<p class="
|
| 59 |
Estado:
|
| 60 |
</p>
|
| 61 |
-
<p class="
|
| 62 |
{% if sesion.activo %}
|
| 63 |
En proceso
|
| 64 |
{% else %}
|
| 65 |
-
Listo para iniciar
|
| 66 |
{% endif %}
|
| 67 |
</p>
|
| 68 |
</section>
|
| 69 |
|
| 70 |
<section>
|
| 71 |
-
<p class="
|
| 72 |
Estilo palabras:
|
| 73 |
</p>
|
| 74 |
-
<p class="
|
| 75 |
{{ sesion.tecnica.id_estilo }}
|
| 76 |
</p>
|
| 77 |
</section>
|
| 78 |
|
| 79 |
<section>
|
| 80 |
-
<p class="
|
| 81 |
-
|
| 82 |
</p>
|
| 83 |
-
<p class="
|
| 84 |
{{ sesion.tecnica.tipo_tecnica }}
|
| 85 |
</p>
|
| 86 |
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
</article>
|
| 88 |
|
| 89 |
<p class="font-bold text-2xl border-b-2">
|
|
@@ -107,8 +142,9 @@
|
|
| 107 |
<article class="flex flex-wrap gap-10">
|
| 108 |
{% if not sesion.activo %}
|
| 109 |
<button
|
| 110 |
-
class="flex-1 uppercase text-lg tracking-wider p-4 border-b-2 active:border-b-0 active:border-t-2 active:border-green-500 border-green-800 transition-all rounded-xl bg-green-600 text-white font-bold disabled:bg-amber-600 flex flex-col justify-center items-center gap-2"
|
| 111 |
-
|
|
|
|
| 112 |
<figure class="w-10">
|
| 113 |
<img src="{% static 'img/giro.svg' %}" alt="flechas girando" class="invert">
|
| 114 |
</figure>
|
|
@@ -138,6 +174,13 @@
|
|
| 138 |
<article class="bg-gray-600 p-4 text-white rounded-xl">
|
| 139 |
</article>
|
| 140 |
{% endif %}
|
|
|
|
|
|
|
|
|
|
| 141 |
</article>
|
| 142 |
</article>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
{% endblock %}
|
|
|
|
| 8 |
<article class="flex flex-col gap-8 bg-gray-400 p-10 rounded-2xl">
|
| 9 |
<header class="text-center flex-row w-full flex justify-around items-center flex-wrap gap-10">
|
| 10 |
<h1 class="text-white rounded-xl font-bold text-2xl bg-gray-600 p-4 flex-1">
|
| 11 |
+
Detalles de la sesión
|
| 12 |
</h1>
|
| 13 |
<a href="{% url 'cata_system:index' %}">
|
| 14 |
<p
|
|
|
|
| 18 |
</a>
|
| 19 |
</header>
|
| 20 |
|
| 21 |
+
{% if error %}
|
| 22 |
+
<article class="bg-red-600 p-4 text-white rounded-xl ct-notification-error">
|
| 23 |
+
<p class="block font-sans text-white text-xl antialiased font-bold uppercase tracking-wider text-center">
|
| 24 |
+
{{ error }}
|
| 25 |
+
</p>
|
| 26 |
+
</article>
|
| 27 |
+
{% endif %}
|
| 28 |
+
|
| 29 |
<p class="font-bold text-2xl border-b-2">
|
| 30 |
+
Información general
|
| 31 |
</p>
|
| 32 |
<article
|
| 33 |
class="text-white rounded-xl grid grid-cols-2 max-sm:grid-cols-1 gap-3 *:bg-gray-500 *:flex *:flex-wrap *:items-center *:justify-center *:max-sm:justify-normal *:gap-x-2 *:p-4 *:rounded-2xl">
|
| 34 |
<section class="col-span-2 max-sm:col-span-1">
|
| 35 |
+
<p class="text-xl font-bold">
|
| 36 |
Código:
|
| 37 |
</p>
|
| 38 |
+
<p class="font-sans text-xl font-normal">
|
| 39 |
{{ sesion.codigo_sesion }}
|
| 40 |
</p>
|
| 41 |
</section>
|
| 42 |
|
| 43 |
<section class="col-span-2 max-sm:col-span-1">
|
| 44 |
+
<p class="text-xl font-bold">
|
| 45 |
Nombre:
|
| 46 |
</p>
|
| 47 |
+
<p class="text-xl antialiased">
|
| 48 |
{% if sesion.nombre_sesion %}
|
| 49 |
{{ sesion.nombre_sesion }}
|
| 50 |
{% else %}
|
|
|
|
| 54 |
</section>
|
| 55 |
|
| 56 |
<section>
|
| 57 |
+
<p class="text-xl font-medium">
|
| 58 |
Fecha creación:
|
| 59 |
</p>
|
| 60 |
+
<p class="font-sans text-lg font-normal uppercase">
|
| 61 |
{{ sesion.fechaCreacion }}
|
| 62 |
</p>
|
| 63 |
</section>
|
| 64 |
|
| 65 |
<section>
|
| 66 |
+
<p class="text-lg font-bold">
|
| 67 |
Estado:
|
| 68 |
</p>
|
| 69 |
+
<p class="font-sans text-lg font-normal">
|
| 70 |
{% if sesion.activo %}
|
| 71 |
En proceso
|
| 72 |
{% else %}
|
| 73 |
+
Listo para iniciar repetición
|
| 74 |
{% endif %}
|
| 75 |
</p>
|
| 76 |
</section>
|
| 77 |
|
| 78 |
<section>
|
| 79 |
+
<p class="text-xl font-medium">
|
| 80 |
Estilo palabras:
|
| 81 |
</p>
|
| 82 |
+
<p class="font-sans text-lg font-normal uppercase">
|
| 83 |
{{ sesion.tecnica.id_estilo }}
|
| 84 |
</p>
|
| 85 |
</section>
|
| 86 |
|
| 87 |
<section>
|
| 88 |
+
<p class="text-xl font-medium">
|
| 89 |
+
Técnica:
|
| 90 |
</p>
|
| 91 |
+
<p class="font-sans text-lg font-normal uppercase">
|
| 92 |
{{ sesion.tecnica.tipo_tecnica }}
|
| 93 |
</p>
|
| 94 |
</section>
|
| 95 |
+
|
| 96 |
+
<section>
|
| 97 |
+
<p class="text-xl font-medium">
|
| 98 |
+
Rep. Hechas:
|
| 99 |
+
</p>
|
| 100 |
+
<p class="font-sans text-lg font-normal">
|
| 101 |
+
{{ sesion.tecnica.repecion }}
|
| 102 |
+
</p>
|
| 103 |
+
</section>
|
| 104 |
+
|
| 105 |
+
<section>
|
| 106 |
+
<p class="text-xl font-medium">
|
| 107 |
+
Rep. Max:
|
| 108 |
+
</p>
|
| 109 |
+
<p class="font-sans text-lg font-normal">
|
| 110 |
+
{{ sesion.tecnica.repeticiones_max }}
|
| 111 |
+
</p>
|
| 112 |
+
</section>
|
| 113 |
+
|
| 114 |
+
<section class="col-span-2 max-sm:col-span-1">
|
| 115 |
+
<p class="text-xl font-bold">
|
| 116 |
+
Instrucciones:
|
| 117 |
+
</p>
|
| 118 |
+
<p class="font-sans text-xl font-normal">
|
| 119 |
+
{{ sesion.tecnica.instrucciones }}
|
| 120 |
+
</p>
|
| 121 |
+
</section>
|
| 122 |
</article>
|
| 123 |
|
| 124 |
<p class="font-bold text-2xl border-b-2">
|
|
|
|
| 142 |
<article class="flex flex-wrap gap-10">
|
| 143 |
{% if not sesion.activo %}
|
| 144 |
<button
|
| 145 |
+
class="ct-btn-start-repition flex-1 uppercase text-lg tracking-wider p-4 border-b-2 active:border-b-0 active:border-t-2 active:border-green-500 border-green-800 transition-all rounded-xl bg-green-600 text-white font-bold disabled:bg-amber-600 flex flex-col justify-center items-center gap-2"
|
| 146 |
+
onclick="startRepetition()">
|
| 147 |
+
Iniciar repetición
|
| 148 |
<figure class="w-10">
|
| 149 |
<img src="{% static 'img/giro.svg' %}" alt="flechas girando" class="invert">
|
| 150 |
</figure>
|
|
|
|
| 174 |
<article class="bg-gray-600 p-4 text-white rounded-xl">
|
| 175 |
</article>
|
| 176 |
{% endif %}
|
| 177 |
+
<form action="" method="post" class="form-action-session hidden">
|
| 178 |
+
{% csrf_token %}
|
| 179 |
+
</form>
|
| 180 |
</article>
|
| 181 |
</article>
|
| 182 |
+
{% endblock %}
|
| 183 |
+
|
| 184 |
+
{% block extra_js %}
|
| 185 |
+
<script src="{% static 'js/details-session.js' %}"></script>
|
| 186 |
{% endblock %}
|
tecnicas/views/session_details.py
CHANGED
|
@@ -1,21 +1,27 @@
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
-
from django.shortcuts import render
|
| 3 |
-
from
|
| 4 |
-
from ..controllers import
|
| 5 |
|
| 6 |
|
| 7 |
def sessionDetails(req: HttpRequest, session_code: str):
|
| 8 |
-
|
| 9 |
-
context = {}
|
| 10 |
-
|
| 11 |
-
sesion = SesionSensorial.objects.get(codigo_sesion=session_code)
|
| 12 |
-
context["sesion"] = sesion
|
| 13 |
-
|
| 14 |
-
words = PalabrasController.getWordsInTechnique(sesion.tecnica)
|
| 15 |
-
context["palabras"] = words
|
| 16 |
-
|
| 17 |
-
rating = CalificacionController.getRatingsByTechnique(
|
| 18 |
-
technique=sesion.tecnica)
|
| 19 |
-
context["calificaciones"] = rating
|
| 20 |
|
|
|
|
| 21 |
return render(req, "tecnicas/manage_sesions/detalles-sesion.html", context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
+
from django.shortcuts import render, redirect
|
| 3 |
+
from django.urls import reverse
|
| 4 |
+
from ..controllers import DetallesSesionController
|
| 5 |
|
| 6 |
|
| 7 |
def sessionDetails(req: HttpRequest, session_code: str):
|
| 8 |
+
context = DetallesSesionController.getContextForView(session_code)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
if req.method == "GET":
|
| 11 |
return render(req, "tecnicas/manage_sesions/detalles-sesion.html", context)
|
| 12 |
+
elif req.method == "POST":
|
| 13 |
+
if req.POST["action"] == "start_session":
|
| 14 |
+
response = DetallesSesionController.startRepetition(
|
| 15 |
+
session_code, req.POST.get("username"))
|
| 16 |
+
if isinstance(response, dict):
|
| 17 |
+
context["error"] = response["error"]
|
| 18 |
+
return render(req, "tecnicas/manage_sesions/detalles-sesion.html", context)
|
| 19 |
+
|
| 20 |
+
return redirect(reverse("cata_system:----"))
|
| 21 |
+
elif req.POST.get("action") == "delete_session":
|
| 22 |
+
pass
|
| 23 |
+
elif req.POST.get("action") == "monitor_session":
|
| 24 |
+
pass
|
| 25 |
+
else:
|
| 26 |
+
context["error"] = "no se reconoce la accion a realizar"
|
| 27 |
+
return render(req, "tecnicas/manage_sesions/detalles-sesion.html", context)
|