chartManD commited on
Commit
1fa33c7
·
1 Parent(s): 415f2d8

Listado de sesionespor Catador

Browse files
tecnicas/controllers/__init__.py CHANGED
@@ -17,4 +17,5 @@ from .views_controller.login_tester_controller import LoginTesterController
17
  from .views_controller.main_tester_form_controller import MainTesterFormController
18
  from .views_controller.api_rating_controller import ApiRatingController
19
  from .views_controller.monitor_sesion_controller import MonitorSesionController
20
- from .views_controller.tester_list_controller import TesterListController
 
 
17
  from .views_controller.main_tester_form_controller import MainTesterFormController
18
  from .views_controller.api_rating_controller import ApiRatingController
19
  from .views_controller.monitor_sesion_controller import MonitorSesionController
20
+ from .views_controller.tester_list_controller import TesterListController
21
+ from .views_controller.list_sessions_tester_controller import ListSessionsTesterController
tecnicas/controllers/views_controller/{main_panel_tester_controller.py → list_sessions_tester_controller.py} RENAMED
@@ -4,10 +4,24 @@ from tecnicas.models import Catador, SesionSensorial, Participacion
4
  from tecnicas.utils import controller_error
5
 
6
 
7
- class MainPanelTesterController():
8
  def __init__(self):
9
  pass
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  @staticmethod
12
  def getSessionByTester(page: int, tester: Catador):
13
  elements_by_page = 6
@@ -43,19 +57,20 @@ class MainPanelTesterController():
43
  participacion_finalizado=participacion_finalizado_subq,
44
  participacion_activo=participacion_activo_subq,
45
  )
46
- .order_by('activo', '-fechaCreacion')
47
  .distinct()
48
  )
49
 
50
  paginator = Paginator(queryset, elements_by_page)
51
  try:
52
- testers_in_page = paginator.page(page)
53
  except PageNotAnInteger:
54
  return controller_error("índice inválido")
55
 
56
- if not testers_in_page.object_list:
57
  return controller_error("Sin registros de Catadores")
58
 
59
- is_last_page = not testers_in_page.number < paginator.num_pages
 
60
 
61
- return (testers_in_page, is_last_page)
 
4
  from tecnicas.utils import controller_error
5
 
6
 
7
+ class ListSessionsTesterController():
8
  def __init__(self):
9
  pass
10
 
11
+ def getContext(self, user: Catador, page: int):
12
+ context_view = {}
13
+
14
+ response = ListSessionsTesterController.getSessionByTester(page, user)
15
+ if isinstance(response, dict):
16
+ return response
17
+
18
+ (sessions, is_last_page, current_page) = response
19
+ context_view["sessions"] = sessions
20
+ context_view["last_page"] = is_last_page
21
+ context_view["page"] = current_page
22
+
23
+ return context_view
24
+
25
  @staticmethod
26
  def getSessionByTester(page: int, tester: Catador):
27
  elements_by_page = 6
 
57
  participacion_finalizado=participacion_finalizado_subq,
58
  participacion_activo=participacion_activo_subq,
59
  )
60
+ .order_by('participacion_finalizado', '-activo', '-fechaCreacion')
61
  .distinct()
62
  )
63
 
64
  paginator = Paginator(queryset, elements_by_page)
65
  try:
66
+ sessions_in_page = paginator.page(page)
67
  except PageNotAnInteger:
68
  return controller_error("índice inválido")
69
 
70
+ if not sessions_in_page.object_list:
71
  return controller_error("Sin registros de Catadores")
72
 
73
+ current_page = sessions_in_page.number
74
+ is_last_page = not current_page < paginator.num_pages
75
 
76
+ return (sessions_in_page, is_last_page, current_page)
tecnicas/middlewares/tester_middleware.py CHANGED
@@ -9,12 +9,12 @@ class TesterAccessMiddleware:
9
  def __call__(self, request):
10
  path = request.path_info
11
 
12
- if path.startswith('/cata/tester/'):
13
  if not request.user.is_authenticated:
14
  from django.shortcuts import redirect
15
  return redirect("cata_system:catador_login")
16
 
17
- if not hasattr(request.user, 'catador'):
18
  return redirect("cata_system:catador_login")
19
 
20
  return self.get_response(request)
 
9
  def __call__(self, request):
10
  path = request.path_info
11
 
12
+ if path.startswith('/cata/testers/'):
13
  if not request.user.is_authenticated:
14
  from django.shortcuts import redirect
15
  return redirect("cata_system:catador_login")
16
 
17
+ if not hasattr(request.user, 'user_catador'):
18
  return redirect("cata_system:catador_login")
19
 
20
  return self.get_response(request)
tecnicas/templates/tecnicas/components/item_session.html ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div
2
+ class='card {{ sesion.activo|yesno:"bg-surface-ligt,bg-surface-card" }} shadow-lg text-black sm:max-w-80 w-full flex justify-center items-center'>
3
+ <div class="card-body flex flex-col justify-between w-full">
4
+ <div class="flex flex-col gap-1 [&>*]:first:text-xl [&>*]:first:font-bold [&>*]:first:border-b">
5
+ {% if sesion.nombre_sesion %}
6
+ <h2>{{ sesion.nombre_sesion }}</h2>
7
+ <span class="text-lg underline"><b>Código:</b><br>{{ sesion.codigo_sesion }}</span>
8
+ {% else %}
9
+ <span class="text-lg">Código:<br>{{ sesion.codigo_sesion }}</span>
10
+ {% endif %}
11
+ </div>
12
+ <ul class="mt-6 flex flex-col gap-2 text-base">
13
+ <li>
14
+ Se usa la Técnica:
15
+ <span class="uppercase font-bold">
16
+ {{ sesion.tecnica.tipo_tecnica.nombre_tecnica }}
17
+ </span>
18
+ </li>
19
+ <li>
20
+ El Estilo de palabras:
21
+ <span class="uppercase font-bold">
22
+ {{ sesion.tecnica.id_estilo.nombre_estilo }}
23
+ </span>
24
+ </li>
25
+ <li>
26
+ {{ sesion.fechaCreacion }}
27
+ </li>
28
+ <li>
29
+ Estado:
30
+ <span class="uppercase font-bold">
31
+ {% if sesion.activo %}
32
+ Activo
33
+ {% else %}
34
+ No activo
35
+ {% endif %}
36
+ </span>
37
+ </li>
38
+ </ul>
39
+ <div class="mt-6">
40
+ <a href="{% url 'cata_system:detalles_sesion' session_code=sesion.codigo_sesion %}">
41
+ <button class="btn bg-btn-primary border-0 block w-full btn-push">
42
+ Inspeccionar sesión
43
+ </button>
44
+ </a>
45
+ </div>
46
+ </div>
47
+ </div>
tecnicas/templates/tecnicas/components/item_session_tester.html ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="card bg-surface-sweet border border-base-300 shadow-md hover:shadow-lg transition">
2
+ <div class="card-body space-y-4">
3
+ <h4 class="card-title text-lg font-bold">
4
+ {% if session.nombre_sesion %}
5
+ {{ session.nombre_sesion }}
6
+ {% else %}
7
+ <span class="italic text-gray-500">Sin nombre</span>
8
+ {% endif %}
9
+ </h4>
10
+
11
+ <article class="text-sm space-y-1">
12
+ <p><span class="font-semibold">Código:</span> {{ session.codigo_sesion }}</p>
13
+ <p><span class="font-semibold">Técnica:</span> {{ session.tecnica.tipo_tecnica }}</p>
14
+ <p><span class="font-semibold">Fecha:</span> {{ session.fechaCreacion }}</p>
15
+ <p>
16
+ <span class="font-semibold">Finazliado:</span>
17
+ {% if session.participacion_finalizado %}
18
+ <span class="badge badge-success">Se ha concluido</span>
19
+ {% else %}
20
+ <span class="badge badge-warning">Sin concluir</span>
21
+ {% endif %}
22
+ </p>
23
+ <p>
24
+ <span class="font-semibold">Estatus:</span>
25
+ {% if session.activo %}
26
+ <span class="badge badge-success">En proceso</span>
27
+ {% else %}
28
+ <span class="badge badge-error">No activo</span>
29
+ {% endif %}
30
+ </p>
31
+ </article>
32
+ <article>
33
+ <a href="{% url 'cata_system:catador_init_session' code_sesion=session.codigo_sesion %}">
34
+ <button class="btn bg-btn-primary border-0 block w-full btn-push">
35
+ Inspeccionar
36
+ </button>
37
+ </a>
38
+ </article>
39
+ </div>
40
+ </div>
tecnicas/templates/tecnicas/forms_tester/init_session.html CHANGED
@@ -113,10 +113,10 @@
113
  </figure>
114
  </button>
115
  {% endif %}
116
- <a href="{% url 'cata_system:catador_main' %}">
117
  <button
118
  class="flex-1 uppercase text-lg tracking-wider cts-btn-general cts-btn-error btn-push flex flex-col justify-center items-center gap-2">
119
- Salir se la sesión
120
  <figure class="w-10">
121
  <img src="{% static 'img/exit.svg' %}" alt="bote de basura" class="invert">
122
  </figure>
 
113
  </figure>
114
  </button>
115
  {% endif %}
116
+ <a href="{% url 'cata_system:catador_list_sessions' num_page=1 %}">
117
  <button
118
  class="flex-1 uppercase text-lg tracking-wider cts-btn-general cts-btn-error btn-push flex flex-col justify-center items-center gap-2">
119
+ Regresar a la lista
120
  <figure class="w-10">
121
  <img src="{% static 'img/exit.svg' %}" alt="bote de basura" class="invert">
122
  </figure>
tecnicas/templates/tecnicas/forms_tester/main_panel_tester.html CHANGED
@@ -11,11 +11,9 @@
11
  <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">
12
  <h2 class="card-title text-2xl font-semibold">Información del Usuario</h2>
13
 
14
- <a href="{% url 'cata_system:catador_in_session' %}">
15
- <button class="cts-btn-general-compress px-4 py-2 cts-btn-primary btn-push">
16
- + Nueva sesión
17
- </button>
18
- </a>
19
  </div>
20
 
21
  <div class="divider my-3"></div>
@@ -49,76 +47,22 @@
49
  </div>
50
  </div>
51
 
52
- <div class="space-y-4">
53
- <h3 class="text-xl font-semibold">Sesiones en las que ha participado</h3>
54
-
55
- <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
56
- {% for sesion in sesiones %}
57
- <div class="card bg-base-100 border border-base-300 shadow-md hover:shadow-lg transition">
58
- <div class="card-body">
59
- <h4 class="card-title text-lg font-bold">
60
- {% if sesion.nombre %}
61
- {{ sesion.nombre }}
62
- {% else %}
63
- <span class="italic text-gray-500">Sin nombre</span>
64
- {% endif %}
65
- </h4>
66
-
67
- <div class="text-sm space-y-1">
68
- <p><span class="font-semibold">Código:</span> {{ sesion.codigo }}</p>
69
- <p><span class="font-semibold">Técnica:</span> {{ sesion.tecnica }}</p>
70
- <p><span class="font-semibold">Fecha:</span> {{ sesion.fecha_creacion }}</p>
71
- <p>
72
- <span class="font-semibold">Finazliado:</span>
73
- {% if sesion.finalizado %}
74
- <span class="badge badge-success">Se ha concluido</span>
75
- {% else %}
76
- <span class="badge badge-warning">Sin concluir</span>
77
- {% endif %}
78
- </p>
79
- {% if sesion.activo %}
80
- <p>
81
- <span class="font-semibold">Estatus:</span>
82
- <span class="badge badge-success">En proceso</span>
83
- </p>
84
- {% endif %}
85
- </div>
86
- </div>
87
- </div>
88
- {% empty %}
89
- <div class="col-span-full text-center text-gray-500">
90
- No hay sesiones registradas.
91
- </div>
92
- {% endfor %}
93
- </div>
94
-
95
- {% if sesiones.has_other_pages %}
96
- <div class="flex justify-center mt-6">
97
- <div class="join">
98
- {% if sesiones.has_previous %}
99
- <a href="/" class="join-item btn btn-sm">«</a>
100
- {% else %}
101
- <button class="join-item btn btn-sm btn-disabled">«</button>
102
- {% endif %}
103
-
104
- {% for num in sesiones.paginator.page_range %}
105
- {% if sesiones.number == num %}
106
- <button class="join-item btn btn-sm btn-active">{{ num }}</button>
107
- {% else %}
108
- <a href="/" class="join-item btn btn-sm">{{ num }}</a>
109
- {% endif %}
110
- {% endfor %}
111
-
112
- {% if sesiones.has_next %}
113
- <a href="/" class="join-item btn btn-sm">»</a>
114
- {% else %}
115
- <button class="join-item btn btn-sm btn-disabled">»</button>
116
- {% endif %}
117
- </div>
118
  </div>
119
- {% endif %}
120
  </div>
121
- </div>
122
  </article>
123
  </article>
124
  {% endblock %}
 
11
  <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">
12
  <h2 class="card-title text-2xl font-semibold">Información del Usuario</h2>
13
 
14
+ <button class="cts-btn-general-compress px-4 py-2 cts-btn-error btn-push">
15
+ Salir del Sistema
16
+ </button>
 
 
17
  </div>
18
 
19
  <div class="divider my-3"></div>
 
47
  </div>
48
  </div>
49
 
50
+ <div class="card bg-surface-card shadow-lg">
51
+ <div class="card-body">
52
+ <article class="flex flex-wrap gap-4 max-sm:flex-col justify-center">
53
+ <a href="{% url 'cata_system:catador_in_session' %}" class="w-fit max-sm:w-full grow">
54
+ <button class="cts-btn-general-compress px-4 py-2 cts-btn-primary btn-push w-full">
55
+ Nueva sesión
56
+ </button>
57
+ </a>
58
+ <a href="{% url 'cata_system:catador_list_sessions' num_page=1 %}" class="w-fit max-sm:w-full grow">
59
+ <button class="cts-btn-general-compress px-4 py-2 cts-btn-primary btn-push w-full">
60
+ 🔍 Ver sesiones
61
+ </button>
62
+ </a>
63
+ </article>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  </div>
 
65
  </div>
 
66
  </article>
67
  </article>
68
  {% endblock %}
tecnicas/templates/tecnicas/forms_tester/sessions_list_tester.html ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'tecnicas/layouts/base.html' %}
2
+
3
+ {% block title %}Panel Principal Tester{% endblock %}
4
+
5
+ {% block content %}
6
+ <article class="cts-container-main">
7
+ <article class="cts-wrap-content text-black">
8
+ <header class="text-center flex flex-row max-sm:flex-col gap-8 items-center w-full">
9
+ <div class="bg-surface-card p-4 text-black shadow-lg rounded-xl flex-1">
10
+ <h1 class="font-bold text-2xl">
11
+ Lista de Sesiones en las
12
+ que se ha participado
13
+ </h1>
14
+ </div>
15
+ <div class="flex-1 flex justify-end items-center">
16
+ <a href="{% url 'cata_system:catador_main' %}" class="w-fit">
17
+ <button class="cts-btn-general cts-btn-secondary btn-push">
18
+ Regresar Panel principal
19
+ </button>
20
+ </a>
21
+ </div>
22
+ </header>
23
+
24
+ {% if error %}
25
+ {% include "../components/error-message.html" with message=error %}
26
+ {% endif %}
27
+ {% if message %}
28
+ {% include "../components/error-message.html" with message=message %}
29
+ {% endif %}
30
+
31
+ <div class="space-y-4">
32
+ <h3 class="text-xl font-semibold">Sesiones en las que ha participado</h3>
33
+ <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
34
+ {% for session in sessions %}
35
+ {% include "../components/item_session_tester.html" with session=session %}
36
+ {% empty %}
37
+ <div class="col-span-full text-center text-gray-500">
38
+ No hay sesiones registradas.
39
+ </div>
40
+ {% endfor %}
41
+ </div>
42
+
43
+ <section class="flex justify-center items-center gap-2">
44
+ <div class="join space-x-2">
45
+ {% if page != 1 %}
46
+ <a href="{% url 'cata_system:catador_list_sessions' num_page=page|add:-1 %}" class="w-fit">
47
+ <button class="join-item btn bg-btn-secondary py-1 text-2xl">
48
+ ⏮️
49
+ </button>
50
+ </a>
51
+ {% endif %}
52
+ <button class="join-item btn bg-btn-secondary">Page {{ page }}</button>
53
+ {% if not last_page %}
54
+ <a href="{% url 'cata_system:catador_list_sessions' num_page=page|add:1 %}" class="w-fit">
55
+ <button class="join-item btn bg-btn-secondary py-1 text-2xl">
56
+ ⏭️
57
+ </button>
58
+ </a>
59
+ {% endif %}
60
+ </div>
61
+ </section>
62
+ </div>
63
+ </article>
64
+ </article>
65
+ {% endblock %}
tecnicas/templates/tecnicas/manage_sesions/sesiones-panel.html CHANGED
@@ -22,55 +22,10 @@
22
  {% if error %}
23
  {% include "../components/error-message.html" with message=error %}
24
  {% else %}
 
25
  <section class="grid grid-cols-3 max-lg:grid-cols-2 max-sm:grid-cols-1 w-full gap-4 justify-center">
26
  {% for sesion in sessions %}
27
- <div
28
- class='card {{ sesion.activo|yesno:"bg-surface-ligt,bg-surface-card" }} shadow-lg text-black sm:max-w-80 w-full flex justify-center items-center'>
29
- <div class="card-body flex flex-col justify-between w-full">
30
- <div class="flex flex-col gap-1 [&>*]:first:text-xl [&>*]:first:font-bold [&>*]:first:border-b">
31
- {% if sesion.nombre_sesion %}
32
- <h2>{{ sesion.nombre_sesion }}</h2>
33
- <span class="text-lg underline"><b>Código:</b><br>{{ sesion.codigo_sesion }}</span>
34
- {% else %}
35
- <span class="text-lg">Código:<br>{{ sesion.codigo_sesion }}</span>
36
- {% endif %}
37
- </div>
38
- <ul class="mt-6 flex flex-col gap-2 text-base">
39
- <li>
40
- Se usa la Técnica:
41
- <span class="uppercase font-bold">
42
- {{ sesion.tecnica.tipo_tecnica.nombre_tecnica }}
43
- </span>
44
- </li>
45
- <li>
46
- El Estilo de palabras:
47
- <span class="uppercase font-bold">
48
- {{ sesion.tecnica.id_estilo.nombre_estilo }}
49
- </span>
50
- </li>
51
- <li>
52
- {{ sesion.fechaCreacion }}
53
- </li>
54
- <li>
55
- Estado:
56
- <span class="uppercase font-bold">
57
- {% if sesion.activo %}
58
- Activo
59
- {% else %}
60
- No activo
61
- {% endif %}
62
- </span>
63
- </li>
64
- </ul>
65
- <div class="mt-6">
66
- <a href="{% url 'cata_system:detalles_sesion' session_code=sesion.codigo_sesion %}">
67
- <button class="btn bg-btn-primary border-0 block w-full btn-push">
68
- Inspeccionar sesión
69
- </button>
70
- </a>
71
- </div>
72
- </div>
73
- </div>
74
  {% endfor %}
75
  </section>
76
 
 
22
  {% if error %}
23
  {% include "../components/error-message.html" with message=error %}
24
  {% else %}
25
+
26
  <section class="grid grid-cols-3 max-lg:grid-cols-2 max-sm:grid-cols-1 w-full gap-4 justify-center">
27
  {% for sesion in sessions %}
28
+ {% include "./components/item_session.html" with sesion=sesion %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  {% endfor %}
30
  </section>
31
 
tecnicas/urls.py CHANGED
@@ -82,6 +82,10 @@ urlpatterns = [
82
  views.mainPanelTester,
83
  name="catador_main"),
84
 
 
 
 
 
85
  path("testers/log-in-session",
86
  views.loginSessionTester,
87
  name="catador_in_session"),
 
82
  views.mainPanelTester,
83
  name="catador_main"),
84
 
85
+ path("testers/catador-list-sessions/<int:num_page>",
86
+ views.sessionsListTester,
87
+ name="catador_list_sessions"),
88
+
89
  path("testers/log-in-session",
90
  views.loginSessionTester,
91
  name="catador_in_session"),
tecnicas/views/__init__.py CHANGED
@@ -26,3 +26,4 @@ from .tester_forms.init_tester_form import initTesterForm
26
  from .tester_forms.convencional_scales import convencionalScales
27
  from .tester_forms.panel_main_tester import mainPanelTester
28
  from .tester_forms.login_session import loginSessionTester
 
 
26
  from .tester_forms.convencional_scales import convencionalScales
27
  from .tester_forms.panel_main_tester import mainPanelTester
28
  from .tester_forms.login_session import loginSessionTester
29
+ from .tester_forms.sessions_list_tester import sessionsListTester
tecnicas/views/tester_forms/sessions_list_tester.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.http import HttpRequest, JsonResponse
2
+ from django.shortcuts import render
3
+ from tecnicas.controllers import ListSessionsTesterController
4
+
5
+
6
+ def sessionsListTester(req: HttpRequest, num_page: int):
7
+ if req.method == "GET":
8
+ view_controller = ListSessionsTesterController()
9
+ contex_view = view_controller.getContext(req.user.user_catador, num_page)
10
+
11
+ return render(req, "tecnicas/forms_tester/sessions_list_tester.html", contex_view)
12
+ else:
13
+ return JsonResponse({"message": "Método no permitido"})