Spaces:
Sleeping
Sleeping
Listado de Catadores
Browse files- tecnicas/controllers/__init__.py +2 -1
- tecnicas/controllers/views_controller/tester_list_controller.py +58 -0
- tecnicas/templates/tecnicas/components/item-tester.html +37 -0
- tecnicas/templates/tecnicas/manage_tester/catador-lista.html +52 -0
- tecnicas/templates/tecnicas/manage_tester/catadores-panel.html +8 -5
- tecnicas/urls.py +20 -13
- tecnicas/views/__init__.py +1 -0
- tecnicas/views/tester_management/tester_list.py +13 -0
tecnicas/controllers/__init__.py
CHANGED
|
@@ -16,4 +16,5 @@ from .views_controller.detalles_sesion_controller import DetallesSesionControlle
|
|
| 16 |
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
|
|
|
|
|
|
| 16 |
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
|
tecnicas/controllers/views_controller/tester_list_controller.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
| 2 |
+
from tecnicas.models import Catador
|
| 3 |
+
from tecnicas.utils import controller_error
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class TesterListController():
|
| 7 |
+
def __init__(self, page: int):
|
| 8 |
+
self.num_page = page
|
| 9 |
+
|
| 10 |
+
def getContext(self):
|
| 11 |
+
view_context = {"num_page": self.num_page}
|
| 12 |
+
|
| 13 |
+
res_tuple = TesterListController.getTestersByPage(page=self.num_page)
|
| 14 |
+
|
| 15 |
+
if isinstance(res_tuple, dict):
|
| 16 |
+
view_context["error"] = res_tuple["error"]
|
| 17 |
+
return view_context
|
| 18 |
+
|
| 19 |
+
(testers, last_page) = res_tuple
|
| 20 |
+
|
| 21 |
+
view_context["testers"] = testers
|
| 22 |
+
view_context["last_page"] = last_page
|
| 23 |
+
|
| 24 |
+
return view_context
|
| 25 |
+
|
| 26 |
+
@staticmethod
|
| 27 |
+
def getTestersByPage(page: int):
|
| 28 |
+
elements_by_page = 6
|
| 29 |
+
|
| 30 |
+
queryset = (
|
| 31 |
+
Catador.objects
|
| 32 |
+
.select_related(
|
| 33 |
+
"user"
|
| 34 |
+
)
|
| 35 |
+
.only(
|
| 36 |
+
"user__first_name",
|
| 37 |
+
"user__last_name",
|
| 38 |
+
"user__username",
|
| 39 |
+
"user__email",
|
| 40 |
+
"genero",
|
| 41 |
+
"telefono",
|
| 42 |
+
"nacimiento"
|
| 43 |
+
)
|
| 44 |
+
.order_by("-user__date_joined")
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
paginator = Paginator(queryset, elements_by_page)
|
| 48 |
+
try:
|
| 49 |
+
testers_in_page = paginator.page(page)
|
| 50 |
+
except PageNotAnInteger:
|
| 51 |
+
return controller_error("índice inválido")
|
| 52 |
+
|
| 53 |
+
if not testers_in_page.object_list:
|
| 54 |
+
return controller_error("Sin registros de Catadores")
|
| 55 |
+
|
| 56 |
+
is_last_page = not testers_in_page.number < paginator.num_pages
|
| 57 |
+
|
| 58 |
+
return (testers_in_page, is_last_page)
|
tecnicas/templates/tecnicas/components/item-tester.html
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div
|
| 2 |
+
class="card w-full min-w-2xs max-w-sm bg-surface-ligt shadow-md hover:shadow-lg transition-shadow duration-300 text-black">
|
| 3 |
+
<div class="card-body">
|
| 4 |
+
<h2 class="text-center text-lg font-bold bg-surface-sweet rounded">
|
| 5 |
+
{{ tester.user.first_name }} {{ tester.user.last_name }}
|
| 6 |
+
</h2>
|
| 7 |
+
<p class="text-lg text-center bg-surface-alter-card rounded px-2">
|
| 8 |
+
<span class="font-bold">Usuario: </span>
|
| 9 |
+
{{ tester.user.username }}
|
| 10 |
+
</p>
|
| 11 |
+
|
| 12 |
+
<div class="w-full text-base flex gap-2 flex-wrap text-center">
|
| 13 |
+
<p class="font-semibold bg-btn-secondary rounded text-white p-1">
|
| 14 |
+
<span class="font-bold">Genero:</span>
|
| 15 |
+
{{ tester.genero }}
|
| 16 |
+
</p>
|
| 17 |
+
<p class="font-semibold bg-btn-secondary rounded text-white p-1">
|
| 18 |
+
<span class="font-bold">Teléfono: </span>
|
| 19 |
+
{{ tester.telefono }}
|
| 20 |
+
</p>
|
| 21 |
+
<p class="font-semibold bg-btn-secondary rounded text-white p-1">
|
| 22 |
+
<span class="font-bold">Email: </span>
|
| 23 |
+
{{ tester.user.email }}
|
| 24 |
+
</p>
|
| 25 |
+
<p class="font-semibold bg-btn-secondary rounded text-white p-1">
|
| 26 |
+
<span class="font-bold">Nacimiento: </span>
|
| 27 |
+
{{ tester.nacimiento|date:"d/m/Y" }}
|
| 28 |
+
</p>
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
+
<div class="card-actions justify-end mt-3">
|
| 32 |
+
<button class="btn bg-btn-primary border-0 block w-full btn-push">
|
| 33 |
+
Ver detalles
|
| 34 |
+
</button>
|
| 35 |
+
</div>
|
| 36 |
+
</div>
|
| 37 |
+
</div>
|
tecnicas/templates/tecnicas/manage_tester/catador-lista.html
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends 'tecnicas/layouts/base.html' %}
|
| 2 |
+
{% load static %}
|
| 3 |
+
|
| 4 |
+
{% block title %}Lista de Catadores{% endblock %}
|
| 5 |
+
|
| 6 |
+
{% block content %}
|
| 7 |
+
<article class="cts-container-main">
|
| 8 |
+
<article class="cts-wrap-content">
|
| 9 |
+
<header class="text-center flex flex-row max-sm:flex-col gap-8 items-center w-full">
|
| 10 |
+
<div class="bg-surface-card p-4 text-black shadow-lg rounded-xl flex-1">
|
| 11 |
+
<h1 class="font-bold text-2xl">Lista de Catadores</h1>
|
| 12 |
+
</div>
|
| 13 |
+
<div class="flex-1 flex justify-end items-center">
|
| 14 |
+
<a href="{% url 'cata_system:panel_catadores' %}" class="w-fit">
|
| 15 |
+
<button class="cts-btn-general cts-btn-error btn-push">
|
| 16 |
+
Rresegar al panel anterior
|
| 17 |
+
</button>
|
| 18 |
+
</a>
|
| 19 |
+
</div>
|
| 20 |
+
</header>
|
| 21 |
+
|
| 22 |
+
{% if error %}
|
| 23 |
+
{% include "../components/error-message.html" with message=error %}
|
| 24 |
+
{% else %}
|
| 25 |
+
<div class="flex justify-center md:grid md:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
| 26 |
+
{% for tester in testers %}
|
| 27 |
+
{% include "../components/item-tester.html" with tester=tester %}
|
| 28 |
+
{% endfor %}
|
| 29 |
+
</div>
|
| 30 |
+
<section class="flex justify-center items-center gap-2">
|
| 31 |
+
<div class="join space-x-2">
|
| 32 |
+
{% if num_page != 1 %}
|
| 33 |
+
<a href="{% url 'cata_system:panel_sesiones' page=num_page|add:-1 %}" class="w-fit">
|
| 34 |
+
<button class="join-item btn bg-btn-secondary py-1">
|
| 35 |
+
<img class="h-full" src="{% static 'img/less-than.svg' %}" alt="menor que">
|
| 36 |
+
</button>
|
| 37 |
+
</a>
|
| 38 |
+
{% endif %}
|
| 39 |
+
<button class="join-item btn bg-btn-secondary">Page {{ num_page }}</button>
|
| 40 |
+
{% if not last_page %}
|
| 41 |
+
<a href="{% url 'cata_system:panel_sesiones' page=num_page|add:1 %}" class="w-fit">
|
| 42 |
+
<button class="join-item btn bg-btn-secondary py-1">
|
| 43 |
+
<img class="h-full" src="{% static 'img/greater-than.svg' %}" alt="mayor que">
|
| 44 |
+
</button>
|
| 45 |
+
</a>
|
| 46 |
+
{% endif %}
|
| 47 |
+
</div>
|
| 48 |
+
</section>
|
| 49 |
+
{% endif %}
|
| 50 |
+
</article>
|
| 51 |
+
</article>
|
| 52 |
+
{% endblock %}
|
tecnicas/templates/tecnicas/manage_tester/catadores-panel.html
CHANGED
|
@@ -28,15 +28,18 @@
|
|
| 28 |
class="w-full h-full object-cover rounded-xl">
|
| 29 |
</div>
|
| 30 |
<a href="{% url 'cata_system:crear_catador' %}" class="flex-1">
|
| 31 |
-
<button
|
| 32 |
-
class="w-full h-full text-black bg-btn-primary font-bold rounded-xl px-8 py-4 text-center border-b-green-800 btn-push">
|
| 33 |
Crear Cadator
|
| 34 |
</button>
|
| 35 |
</a>
|
| 36 |
<a href="{% url 'cata_system:buscar_catador' %}" class="flex-1">
|
| 37 |
-
<button
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
</button>
|
| 41 |
</a>
|
| 42 |
<div class="w-full h-40 rounded-2xl min-sm:hidden">
|
|
|
|
| 28 |
class="w-full h-full object-cover rounded-xl">
|
| 29 |
</div>
|
| 30 |
<a href="{% url 'cata_system:crear_catador' %}" class="flex-1">
|
| 31 |
+
<button class="w-full h-full cts-btn-general-compress cts-btn-primary btn-push">
|
|
|
|
| 32 |
Crear Cadator
|
| 33 |
</button>
|
| 34 |
</a>
|
| 35 |
<a href="{% url 'cata_system:buscar_catador' %}" class="flex-1">
|
| 36 |
+
<button class="w-full h-full cts-btn-general-compress cts-btn-secondary btn-push">
|
| 37 |
+
Buscar/Actualizar Catador
|
| 38 |
+
</button>
|
| 39 |
+
</a>
|
| 40 |
+
<a href="{% url 'cata_system:listar_catador' num_page=1 %}" class="flex-1">
|
| 41 |
+
<button class="w-full h-full cts-btn-general-compress cts-btn-tertiary btn-push">
|
| 42 |
+
Listar Catadores
|
| 43 |
</button>
|
| 44 |
</a>
|
| 45 |
<div class="w-full h-40 rounded-2xl min-sm:hidden">
|
tecnicas/urls.py
CHANGED
|
@@ -14,22 +14,10 @@ urlpatterns = [
|
|
| 14 |
views.testerLogin,
|
| 15 |
name="catador_login"),
|
| 16 |
|
|
|
|
| 17 |
# Pantalla principal Presetador
|
| 18 |
path("presenter/", views.mainPanel, name="index"),
|
| 19 |
|
| 20 |
-
# Gestion de catadores
|
| 21 |
-
path("presenter/panel-catadores",
|
| 22 |
-
views.testerMenu,
|
| 23 |
-
name="panel_catadores"),
|
| 24 |
-
|
| 25 |
-
path("presenter/crear-catador",
|
| 26 |
-
views.testerCreate,
|
| 27 |
-
name="crear_catador"),
|
| 28 |
-
|
| 29 |
-
path("presenter/buscar-catador",
|
| 30 |
-
views.testerSearch,
|
| 31 |
-
name="buscar_catador"),
|
| 32 |
-
|
| 33 |
|
| 34 |
# Creacion de sessiones sensoriales
|
| 35 |
path("presenter/seleccion-tecnica",
|
|
@@ -57,6 +45,24 @@ urlpatterns = [
|
|
| 57 |
name="creando_sesion"),
|
| 58 |
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
# Gestion de sesiones sensoriales
|
| 61 |
path("presenter/panel-sesiones/<int:page>",
|
| 62 |
views.sesionsPanel,
|
|
@@ -80,6 +86,7 @@ urlpatterns = [
|
|
| 80 |
views.convencionalScales,
|
| 81 |
name="session_convencional"),
|
| 82 |
|
|
|
|
| 83 |
# APIs
|
| 84 |
path("api/nueva-etiqueta",
|
| 85 |
views.newTag,
|
|
|
|
| 14 |
views.testerLogin,
|
| 15 |
name="catador_login"),
|
| 16 |
|
| 17 |
+
|
| 18 |
# Pantalla principal Presetador
|
| 19 |
path("presenter/", views.mainPanel, name="index"),
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Creacion de sessiones sensoriales
|
| 23 |
path("presenter/seleccion-tecnica",
|
|
|
|
| 45 |
name="creando_sesion"),
|
| 46 |
|
| 47 |
|
| 48 |
+
# Gestion de catadores
|
| 49 |
+
path("presenter/panel-catadores",
|
| 50 |
+
views.testerMenu,
|
| 51 |
+
name="panel_catadores"),
|
| 52 |
+
|
| 53 |
+
path("presenter/crear-catador",
|
| 54 |
+
views.testerCreate,
|
| 55 |
+
name="crear_catador"),
|
| 56 |
+
|
| 57 |
+
path("presenter/buscar-catador",
|
| 58 |
+
views.testerSearch,
|
| 59 |
+
name="buscar_catador"),
|
| 60 |
+
|
| 61 |
+
path("presenter/listar-catador/<int:num_page>",
|
| 62 |
+
views.testerList,
|
| 63 |
+
name="listar_catador"),
|
| 64 |
+
|
| 65 |
+
|
| 66 |
# Gestion de sesiones sensoriales
|
| 67 |
path("presenter/panel-sesiones/<int:page>",
|
| 68 |
views.sesionsPanel,
|
|
|
|
| 86 |
views.convencionalScales,
|
| 87 |
name="session_convencional"),
|
| 88 |
|
| 89 |
+
|
| 90 |
# APIs
|
| 91 |
path("api/nueva-etiqueta",
|
| 92 |
views.newTag,
|
tecnicas/views/__init__.py
CHANGED
|
@@ -16,6 +16,7 @@ from .sessions_config.create_session import createSession
|
|
| 16 |
from .tester_management.tester_menu import testerMenu
|
| 17 |
from .tester_management.tester_create import testerCreate
|
| 18 |
from .tester_management.tester_search import testerSearch
|
|
|
|
| 19 |
|
| 20 |
from .apis.api_tag import newTag
|
| 21 |
from .apis.api_words import words
|
|
|
|
| 16 |
from .tester_management.tester_menu import testerMenu
|
| 17 |
from .tester_management.tester_create import testerCreate
|
| 18 |
from .tester_management.tester_search import testerSearch
|
| 19 |
+
from .tester_management.tester_list import testerList
|
| 20 |
|
| 21 |
from .apis.api_tag import newTag
|
| 22 |
from .apis.api_words import words
|
tecnicas/views/tester_management/tester_list.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from django.shortcuts import render
|
| 3 |
+
from tecnicas.controllers import TesterListController
|
| 4 |
+
from tecnicas.utils import general_error
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def testerList(req: HttpRequest, num_page: int):
|
| 8 |
+
if req.method == "GET":
|
| 9 |
+
view_controller = TesterListController(page=num_page)
|
| 10 |
+
view_context = view_controller.getContext()
|
| 11 |
+
return render(req, "tecnicas/manage_tester/catador-lista.html", view_context)
|
| 12 |
+
else:
|
| 13 |
+
return general_error("Método no permitido")
|