From 7990cbbca3a49d413c3fcd6807d803499864d2c5 Mon Sep 17 00:00:00 2001 From: AdalbertoCV <34152734@uaz.edu.mx> Date: Wed, 23 Oct 2024 13:02:08 -0600 Subject: [PATCH] Validaciones para datos incompletos al solicitar --- cosiap_api/dynamic_forms/views.py | 2 +- cosiap_api/dynamic_tables/DynamicTable.py | 1 - .../src/components/modalidades/Modalidad.jsx | 11 +++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cosiap_api/dynamic_forms/views.py b/cosiap_api/dynamic_forms/views.py index e6651a9..a8196c7 100644 --- a/cosiap_api/dynamic_forms/views.py +++ b/cosiap_api/dynamic_forms/views.py @@ -35,7 +35,7 @@ class BaseFormAPIView(BasePermissionAPIView): permission_classes_create = [IsAuthenticated, es_admin] permission_classes_delete = [IsAuthenticated, es_admin] - permission_classes_list = [IsAuthenticated, primer_login] + permission_classes_list = [IsAuthenticated] permission_classes_update = [IsAuthenticated, es_admin] def __init__(self): diff --git a/cosiap_api/dynamic_tables/DynamicTable.py b/cosiap_api/dynamic_tables/DynamicTable.py index ca33432..9cc1888 100644 --- a/cosiap_api/dynamic_tables/DynamicTable.py +++ b/cosiap_api/dynamic_tables/DynamicTable.py @@ -158,7 +158,6 @@ class DynamicTable(serializers.ModelSerializer): (field.related_model is not None)): related_queryset = field.related_model.objects.all() queryset = queryset.prefetch_related(Prefetch(field.name, queryset=related_queryset)) - return list(queryset) except Exception as e: # Si hay algún fallo, regresamos una lista vacía diff --git a/cosiap_frontend/src/components/modalidades/Modalidad.jsx b/cosiap_frontend/src/components/modalidades/Modalidad.jsx index 9f631e6..f8ae535 100644 --- a/cosiap_frontend/src/components/modalidades/Modalidad.jsx +++ b/cosiap_frontend/src/components/modalidades/Modalidad.jsx @@ -248,8 +248,15 @@ const SolicitarModalidad = () => { showAlert(`Error: ${errorMessage}`, false); } } catch (error) { - const specificErrorMessage = error.response?.data?.messages?.error[0] || error.message || 'Error en la conexión'; - showAlert(`Error: ${specificErrorMessage}`, false); + console.log("Error", error.response.status) + console.log(error.response.status === 403) + if (error.response.status === 403){ + showAlert('Para registrar una solicitud, por favor complete sus datos en su perfil.', false) + } + else{ + const specificErrorMessage = error.response?.data?.messages?.error[0] || error.message || 'Error en la conexión'; + showAlert(`Error: ${specificErrorMessage}`, false) + } } }; -- GitLab