fix: se agregan nuevos ajustes al filtro y ejecucion de procesos en base al filtro seleccionado.
This commit is contained in:
@@ -1783,14 +1783,23 @@ class EjecutarComandoView(APIView):
|
|||||||
View para ejecutar el comando de microservicios desde una petición HTTP.
|
View para ejecutar el comando de microservicios desde una petición HTTP.
|
||||||
"""
|
"""
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
# organizacion_id = request.data.get('organizacion_id', None)
|
|
||||||
|
# Obtener organizacion_id del request (si se envía)
|
||||||
|
organizacion_id_request = request.data.get('organizacionid', None)
|
||||||
procesamiento = request.data.get('procesamiento', None)
|
procesamiento = request.data.get('procesamiento', None)
|
||||||
todos = request.data.get('todos', False)
|
todos = request.data.get('todos', False)
|
||||||
|
|
||||||
if not self.request.user.is_authenticated or not hasattr(self.request.user, 'organizacion'):
|
if not self.request.user.is_authenticated or not hasattr(self.request.user, 'organizacion'):
|
||||||
raise ValueError("Usuario no autenticado o sin organización")
|
raise ValueError("Usuario no autenticado o sin organización")
|
||||||
|
|
||||||
organizacion_id = self.request.user.organizacion.id
|
if organizacion_id_request is None:
|
||||||
|
return Response(
|
||||||
|
{"error": 'No se proporcionó la organización a ejecutar el proceso.'},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST
|
||||||
|
)
|
||||||
|
|
||||||
|
# organizacion_id = self.request.user.organizacion.id
|
||||||
|
organizacion_id = organizacion_id_request
|
||||||
nombre_organizacion = self.request.user.organizacion.nombre
|
nombre_organizacion = self.request.user.organizacion.nombre
|
||||||
|
|
||||||
if procesamiento is None and todos == False:
|
if procesamiento is None and todos == False:
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ class TaskFilter(filters.FilterSet):
|
|||||||
timestamp_gte = filters.DateTimeFilter(field_name='timestamp', lookup_expr='gte')
|
timestamp_gte = filters.DateTimeFilter(field_name='timestamp', lookup_expr='gte')
|
||||||
timestamp_lte = filters.DateTimeFilter(field_name='timestamp', lookup_expr='lte')
|
timestamp_lte = filters.DateTimeFilter(field_name='timestamp', lookup_expr='lte')
|
||||||
status = filters.CharFilter(field_name='status')
|
status = filters.CharFilter(field_name='status')
|
||||||
|
organizacion = filters.UUIDFilter(field_name='organizacion__id') # Cambiado a relación directa
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Task
|
model = Task
|
||||||
fields = ['servicio', 'pedimento_app', 'pedimento', 'timestamp_gte', 'timestamp_lte', 'status']
|
fields = ['servicio', 'pedimento_app', 'pedimento', 'timestamp_gte', 'timestamp_lte', 'status', 'organizacion']
|
||||||
@@ -42,7 +42,6 @@ class TaskViewSet(LoggingMixin,viewsets.ModelViewSet,OrganizacionFiltradaMixin):
|
|||||||
Superusuarios pueden ver todas las tareas.
|
Superusuarios pueden ver todas las tareas.
|
||||||
"""
|
"""
|
||||||
queryset = self.get_queryset_filtrado_por_organizacion() # Tambien filtra por importador
|
queryset = self.get_queryset_filtrado_por_organizacion() # Tambien filtra por importador
|
||||||
# user = self.request.user
|
|
||||||
# if user.is_superuser:
|
# if user.is_superuser:
|
||||||
# return self.queryset
|
# return self.queryset
|
||||||
# # return self.queryset.filter(organizacion_id=user.organizacion.id)
|
# # return self.queryset.filter(organizacion_id=user.organizacion.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user