correcion de usuario__usuario en el filter de precio y eliminacion del metodo validate
Showing
2 changed files
with
1 additions
and
11 deletions
@@ -54,7 +54,7 @@ class PrecioViewSet(viewsets.ReadOnlyModelViewSet): | @@ -54,7 +54,7 @@ class PrecioViewSet(viewsets.ReadOnlyModelViewSet): | ||
54 | permission_classes = [IsAuthenticated, IsAdminOrAuthorized] | 54 | permission_classes = [IsAuthenticated, IsAdminOrAuthorized] |
55 | filter_backends = (DjangoFilterBackend, filters.OrderingFilter) | 55 | filter_backends = (DjangoFilterBackend, filters.OrderingFilter) |
56 | filterset_class = PrecioFilter | 56 | filterset_class = PrecioFilter |
57 | - ordering_fields = ('usuario__usuario', ) | 57 | + ordering_fields = ('usuario', ) |
58 | ordering = 'usuario' | 58 | ordering = 'usuario' |
59 | queryset = Precio.objects.all() | 59 | queryset = Precio.objects.all() |
60 | pagination_class = CustomPagination | 60 | pagination_class = CustomPagination |
@@ -57,16 +57,6 @@ class PrecioSerializer(serializers.ModelSerializer): | @@ -57,16 +57,6 @@ class PrecioSerializer(serializers.ModelSerializer): | ||
57 | 'vigencia_hasta', | 57 | 'vigencia_hasta', |
58 | ) | 58 | ) |
59 | 59 | ||
60 | - def validate(self, data): | ||
61 | - request = self.context.get('request') | ||
62 | - user = request.user if request else None | ||
63 | - if not user or user.is_anonymous: | ||
64 | - raise serializers.ValidationError("El usuario debe estar autenticado.") | ||
65 | - if not user.is_staff: | ||
66 | - raise serializers.ValidationError("El usuario no es parte del personal designado.") | ||
67 | - | ||
68 | - return data | ||
69 | - | ||
70 | included_serializers = { | 60 | included_serializers = { |
71 | 'usuario': UsuarioListaSerializer | 61 | 'usuario': UsuarioListaSerializer |
72 | } | 62 | } |
-
Please register or login to post a comment