Showing
28 changed files
with
204 additions
and
566 deletions
@@ -3,4 +3,4 @@ from rest_framework_json_api.pagination import JsonApiPageNumberPagination | @@ -3,4 +3,4 @@ from rest_framework_json_api.pagination import JsonApiPageNumberPagination | ||
3 | 3 | ||
4 | class LargePagination(JsonApiPageNumberPagination): | 4 | class LargePagination(JsonApiPageNumberPagination): |
5 | max_page_size = 300 | 5 | max_page_size = 300 |
6 | - page_size_query_param = 'page_size' | ||
6 | + page_size_query_param = 'page_size' |
project/apps/core/views.py
deleted
100644 → 0
1 | -from rest_framework import viewsets, filters, mixins, status | ||
2 | from django_filters.rest_framework import DjangoFilterBackend | 1 | from django_filters.rest_framework import DjangoFilterBackend |
3 | -from rest_framework.response import Response | 2 | +from rest_framework import viewsets, filters, mixins |
4 | from rest_framework.permissions import IsAuthenticated | 3 | from rest_framework.permissions import IsAuthenticated |
5 | -from rest_framework.decorators import action | ||
6 | 4 | ||
7 | -from .models import Edicto, Precio | ||
8 | -from .serializer import EdictoSerializer, PrecioSerializer | ||
9 | from .filters import EdictoFilter, PrecioFilter | 5 | from .filters import EdictoFilter, PrecioFilter |
6 | +from .models import Edicto, Precio | ||
10 | from .permissions import IsAdminOrAuthorized | 7 | from .permissions import IsAdminOrAuthorized |
8 | +from .serializer import EdictoSerializer, PrecioSerializer | ||
11 | 9 | ||
12 | 10 | ||
13 | class EdictoViewSet(mixins.CreateModelMixin, | 11 | class EdictoViewSet(mixins.CreateModelMixin, |
@@ -17,7 +15,7 @@ class EdictoViewSet(mixins.CreateModelMixin, | @@ -17,7 +15,7 @@ class EdictoViewSet(mixins.CreateModelMixin, | ||
17 | viewsets.GenericViewSet): | 15 | viewsets.GenericViewSet): |
18 | 16 | ||
19 | serializer_class = EdictoSerializer | 17 | serializer_class = EdictoSerializer |
20 | - permission_classes = [IsAuthenticated, ] | 18 | + permission_classes = [IsAuthenticated] |
21 | filter_backends = (DjangoFilterBackend, filters.OrderingFilter) | 19 | filter_backends = (DjangoFilterBackend, filters.OrderingFilter) |
22 | filterset_class = EdictoFilter | 20 | filterset_class = EdictoFilter |
23 | queryset = Edicto.objects.all() | 21 | queryset = Edicto.objects.all() |
@@ -31,6 +29,6 @@ class PrecioViewSet(viewsets.ReadOnlyModelViewSet): | @@ -31,6 +29,6 @@ class PrecioViewSet(viewsets.ReadOnlyModelViewSet): | ||
31 | permission_classes = [IsAuthenticated, IsAdminOrAuthorized] | 29 | permission_classes = [IsAuthenticated, IsAdminOrAuthorized] |
32 | filter_backends = (DjangoFilterBackend, filters.OrderingFilter) | 30 | filter_backends = (DjangoFilterBackend, filters.OrderingFilter) |
33 | filterset_class = PrecioFilter | 31 | filterset_class = PrecioFilter |
34 | - ordering_fields = ('usuario', ) | 32 | + ordering_fields = ('usuario',) |
35 | ordering = 'usuario' | 33 | ordering = 'usuario' |
36 | - queryset = Precio.objects.all() | ||
34 | + queryset = Precio.objects.all() |
1 | from django.utils.translation import gettext_lazy as _ | 1 | from django.utils.translation import gettext_lazy as _ |
2 | 2 | ||
3 | INICIADO = 'iniciado' | 3 | INICIADO = 'iniciado' |
4 | -PENDIENTE_REVISION= 'pendiente_revision' | 4 | +PENDIENTE_REVISION = 'pendiente_revision' |
5 | PENDIENTE_DE_PAGO = 'pendiente_de_pago' | 5 | PENDIENTE_DE_PAGO = 'pendiente_de_pago' |
6 | -PENDIENTE_PAGO_REVISION= 'pendiente_pago_revision' | 6 | +PENDIENTE_PAGO_REVISION = 'pendiente_pago_revision' |
7 | PUBLICADO = 'publicado' | 7 | PUBLICADO = 'publicado' |
8 | APROBADO = 'aprobado' | 8 | APROBADO = 'aprobado' |
9 | RECHAZADO = 'rechazado' | 9 | RECHAZADO = 'rechazado' |
10 | 10 | ||
11 | - | ||
12 | STATUS_CHOICE = [ | 11 | STATUS_CHOICE = [ |
13 | - (INICIADO, _('iniciado')), | ||
14 | - (PENDIENTE_REVISION, _('pendiente_revision')), | ||
15 | - (PENDIENTE_DE_PAGO, _('pendiente_de_pago')), | ||
16 | - (PENDIENTE_PAGO_REVISION, _('pendiente_pago_revision')), | ||
17 | - (PUBLICADO, _('publicado')), | ||
18 | - (APROBADO, _('aprobado')), | ||
19 | - (RECHAZADO, _('rechazado')), | ||
20 | - ] | ||
21 | - | 12 | + (INICIADO, _('iniciado')), |
13 | + (PENDIENTE_REVISION, _('pendiente_revision')), | ||
14 | + (PENDIENTE_DE_PAGO, _('pendiente_de_pago')), | ||
15 | + (PENDIENTE_PAGO_REVISION, _('pendiente_pago_revision')), | ||
16 | + (PUBLICADO, _('publicado')), | ||
17 | + (APROBADO, _('aprobado')), | ||
18 | + (RECHAZADO, _('rechazado')), | ||
19 | +] | ||
22 | 20 | ||
23 | EXTENSIONES_VALIDAS = "pdf", | 21 | EXTENSIONES_VALIDAS = "pdf", |
24 | 22 | ||
25 | - | ||
26 | PESOS = 'peso_argentino' | 23 | PESOS = 'peso_argentino' |
27 | DOLAR = 'dolar' | 24 | DOLAR = 'dolar' |
28 | EURO = 'euro' | 25 | EURO = 'euro' |
29 | 26 | ||
30 | - | ||
31 | MONEDA = [ | 27 | MONEDA = [ |
32 | - (PESOS, _('peso_argentino')), | ||
33 | - (DOLAR, _('dolar')), | ||
34 | - (EURO, _('euro')), | ||
35 | - ] | 28 | + (PESOS, _('peso_argentino')), |
29 | + (DOLAR, _('dolar')), | ||
30 | + (EURO, _('euro')), | ||
31 | +] |
1 | -# Generated by Django 4.1.9 on 2023-07-30 21:21 | 1 | +# Generated by Django 4.1.9 on 2023-09-21 13:18 |
2 | 2 | ||
3 | from django.conf import settings | 3 | from django.conf import settings |
4 | from django.db import migrations, models | 4 | from django.db import migrations, models |
5 | import django.db.models.deletion | 5 | import django.db.models.deletion |
6 | +import uuid | ||
6 | 7 | ||
7 | 8 | ||
8 | class Migration(migrations.Migration): | 9 | class Migration(migrations.Migration): |
9 | - | ||
10 | initial = True | 10 | initial = True |
11 | 11 | ||
12 | dependencies = [ | 12 | dependencies = [ |
@@ -15,54 +15,141 @@ class Migration(migrations.Migration): | @@ -15,54 +15,141 @@ class Migration(migrations.Migration): | ||
15 | 15 | ||
16 | operations = [ | 16 | operations = [ |
17 | migrations.CreateModel( | 17 | migrations.CreateModel( |
18 | - name='Precio', | 18 | + name="Precio", |
19 | fields=[ | 19 | fields=[ |
20 | - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
21 | - ('precio', models.FloatField(max_length=50)), | ||
22 | - ('vigencia_desde', models.DateTimeField()), | ||
23 | - ('vigencia_hasta', models.DateTimeField()), | ||
24 | - ('moneda', models.CharField(max_length=50)), | ||
25 | - ('precio_ejemplar', models.FloatField(max_length=50)), | ||
26 | - ('usuario', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | 20 | + ( |
21 | + "id", | ||
22 | + models.BigAutoField( | ||
23 | + auto_created=True, | ||
24 | + primary_key=True, | ||
25 | + serialize=False, | ||
26 | + verbose_name="ID", | ||
27 | + ), | ||
28 | + ), | ||
29 | + ("precio", models.FloatField(max_length=50)), | ||
30 | + ("vigencia_desde", models.DateField()), | ||
31 | + ("vigencia_hasta", models.DateField(blank=True, null=True)), | ||
32 | + ( | ||
33 | + "moneda", | ||
34 | + models.CharField( | ||
35 | + choices=[ | ||
36 | + ("peso_argentino", "peso_argentino"), | ||
37 | + ("dolar", "dolar"), | ||
38 | + ("euro", "euro"), | ||
39 | + ], | ||
40 | + default="peso_argentino", | ||
41 | + max_length=50, | ||
42 | + ), | ||
43 | + ), | ||
44 | + ("precio_ejemplar", models.FloatField(max_length=50)), | ||
45 | + ( | ||
46 | + "usuario", | ||
47 | + models.ForeignKey( | ||
48 | + on_delete=django.db.models.deletion.CASCADE, | ||
49 | + to=settings.AUTH_USER_MODEL, | ||
50 | + ), | ||
51 | + ), | ||
27 | ], | 52 | ], |
28 | options={ | 53 | options={ |
29 | - 'verbose_name': 'Administrador', | ||
30 | - 'verbose_name_plural': 'Administradores', | 54 | + "verbose_name": "Precio", |
55 | + "verbose_name_plural": "Precios", | ||
31 | }, | 56 | }, |
32 | ), | 57 | ), |
33 | migrations.CreateModel( | 58 | migrations.CreateModel( |
34 | - name='Edicto', | 59 | + name="Edicto", |
35 | fields=[ | 60 | fields=[ |
36 | - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
37 | - ('cuerpo_edicto', models.TextField()), | ||
38 | - ('archivo', models.FileField(upload_to='uploads/%Y/%m/%d/')), | ||
39 | - ('dias_publicar', models.PositiveIntegerField()), | ||
40 | - ('cantidad_sellos', models.PositiveIntegerField()), | ||
41 | - ('estado', models.CharField(choices=[('iniciado', 'iniciado'), ('pendiente_de_pago', 'pendiente_de_pago'), ('publicado', 'publicado'), ('aprobado', 'aprobado'), ('rechazado', 'rechazado')], default='inciado', max_length=150)), | ||
42 | - ('cantidad_palabras', models.IntegerField()), | ||
43 | - ('cantidad_copias', models.PositiveIntegerField()), | ||
44 | - ('fecha_publicacion', models.DateField()), | ||
45 | - ('fecha_creacion', models.DateTimeField(auto_now_add=True)), | ||
46 | - ('fecha_modificacion', models.DateTimeField(auto_now_add=True)), | ||
47 | - ('usuario', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Usuario')), | 61 | + ( |
62 | + "uuid", | ||
63 | + models.UUIDField( | ||
64 | + default=uuid.uuid4, | ||
65 | + editable=False, | ||
66 | + primary_key=True, | ||
67 | + serialize=False, | ||
68 | + unique=True, | ||
69 | + ), | ||
70 | + ), | ||
71 | + ("cuerpo_edicto", models.TextField()), | ||
72 | + ("archivo", models.FileField(upload_to="uploads/%Y/%m/%d/")), | ||
73 | + ("dias_publicar", models.PositiveIntegerField()), | ||
74 | + ("cantidad_sellos", models.PositiveIntegerField()), | ||
75 | + ( | ||
76 | + "estado", | ||
77 | + models.CharField( | ||
78 | + choices=[ | ||
79 | + ("iniciado", "iniciado"), | ||
80 | + ("pendiente_revision", "pendiente_revision"), | ||
81 | + ("pendiente_de_pago", "pendiente_de_pago"), | ||
82 | + ("pendiente_pago_revision", "pendiente_pago_revision"), | ||
83 | + ("publicado", "publicado"), | ||
84 | + ("aprobado", "aprobado"), | ||
85 | + ("rechazado", "rechazado"), | ||
86 | + ], | ||
87 | + default="inciado", | ||
88 | + max_length=23, | ||
89 | + ), | ||
90 | + ), | ||
91 | + ("cantidad_palabras", models.IntegerField(editable=False)), | ||
92 | + ("cantidad_copias", models.PositiveIntegerField()), | ||
93 | + ("observaciones", models.CharField(blank=True, max_length=500)), | ||
94 | + ("fecha_publicacion", models.DateField(blank=True, null=True)), | ||
95 | + ("fecha_creacion", models.DateField(auto_now_add=True)), | ||
96 | + ("fecha_modificacion", models.DateTimeField(auto_now=True)), | ||
97 | + ( | ||
98 | + "creado_por", | ||
99 | + models.ForeignKey( | ||
100 | + editable=False, | ||
101 | + on_delete=django.db.models.deletion.CASCADE, | ||
102 | + to=settings.AUTH_USER_MODEL, | ||
103 | + verbose_name="Usuario", | ||
104 | + ), | ||
105 | + ), | ||
106 | + ( | ||
107 | + "modificado_por", | ||
108 | + models.ForeignKey( | ||
109 | + editable=False, | ||
110 | + on_delete=django.db.models.deletion.CASCADE, | ||
111 | + related_name="update_edicto", | ||
112 | + to=settings.AUTH_USER_MODEL, | ||
113 | + ), | ||
114 | + ), | ||
48 | ], | 115 | ], |
49 | options={ | 116 | options={ |
50 | - 'verbose_name': 'Edicto', | ||
51 | - 'verbose_name_plural': 'Edictos', | 117 | + "verbose_name": "Edicto", |
118 | + "verbose_name_plural": "Edictos", | ||
52 | }, | 119 | }, |
53 | ), | 120 | ), |
54 | migrations.CreateModel( | 121 | migrations.CreateModel( |
55 | - name='ComprobantePago', | 122 | + name="ComprobantePago", |
56 | fields=[ | 123 | fields=[ |
57 | - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
58 | - ('resultado', models.FloatField()), | ||
59 | - ('numero_comprobante', models.CharField(max_length=300, null=True)), | ||
60 | - ('fecha_pago', models.DateTimeField(null=True)), | ||
61 | - ('edicto', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='edicto.edicto')), | 124 | + ( |
125 | + "id", | ||
126 | + models.BigAutoField( | ||
127 | + auto_created=True, | ||
128 | + primary_key=True, | ||
129 | + serialize=False, | ||
130 | + verbose_name="ID", | ||
131 | + ), | ||
132 | + ), | ||
133 | + ("monto", models.FloatField()), | ||
134 | + ( | ||
135 | + "numero_comprobante", | ||
136 | + models.CharField(blank=True, max_length=300, null=True), | ||
137 | + ), | ||
138 | + ("fecha_pago", models.DateTimeField(blank=True, null=True)), | ||
139 | + ( | ||
140 | + "archivo", | ||
141 | + models.FileField(blank=True, upload_to="uploads/%Y/%m/%d/"), | ||
142 | + ), | ||
143 | + ( | ||
144 | + "edicto", | ||
145 | + models.OneToOneField( | ||
146 | + on_delete=django.db.models.deletion.CASCADE, to="edicto.edicto" | ||
147 | + ), | ||
148 | + ), | ||
62 | ], | 149 | ], |
63 | options={ | 150 | options={ |
64 | - 'verbose_name': 'ComprobantePago', | ||
65 | - 'verbose_name_plural': 'ComprobantesPagos', | 151 | + "verbose_name": "ComprobantePago", |
152 | + "verbose_name_plural": "ComprobantesPagos", | ||
66 | }, | 153 | }, |
67 | ), | 154 | ), |
68 | ] | 155 | ] |
1 | -# Generated by Django 4.1.9 on 2023-08-02 11:36 | ||
2 | - | ||
3 | -from django.db import migrations, models | ||
4 | - | ||
5 | - | ||
6 | -class Migration(migrations.Migration): | ||
7 | - | ||
8 | - dependencies = [ | ||
9 | - ('edicto', '0001_initial'), | ||
10 | - ] | ||
11 | - | ||
12 | - operations = [ | ||
13 | - migrations.AlterField( | ||
14 | - model_name='precio', | ||
15 | - name='vigencia_desde', | ||
16 | - field=models.DateField(), | ||
17 | - ), | ||
18 | - migrations.AlterField( | ||
19 | - model_name='precio', | ||
20 | - name='vigencia_hasta', | ||
21 | - field=models.DateField(), | ||
22 | - ), | ||
23 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-08-02 12:21 | ||
2 | - | ||
3 | -from django.db import migrations, models | ||
4 | - | ||
5 | - | ||
6 | -class Migration(migrations.Migration): | ||
7 | - | ||
8 | - dependencies = [ | ||
9 | - ('edicto', '0002_alter_precio_vigencia_desde_and_more'), | ||
10 | - ] | ||
11 | - | ||
12 | - operations = [ | ||
13 | - migrations.AlterField( | ||
14 | - model_name='precio', | ||
15 | - name='moneda', | ||
16 | - field=models.CharField(choices=[('peso_argentino', 'peso_argentino'), ('dolar', 'dolar'), ('euro', 'euro')], default='peso_argentino', max_length=50), | ||
17 | - ), | ||
18 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-08-11 12:57 | ||
2 | - | ||
3 | -from django.db import migrations, models | ||
4 | - | ||
5 | - | ||
6 | -class Migration(migrations.Migration): | ||
7 | - | ||
8 | - dependencies = [ | ||
9 | - ('edicto', '0003_alter_precio_moneda'), | ||
10 | - ] | ||
11 | - | ||
12 | - operations = [ | ||
13 | - migrations.AddField( | ||
14 | - model_name='edicto', | ||
15 | - name='comentarios', | ||
16 | - field=models.CharField(blank=True, max_length=500, null=True), | ||
17 | - ), | ||
18 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-08-11 13:14 | ||
2 | - | ||
3 | -from django.db import migrations | ||
4 | - | ||
5 | - | ||
6 | -class Migration(migrations.Migration): | ||
7 | - | ||
8 | - dependencies = [ | ||
9 | - ('edicto', '0004_edicto_comentarios'), | ||
10 | - ] | ||
11 | - | ||
12 | - operations = [ | ||
13 | - migrations.RenameField( | ||
14 | - model_name='edicto', | ||
15 | - old_name='comentarios', | ||
16 | - new_name='observaciones', | ||
17 | - ), | ||
18 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-08-14 14:29 | ||
2 | - | ||
3 | -from django.db import migrations | ||
4 | - | ||
5 | - | ||
6 | -class Migration(migrations.Migration): | ||
7 | - | ||
8 | - dependencies = [ | ||
9 | - ('edicto', '0005_rename_comentarios_edicto_observaciones'), | ||
10 | - ] | ||
11 | - | ||
12 | - operations = [ | ||
13 | - migrations.RemoveField( | ||
14 | - model_name='comprobantepago', | ||
15 | - name='edicto', | ||
16 | - ), | ||
17 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-08-14 22:33 | ||
2 | - | ||
3 | -from django.conf import settings | ||
4 | -from django.db import migrations, models | ||
5 | -import django.db.models.deletion | ||
6 | - | ||
7 | - | ||
8 | -class Migration(migrations.Migration): | ||
9 | - | ||
10 | - dependencies = [ | ||
11 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
12 | - ('edicto', '0006_remove_comprobantepago_edicto'), | ||
13 | - ] | ||
14 | - | ||
15 | - operations = [ | ||
16 | - migrations.AlterField( | ||
17 | - model_name='edicto', | ||
18 | - name='usuario', | ||
19 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='Usuario', to=settings.AUTH_USER_MODEL), | ||
20 | - ), | ||
21 | - ] |
project/apps/edicto/migrations/0008_alter_edicto_fecha_publicacion_alter_edicto_usuario.py
deleted
100644 → 0
1 | -# Generated by Django 4.1.9 on 2023-08-15 00:08 | ||
2 | - | ||
3 | -from django.conf import settings | ||
4 | -from django.db import migrations, models | ||
5 | -import django.db.models.deletion | ||
6 | - | ||
7 | - | ||
8 | -class Migration(migrations.Migration): | ||
9 | - | ||
10 | - dependencies = [ | ||
11 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
12 | - ('edicto', '0007_alter_edicto_usuario'), | ||
13 | - ] | ||
14 | - | ||
15 | - operations = [ | ||
16 | - migrations.AlterField( | ||
17 | - model_name='edicto', | ||
18 | - name='fecha_publicacion', | ||
19 | - field=models.DateField(blank=True, null=True), | ||
20 | - ), | ||
21 | - migrations.AlterField( | ||
22 | - model_name='edicto', | ||
23 | - name='usuario', | ||
24 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Usuario'), | ||
25 | - ), | ||
26 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-06 10:15 | ||
2 | - | ||
3 | -from django.db import migrations, models | ||
4 | -import django.db.models.deletion | ||
5 | - | ||
6 | - | ||
7 | -class Migration(migrations.Migration): | ||
8 | - | ||
9 | - dependencies = [ | ||
10 | - ('edicto', '0008_alter_edicto_fecha_publicacion_alter_edicto_usuario'), | ||
11 | - ] | ||
12 | - | ||
13 | - operations = [ | ||
14 | - migrations.AlterModelOptions( | ||
15 | - name='precio', | ||
16 | - options={'verbose_name': 'Precio', 'verbose_name_plural': 'Precios'}, | ||
17 | - ), | ||
18 | - migrations.RenameField( | ||
19 | - model_name='comprobantepago', | ||
20 | - old_name='resultado', | ||
21 | - new_name='monto', | ||
22 | - ), | ||
23 | - migrations.AddField( | ||
24 | - model_name='comprobantepago', | ||
25 | - name='edicto', | ||
26 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='edicto.edicto'), | ||
27 | - preserve_default=False, | ||
28 | - ), | ||
29 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-06 10:52 | ||
2 | - | ||
3 | -from django.db import migrations, models | ||
4 | - | ||
5 | - | ||
6 | -class Migration(migrations.Migration): | ||
7 | - | ||
8 | - dependencies = [ | ||
9 | - ('edicto', '0009_alter_precio_options_and_more'), | ||
10 | - ] | ||
11 | - | ||
12 | - operations = [ | ||
13 | - migrations.AlterField( | ||
14 | - model_name='edicto', | ||
15 | - name='fecha_creacion', | ||
16 | - field=models.DateField(auto_now_add=True), | ||
17 | - ), | ||
18 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-08 11:10 | ||
2 | - | ||
3 | -from django.db import migrations, models | ||
4 | -import uuid | ||
5 | - | ||
6 | - | ||
7 | -class Migration(migrations.Migration): | ||
8 | - | ||
9 | - dependencies = [ | ||
10 | - ('edicto', '0010_alter_edicto_fecha_creacion'), | ||
11 | - ] | ||
12 | - | ||
13 | - operations = [ | ||
14 | - migrations.AddField( | ||
15 | - model_name='edicto', | ||
16 | - name='uuid', | ||
17 | - field=models.UUIDField(default=uuid.uuid4), | ||
18 | - ), | ||
19 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-08 11:19 | ||
2 | -from django.db import migrations, models | ||
3 | - | ||
4 | -import uuid | ||
5 | - | ||
6 | - | ||
7 | -def migrar_datos_uuid(apps, schema): | ||
8 | - Edictos = apps.get_model('edicto', 'Edicto') | ||
9 | - for edicto in Edictos.objects.all(): | ||
10 | - edicto.uuid = uuid.uuid4() | ||
11 | - edicto.save() | ||
12 | - | ||
13 | - | ||
14 | -class Migration(migrations.Migration): | ||
15 | - | ||
16 | - dependencies = [ | ||
17 | - ('edicto', '0011_edicto_uuid'), | ||
18 | - ] | ||
19 | - | ||
20 | - operations = [ | ||
21 | - migrations.RunPython(migrar_datos_uuid, reverse_code=migrations.RunPython.noop), | ||
22 | - migrations.AlterField( | ||
23 | - model_name='edicto', | ||
24 | - name='uuid', | ||
25 | - field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True), | ||
26 | - ), | ||
27 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-12 15:47 | ||
2 | - | ||
3 | -from django.db import migrations, models | ||
4 | - | ||
5 | - | ||
6 | -class Migration(migrations.Migration): | ||
7 | - | ||
8 | - dependencies = [ | ||
9 | - ('edicto', '0012_migracion_dato_uuid'), | ||
10 | - ] | ||
11 | - | ||
12 | - operations = [ | ||
13 | - migrations.AlterField( | ||
14 | - model_name='edicto', | ||
15 | - name='estado', | ||
16 | - field=models.CharField(choices=[('iniciado', 'iniciado'), ('pendiente_revision', 'pendiente_revision'), ('pendiente_de_pago', 'pendiente_de_pago'), ('pendiente_pago_revision', 'pendiente_pago_revision'), ('publicado', 'publicado'), ('aprobado', 'aprobado'), ('rechazado', 'rechazado')], default='inciado', max_length=150), | ||
17 | - ), | ||
18 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-12 21:23 | ||
2 | - | ||
3 | -from django.conf import settings | ||
4 | -from django.db import migrations, models | ||
5 | -import django.db.models.deletion | ||
6 | - | ||
7 | - | ||
8 | -class Migration(migrations.Migration): | ||
9 | - | ||
10 | - dependencies = [ | ||
11 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
12 | - ('edicto', '0013_alter_edicto_estado'), | ||
13 | - ] | ||
14 | - | ||
15 | - operations = [ | ||
16 | - migrations.AddField( | ||
17 | - model_name='edicto', | ||
18 | - name='usuario_movimiento', | ||
19 | - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='udate_edicto', to=settings.AUTH_USER_MODEL), | ||
20 | - ), | ||
21 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-12 21:24 | ||
2 | -from django.conf import settings | ||
3 | -from django.db import migrations, models | ||
4 | -import django.db.models.deletion | ||
5 | - | ||
6 | - | ||
7 | -def migrar_edicto_usuario_movi(apps, schema): | ||
8 | - Edictos = apps.get_model('edicto', 'Edicto') | ||
9 | - user_move = 1 | ||
10 | - for edicto in Edictos.objects.all(): | ||
11 | - edicto.usuario_movimiento = user_move | ||
12 | - edicto.save() | ||
13 | - user_move = user_move+1 | ||
14 | - | ||
15 | - | ||
16 | -class Migration(migrations.Migration): | ||
17 | - | ||
18 | - dependencies = [ | ||
19 | - ('edicto', '0014_edicto_usuario_movimiento'), | ||
20 | - ] | ||
21 | - | ||
22 | - operations = [ | ||
23 | - migrations.RunPython(migrar_edicto_usuario_movi, reverse_code=migrations.RunPython.noop), | ||
24 | - migrations.AlterField( | ||
25 | - model_name='edicto', | ||
26 | - name='usuario_movimiento', | ||
27 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='udate_edicto', to=settings.AUTH_USER_MODEL) | ||
28 | - ), | ||
29 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-19 13:23 | ||
2 | - | ||
3 | -from django.conf import settings | ||
4 | -from django.db import migrations, models | ||
5 | -import django.db.models.deletion | ||
6 | - | ||
7 | - | ||
8 | -class Migration(migrations.Migration): | ||
9 | - | ||
10 | - dependencies = [ | ||
11 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
12 | - ('edicto', '0015_edicto_usuario_movi'), | ||
13 | - ] | ||
14 | - | ||
15 | - operations = [ | ||
16 | - migrations.RemoveField( | ||
17 | - model_name='edicto', | ||
18 | - name='usuario', | ||
19 | - ), | ||
20 | - migrations.RemoveField( | ||
21 | - model_name='edicto', | ||
22 | - name='usuario_movimiento', | ||
23 | - ), | ||
24 | - migrations.AddField( | ||
25 | - model_name='edicto', | ||
26 | - name='creado_por', | ||
27 | - field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Usuario'), | ||
28 | - preserve_default=False, | ||
29 | - ), | ||
30 | - migrations.AddField( | ||
31 | - model_name='edicto', | ||
32 | - name='modificado_por', | ||
33 | - field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='udate_edicto', to=settings.AUTH_USER_MODEL), | ||
34 | - preserve_default=False, | ||
35 | - ), | ||
36 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-19 13:29 | ||
2 | - | ||
3 | -from django.db import migrations, models | ||
4 | -import uuid | ||
5 | - | ||
6 | - | ||
7 | -class Migration(migrations.Migration): | ||
8 | - | ||
9 | - dependencies = [ | ||
10 | - ('edicto', '0016_remove_edicto_usuario_and_more'), | ||
11 | - ] | ||
12 | - | ||
13 | - operations = [ | ||
14 | - migrations.RemoveField( | ||
15 | - model_name='edicto', | ||
16 | - name='id', | ||
17 | - ), | ||
18 | - migrations.AlterField( | ||
19 | - model_name='edicto', | ||
20 | - name='uuid', | ||
21 | - field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True), | ||
22 | - ), | ||
23 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-19 13:34 | ||
2 | - | ||
3 | -from django.db import migrations, models | ||
4 | - | ||
5 | - | ||
6 | -class Migration(migrations.Migration): | ||
7 | - | ||
8 | - dependencies = [ | ||
9 | - ('edicto', '0017_remove_edicto_id_alter_edicto_uuid'), | ||
10 | - ] | ||
11 | - | ||
12 | - operations = [ | ||
13 | - migrations.AlterField( | ||
14 | - model_name='edicto', | ||
15 | - name='fecha_modificacion', | ||
16 | - field=models.DateTimeField(auto_now=True), | ||
17 | - ), | ||
18 | - ] |
1 | -# Generated by Django 4.1.9 on 2023-09-20 13:27 | ||
2 | - | ||
3 | -from django.conf import settings | ||
4 | -from django.db import migrations, models | ||
5 | -import django.db.models.deletion | ||
6 | - | ||
7 | - | ||
8 | -class Migration(migrations.Migration): | ||
9 | - | ||
10 | - dependencies = [ | ||
11 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
12 | - ('edicto', '0018_alter_edicto_fecha_modificacion'), | ||
13 | - ] | ||
14 | - | ||
15 | - operations = [ | ||
16 | - migrations.AddField( | ||
17 | - model_name='comprobantepago', | ||
18 | - name='archivo', | ||
19 | - field=models.FileField(blank=True, upload_to='uploads/%Y/%m/%d/'), | ||
20 | - ), | ||
21 | - migrations.AlterField( | ||
22 | - model_name='comprobantepago', | ||
23 | - name='edicto', | ||
24 | - field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='edicto.edicto'), | ||
25 | - ), | ||
26 | - migrations.AlterField( | ||
27 | - model_name='comprobantepago', | ||
28 | - name='fecha_pago', | ||
29 | - field=models.DateTimeField(blank=True, null=True), | ||
30 | - ), | ||
31 | - migrations.AlterField( | ||
32 | - model_name='comprobantepago', | ||
33 | - name='monto', | ||
34 | - field=models.FloatField(editable=False), | ||
35 | - ), | ||
36 | - migrations.AlterField( | ||
37 | - model_name='comprobantepago', | ||
38 | - name='numero_comprobante', | ||
39 | - field=models.CharField(blank=True, max_length=300, null=True), | ||
40 | - ), | ||
41 | - migrations.AlterField( | ||
42 | - model_name='edicto', | ||
43 | - name='cantidad_palabras', | ||
44 | - field=models.IntegerField(editable=False), | ||
45 | - ), | ||
46 | - migrations.AlterField( | ||
47 | - model_name='edicto', | ||
48 | - name='modificado_por', | ||
49 | - field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='update_edicto', to=settings.AUTH_USER_MODEL), | ||
50 | - ), | ||
51 | - migrations.AlterField( | ||
52 | - model_name='precio', | ||
53 | - name='vigencia_hasta', | ||
54 | - field=models.DateField(blank=True, null=True), | ||
55 | - ), | ||
56 | - ] |
1 | +from uuid import uuid4 | ||
2 | + | ||
1 | from django.db import models | 3 | from django.db import models |
2 | 4 | ||
3 | -from uuid import uuid4 | 5 | +from usuario.models import Usuario |
4 | from .constants import STATUS_CHOICE, MONEDA | 6 | from .constants import STATUS_CHOICE, MONEDA |
5 | 7 | ||
6 | -from usuario.models import Usuario | ||
7 | 8 | ||
8 | # Create your models here. | 9 | # Create your models here. |
9 | 10 | ||
10 | 11 | ||
11 | -class Precio (models.Model): | 12 | +class Precio(models.Model): |
12 | precio = models.FloatField(max_length=50, blank=False, null=False) | 13 | precio = models.FloatField(max_length=50, blank=False, null=False) |
13 | vigencia_desde = models.DateField() | 14 | vigencia_desde = models.DateField() |
14 | vigencia_hasta = models.DateField(blank=True, null=True) | 15 | vigencia_hasta = models.DateField(blank=True, null=True) |
15 | usuario = models.ForeignKey(Usuario, on_delete=models.CASCADE) | 16 | usuario = models.ForeignKey(Usuario, on_delete=models.CASCADE) |
16 | - moneda = models.CharField(max_length=50, blank=False, null=False, choices=MONEDA, default='peso_argentino') | 17 | + moneda = models.CharField(max_length=50, blank=False, null=False, choices=MONEDA, |
18 | + default='peso_argentino') | ||
17 | precio_ejemplar = models.FloatField(max_length=50, blank=False, null=False) | 19 | precio_ejemplar = models.FloatField(max_length=50, blank=False, null=False) |
18 | 20 | ||
19 | class Meta: | 21 | class Meta: |
@@ -25,39 +27,42 @@ class Precio (models.Model): | @@ -25,39 +27,42 @@ class Precio (models.Model): | ||
25 | 27 | ||
26 | 28 | ||
27 | class Edicto(models.Model): | 29 | class Edicto(models.Model): |
30 | + class Meta: | ||
31 | + verbose_name = 'Edicto' | ||
32 | + verbose_name_plural = 'Edictos' | ||
33 | + | ||
28 | uuid = models.UUIDField(unique=True, editable=False, default=uuid4, primary_key=True) | 34 | uuid = models.UUIDField(unique=True, editable=False, default=uuid4, primary_key=True) |
29 | - creado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario', editable=False) | ||
30 | - cuerpo_edicto = models.TextField(blank=False, null=False) | ||
31 | - archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", null=False, blank=False) | ||
32 | - dias_publicar = models.PositiveIntegerField(blank=False, null=False) | ||
33 | - cantidad_sellos = models.PositiveIntegerField(blank=False, null=False) | ||
34 | - estado = models.CharField(max_length=150, choices=STATUS_CHOICE, default='inciado') | ||
35 | - cantidad_palabras = models.IntegerField(blank=False, null=False, editable=False) | ||
36 | - cantidad_copias = models.PositiveIntegerField(blank=False, null=False) | 35 | + cuerpo_edicto = models.TextField(blank=False) |
36 | + archivo = models.FileField(upload_to="uploads/%Y/%m/%d/") | ||
37 | + dias_publicar = models.PositiveIntegerField() | ||
38 | + cantidad_sellos = models.PositiveIntegerField() | ||
39 | + estado = models.CharField(max_length=23, choices=STATUS_CHOICE, default='inciado') | ||
40 | + cantidad_palabras = models.IntegerField(editable=False) | ||
41 | + cantidad_copias = models.PositiveIntegerField() | ||
42 | + observaciones = models.CharField(max_length=500, blank=True) | ||
43 | + | ||
37 | fecha_publicacion = models.DateField(blank=True, null=True) | 44 | fecha_publicacion = models.DateField(blank=True, null=True) |
38 | - observaciones = models.CharField(max_length=500, blank=True, null=True) | ||
39 | fecha_creacion = models.DateField(auto_now_add=True, editable=False) | 45 | fecha_creacion = models.DateField(auto_now_add=True, editable=False) |
40 | fecha_modificacion = models.DateTimeField(auto_now=True, editable=False) | 46 | fecha_modificacion = models.DateTimeField(auto_now=True, editable=False) |
41 | - modificado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, related_name='update_edicto', editable=False) | ||
42 | - | ||
43 | - class Meta: | ||
44 | - verbose_name = 'Edicto' | ||
45 | - verbose_name_plural = 'Edictos' | 47 | + creado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario', editable=False) |
48 | + modificado_por = models.ForeignKey( | ||
49 | + Usuario, on_delete=models.CASCADE, related_name='update_edicto', editable=False | ||
50 | + ) | ||
46 | 51 | ||
47 | def __str__(self): | 52 | def __str__(self): |
48 | return self.creado_por | 53 | return self.creado_por |
49 | 54 | ||
50 | 55 | ||
51 | class ComprobantePago(models.Model): | 56 | class ComprobantePago(models.Model): |
52 | - monto = models.FloatField(blank=False, null=False, editable=False) | ||
53 | - numero_comprobante = models.CharField(max_length=300, blank=True, null=True) | ||
54 | - fecha_pago = models.DateTimeField(blank=True, null=True) | ||
55 | - edicto = models.OneToOneField(Edicto, on_delete=models.CASCADE) | ||
56 | - archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", blank=True, null=False) | ||
57 | - | ||
58 | class Meta: | 57 | class Meta: |
59 | verbose_name = 'ComprobantePago' | 58 | verbose_name = 'ComprobantePago' |
60 | verbose_name_plural = 'ComprobantesPagos' | 59 | verbose_name_plural = 'ComprobantesPagos' |
61 | 60 | ||
61 | + monto = models.FloatField() | ||
62 | + numero_comprobante = models.CharField(max_length=300, blank=True, null=True) | ||
63 | + fecha_pago = models.DateTimeField(blank=True, null=True) | ||
64 | + edicto = models.OneToOneField(Edicto, on_delete=models.CASCADE) | ||
65 | + archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", blank=True) | ||
66 | + | ||
62 | def __str__(self): | 67 | def __str__(self): |
63 | return self.numero_comprobante | 68 | return self.numero_comprobante |
1 | from rest_framework import serializers | 1 | from rest_framework import serializers |
2 | 2 | ||
3 | - | 3 | +from usuario.serializers import UsuarioListaSerializer |
4 | from .constants import EXTENSIONES_VALIDAS | 4 | from .constants import EXTENSIONES_VALIDAS |
5 | - | ||
6 | from .models import Edicto, Precio | 5 | from .models import Edicto, Precio |
7 | -from usuario.serializers import UsuarioListaSerializer | ||
8 | from .utils import contador | 6 | from .utils import contador |
9 | 7 | ||
10 | 8 | ||
@@ -16,31 +14,31 @@ class EdictoSerializer(serializers.ModelSerializer): | @@ -16,31 +14,31 @@ class EdictoSerializer(serializers.ModelSerializer): | ||
16 | 14 | ||
17 | class Meta: | 15 | class Meta: |
18 | model = Edicto | 16 | model = Edicto |
19 | - fields = ('creado_por', | ||
20 | - 'modificado_por', | ||
21 | - 'estado', | ||
22 | - 'cuerpo_edicto', | ||
23 | - 'cantidad_palabras', | ||
24 | - 'dias_publicar', | ||
25 | - 'cantidad_sellos', | ||
26 | - 'cantidad_copias', | ||
27 | - 'archivo', | ||
28 | - 'fecha_creacion', | ||
29 | - 'observaciones', | ||
30 | - 'fecha_publicacion', | ||
31 | - 'fecha_modificacion' | ||
32 | - | ||
33 | - ) | 17 | + fields = ( |
18 | + 'creado_por', | ||
19 | + 'modificado_por', | ||
20 | + 'estado', | ||
21 | + 'cuerpo_edicto', | ||
22 | + 'cantidad_palabras', | ||
23 | + 'dias_publicar', | ||
24 | + 'cantidad_sellos', | ||
25 | + 'cantidad_copias', | ||
26 | + 'archivo', | ||
27 | + 'fecha_creacion', | ||
28 | + 'observaciones', | ||
29 | + 'fecha_publicacion', | ||
30 | + 'fecha_modificacion' | ||
31 | + ) | ||
34 | 32 | ||
35 | - read_only_fields = ('fecha_publicacion', | ||
36 | - ) | 33 | + read_only_fields = ('fecha_publicacion',) |
37 | 34 | ||
38 | def validate(self, data): | 35 | def validate(self, data): |
39 | - edicto = data.get('cuerpo_edicto', '') | ||
40 | - data['cantidad_palabras'] = contador(edicto) | ||
41 | request = self.context['request'] | 36 | request = self.context['request'] |
37 | + data['cantidad_palabras'] = contador(data.get('cuerpo_edicto', '')) | ||
38 | + | ||
42 | if request.method == 'POST': | 39 | if request.method == 'POST': |
43 | data['creado_por'] = request.user | 40 | data['creado_por'] = request.user |
41 | + | ||
44 | data['modificado_por'] = request.user | 42 | data['modificado_por'] = request.user |
45 | return data | 43 | return data |
46 | 44 | ||
@@ -53,17 +51,15 @@ class EdictoSerializer(serializers.ModelSerializer): | @@ -53,17 +51,15 @@ class EdictoSerializer(serializers.ModelSerializer): | ||
53 | 51 | ||
54 | 52 | ||
55 | class PrecioSerializer(serializers.ModelSerializer): | 53 | class PrecioSerializer(serializers.ModelSerializer): |
56 | - | ||
57 | class Meta: | 54 | class Meta: |
58 | model = Precio | 55 | model = Precio |
59 | - fields = ('usuario', | ||
60 | - 'moneda', | ||
61 | - 'precio', | ||
62 | - 'precio_ejemplar', | ||
63 | - 'vigencia_desde', | ||
64 | - 'vigencia_hasta', | ||
65 | - ) | 56 | + fields = ( |
57 | + 'usuario', | ||
58 | + 'moneda', | ||
59 | + 'precio', | ||
60 | + 'precio_ejemplar', | ||
61 | + 'vigencia_desde', | ||
62 | + 'vigencia_hasta', | ||
63 | + ) | ||
66 | 64 | ||
67 | - included_serializers = { | ||
68 | - 'usuario': UsuarioListaSerializer | ||
69 | - } | 65 | + included_serializers = {'usuario': UsuarioListaSerializer} |
project/apps/edicto/tests.py
deleted
100644 → 0
project/apps/edicto/views.py
deleted
100644 → 0
@@ -6,14 +6,14 @@ from django.db import migrations, models | @@ -6,14 +6,14 @@ from django.db import migrations, models | ||
6 | def asignar_valor_cuil(apps, schema): | 6 | def asignar_valor_cuil(apps, schema): |
7 | Usuario = apps.get_model('usuario', 'Usuario') | 7 | Usuario = apps.get_model('usuario', 'Usuario') |
8 | nro_cuil = 1 | 8 | nro_cuil = 1 |
9 | + | ||
9 | for usuario in Usuario.objects.all(): | 10 | for usuario in Usuario.objects.all(): |
10 | - usuario.cuil = nro_cuil | 11 | + usuario.cuil = f"cuil-fake-{nro_cuil}" |
11 | usuario.save() | 12 | usuario.save() |
12 | - nro_cuil = nro_cuil+1 | 13 | + nro_cuil += 1 |
13 | 14 | ||
14 | 15 | ||
15 | class Migration(migrations.Migration): | 16 | class Migration(migrations.Migration): |
16 | - | ||
17 | dependencies = [ | 17 | dependencies = [ |
18 | ('usuario', '0002_remove_usuario_documento_identidad_usuario_cuil'), | 18 | ('usuario', '0002_remove_usuario_documento_identidad_usuario_cuil'), |
19 | ] | 19 | ] |
-
Please register or login to post a comment