Showing
5 changed files
with
24 additions
and
7 deletions
1 | from rest_framework import viewsets, filters, mixins, status | 1 | from rest_framework import viewsets, filters, mixins, status |
2 | +from django.shortcuts import get_object_or_404 | ||
2 | from django_filters.rest_framework import DjangoFilterBackend | 3 | from django_filters.rest_framework import DjangoFilterBackend |
3 | from rest_framework.response import Response | 4 | from rest_framework.response import Response |
4 | from rest_framework.permissions import IsAuthenticated | 5 | from rest_framework.permissions import IsAuthenticated |
@@ -16,7 +17,6 @@ from .precio import calculadora | @@ -16,7 +17,6 @@ from .precio import calculadora | ||
16 | class EdictoViewSet(mixins.CreateModelMixin, | 17 | class EdictoViewSet(mixins.CreateModelMixin, |
17 | mixins.RetrieveModelMixin, | 18 | mixins.RetrieveModelMixin, |
18 | mixins.UpdateModelMixin, | 19 | mixins.UpdateModelMixin, |
19 | - mixins.DestroyModelMixin, | ||
20 | mixins.ListModelMixin, | 20 | mixins.ListModelMixin, |
21 | viewsets.GenericViewSet): | 21 | viewsets.GenericViewSet): |
22 | 22 | ||
@@ -26,7 +26,8 @@ class EdictoViewSet(mixins.CreateModelMixin, | @@ -26,7 +26,8 @@ class EdictoViewSet(mixins.CreateModelMixin, | ||
26 | filterset_class = EdictoFilter | 26 | filterset_class = EdictoFilter |
27 | queryset = Edicto.objects.all() | 27 | queryset = Edicto.objects.all() |
28 | ordering_fields = ('usuario',) | 28 | ordering_fields = ('usuario',) |
29 | - ordering = 'usuario' | 29 | + ordering = 'fecha_creacion' |
30 | + lookup_field = 'uuid' | ||
30 | 31 | ||
31 | def perform_create(self, serializer): | 32 | def perform_create(self, serializer): |
32 | edicto = self.request.data.get('cuerpo_edicto') | 33 | edicto = self.request.data.get('cuerpo_edicto') |
@@ -11,7 +11,7 @@ class EdictoFilter(filters.FilterSet): | @@ -11,7 +11,7 @@ class EdictoFilter(filters.FilterSet): | ||
11 | model = Edicto | 11 | model = Edicto |
12 | fields = {'usuario': ['exact'], | 12 | fields = {'usuario': ['exact'], |
13 | 'estado': ['exact'], | 13 | 'estado': ['exact'], |
14 | - 'id': ['exact'], | 14 | + 'uuid': ['exact'], |
15 | } | 15 | } |
16 | 16 | ||
17 | 17 |
1 | +# Generated by Django 4.1.9 on 2023-09-11 10:07 | ||
2 | + | ||
3 | +from django.db import migrations | ||
4 | + | ||
5 | + | ||
6 | +class Migration(migrations.Migration): | ||
7 | + | ||
8 | + dependencies = [ | ||
9 | + ('edicto', '0012_migracion_dato_uuid'), | ||
10 | + ('edicto', '0015_rename_archivo_comprobantepago_archivo_comprobante'), | ||
11 | + ] | ||
12 | + | ||
13 | + operations = [ | ||
14 | + ] |
@@ -44,7 +44,7 @@ class Edicto(models.Model): | @@ -44,7 +44,7 @@ class Edicto(models.Model): | ||
44 | verbose_name_plural = 'Edictos' | 44 | verbose_name_plural = 'Edictos' |
45 | 45 | ||
46 | def __str__(self): | 46 | def __str__(self): |
47 | - return f"{self.usuario} - Edicto" | 47 | + return f"{self.uuid} - Edicto" |
48 | 48 | ||
49 | 49 | ||
50 | class ComprobantePago(models.Model): | 50 | class ComprobantePago(models.Model): |
@@ -59,4 +59,5 @@ class ComprobantePago(models.Model): | @@ -59,4 +59,5 @@ class ComprobantePago(models.Model): | ||
59 | verbose_name_plural = 'ComprobantesPagos' | 59 | verbose_name_plural = 'ComprobantesPagos' |
60 | 60 | ||
61 | def __str__(self): | 61 | def __str__(self): |
62 | - return f"{self.numero_comprobante} comprobante pago de {self.edicto.usuario}" | 62 | + return f"{self.numero_comprobante} comprobante pago de {self.edicto.uuid}" |
63 | + |
@@ -14,7 +14,8 @@ class EdictoSerializer(serializers.ModelSerializer): | @@ -14,7 +14,8 @@ class EdictoSerializer(serializers.ModelSerializer): | ||
14 | 14 | ||
15 | class Meta: | 15 | class Meta: |
16 | model = Edicto | 16 | model = Edicto |
17 | - fields = ('usuario', | 17 | + fields = ('uuid', |
18 | + 'usuario', | ||
18 | 'estado', | 19 | 'estado', |
19 | 'cuerpo_edicto', | 20 | 'cuerpo_edicto', |
20 | 'cantidad_palabras', | 21 | 'cantidad_palabras', |
@@ -28,7 +29,7 @@ class EdictoSerializer(serializers.ModelSerializer): | @@ -28,7 +29,7 @@ class EdictoSerializer(serializers.ModelSerializer): | ||
28 | 29 | ||
29 | ) | 30 | ) |
30 | 31 | ||
31 | - read_only_fields = ('usuario', 'fecha_publicacion', 'cantidad_palabras', 'fecha_creacion') | 32 | + read_only_fields = ('uuid', 'usuario', 'fecha_publicacion', 'cantidad_palabras', 'fecha_creacion') |
32 | 33 | ||
33 | def to_representation(self, instance): | 34 | def to_representation(self, instance): |
34 | data = super().to_representation(instance) | 35 | data = super().to_representation(instance) |
-
Please register or login to post a comment