Martín Miranda

remove migrations

Showing 28 changed files with 204 additions and 566 deletions
... ... @@ -3,4 +3,4 @@ from rest_framework_json_api.pagination import JsonApiPageNumberPagination
class LargePagination(JsonApiPageNumberPagination):
max_page_size = 300
page_size_query_param = 'page_size'
\ No newline at end of file
page_size_query_param = 'page_size'
... ...
from django.shortcuts import render
# Create your views here.
from rest_framework import viewsets, filters, mixins, status
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.response import Response
from rest_framework import viewsets, filters, mixins
from rest_framework.permissions import IsAuthenticated
from rest_framework.decorators import action
from .models import Edicto, Precio
from .serializer import EdictoSerializer, PrecioSerializer
from .filters import EdictoFilter, PrecioFilter
from .models import Edicto, Precio
from .permissions import IsAdminOrAuthorized
from .serializer import EdictoSerializer, PrecioSerializer
class EdictoViewSet(mixins.CreateModelMixin,
... ... @@ -17,7 +15,7 @@ class EdictoViewSet(mixins.CreateModelMixin,
viewsets.GenericViewSet):
serializer_class = EdictoSerializer
permission_classes = [IsAuthenticated, ]
permission_classes = [IsAuthenticated]
filter_backends = (DjangoFilterBackend, filters.OrderingFilter)
filterset_class = EdictoFilter
queryset = Edicto.objects.all()
... ... @@ -31,6 +29,6 @@ class PrecioViewSet(viewsets.ReadOnlyModelViewSet):
permission_classes = [IsAuthenticated, IsAdminOrAuthorized]
filter_backends = (DjangoFilterBackend, filters.OrderingFilter)
filterset_class = PrecioFilter
ordering_fields = ('usuario', )
ordering_fields = ('usuario',)
ordering = 'usuario'
queryset = Precio.objects.all()
\ No newline at end of file
queryset = Precio.objects.all()
... ...
from django.utils.translation import gettext_lazy as _
INICIADO = 'iniciado'
PENDIENTE_REVISION= 'pendiente_revision'
PENDIENTE_REVISION = 'pendiente_revision'
PENDIENTE_DE_PAGO = 'pendiente_de_pago'
PENDIENTE_PAGO_REVISION= 'pendiente_pago_revision'
PENDIENTE_PAGO_REVISION = 'pendiente_pago_revision'
PUBLICADO = 'publicado'
APROBADO = 'aprobado'
RECHAZADO = 'rechazado'
STATUS_CHOICE = [
(INICIADO, _('iniciado')),
(PENDIENTE_REVISION, _('pendiente_revision')),
(PENDIENTE_DE_PAGO, _('pendiente_de_pago')),
(PENDIENTE_PAGO_REVISION, _('pendiente_pago_revision')),
(PUBLICADO, _('publicado')),
(APROBADO, _('aprobado')),
(RECHAZADO, _('rechazado')),
]
(INICIADO, _('iniciado')),
(PENDIENTE_REVISION, _('pendiente_revision')),
(PENDIENTE_DE_PAGO, _('pendiente_de_pago')),
(PENDIENTE_PAGO_REVISION, _('pendiente_pago_revision')),
(PUBLICADO, _('publicado')),
(APROBADO, _('aprobado')),
(RECHAZADO, _('rechazado')),
]
EXTENSIONES_VALIDAS = "pdf",
PESOS = 'peso_argentino'
DOLAR = 'dolar'
EURO = 'euro'
MONEDA = [
(PESOS, _('peso_argentino')),
(DOLAR, _('dolar')),
(EURO, _('euro')),
]
(PESOS, _('peso_argentino')),
(DOLAR, _('dolar')),
(EURO, _('euro')),
]
... ...
# Generated by Django 4.1.9 on 2023-07-30 21:21
# Generated by Django 4.1.9 on 2023-09-21 13:18
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
... ... @@ -15,54 +15,141 @@ class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
name='Precio',
name="Precio",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('precio', models.FloatField(max_length=50)),
('vigencia_desde', models.DateTimeField()),
('vigencia_hasta', models.DateTimeField()),
('moneda', models.CharField(max_length=50)),
('precio_ejemplar', models.FloatField(max_length=50)),
('usuario', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("precio", models.FloatField(max_length=50)),
("vigencia_desde", models.DateField()),
("vigencia_hasta", models.DateField(blank=True, null=True)),
(
"moneda",
models.CharField(
choices=[
("peso_argentino", "peso_argentino"),
("dolar", "dolar"),
("euro", "euro"),
],
default="peso_argentino",
max_length=50,
),
),
("precio_ejemplar", models.FloatField(max_length=50)),
(
"usuario",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
options={
'verbose_name': 'Administrador',
'verbose_name_plural': 'Administradores',
"verbose_name": "Precio",
"verbose_name_plural": "Precios",
},
),
migrations.CreateModel(
name='Edicto',
name="Edicto",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('cuerpo_edicto', models.TextField()),
('archivo', models.FileField(upload_to='uploads/%Y/%m/%d/')),
('dias_publicar', models.PositiveIntegerField()),
('cantidad_sellos', models.PositiveIntegerField()),
('estado', models.CharField(choices=[('iniciado', 'iniciado'), ('pendiente_de_pago', 'pendiente_de_pago'), ('publicado', 'publicado'), ('aprobado', 'aprobado'), ('rechazado', 'rechazado')], default='inciado', max_length=150)),
('cantidad_palabras', models.IntegerField()),
('cantidad_copias', models.PositiveIntegerField()),
('fecha_publicacion', models.DateField()),
('fecha_creacion', models.DateTimeField(auto_now_add=True)),
('fecha_modificacion', models.DateTimeField(auto_now_add=True)),
('usuario', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Usuario')),
(
"uuid",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("cuerpo_edicto", models.TextField()),
("archivo", models.FileField(upload_to="uploads/%Y/%m/%d/")),
("dias_publicar", models.PositiveIntegerField()),
("cantidad_sellos", models.PositiveIntegerField()),
(
"estado",
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=23,
),
),
("cantidad_palabras", models.IntegerField(editable=False)),
("cantidad_copias", models.PositiveIntegerField()),
("observaciones", models.CharField(blank=True, max_length=500)),
("fecha_publicacion", models.DateField(blank=True, null=True)),
("fecha_creacion", models.DateField(auto_now_add=True)),
("fecha_modificacion", models.DateTimeField(auto_now=True)),
(
"creado_por",
models.ForeignKey(
editable=False,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
verbose_name="Usuario",
),
),
(
"modificado_por",
models.ForeignKey(
editable=False,
on_delete=django.db.models.deletion.CASCADE,
related_name="update_edicto",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
'verbose_name': 'Edicto',
'verbose_name_plural': 'Edictos',
"verbose_name": "Edicto",
"verbose_name_plural": "Edictos",
},
),
migrations.CreateModel(
name='ComprobantePago',
name="ComprobantePago",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('resultado', models.FloatField()),
('numero_comprobante', models.CharField(max_length=300, null=True)),
('fecha_pago', models.DateTimeField(null=True)),
('edicto', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='edicto.edicto')),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("monto", models.FloatField()),
(
"numero_comprobante",
models.CharField(blank=True, max_length=300, null=True),
),
("fecha_pago", models.DateTimeField(blank=True, null=True)),
(
"archivo",
models.FileField(blank=True, upload_to="uploads/%Y/%m/%d/"),
),
(
"edicto",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to="edicto.edicto"
),
),
],
options={
'verbose_name': 'ComprobantePago',
'verbose_name_plural': 'ComprobantesPagos',
"verbose_name": "ComprobantePago",
"verbose_name_plural": "ComprobantesPagos",
},
),
]
... ...
# Generated by Django 4.1.9 on 2023-08-02 11:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('edicto', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='precio',
name='vigencia_desde',
field=models.DateField(),
),
migrations.AlterField(
model_name='precio',
name='vigencia_hasta',
field=models.DateField(),
),
]
# Generated by Django 4.1.9 on 2023-08-02 12:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('edicto', '0002_alter_precio_vigencia_desde_and_more'),
]
operations = [
migrations.AlterField(
model_name='precio',
name='moneda',
field=models.CharField(choices=[('peso_argentino', 'peso_argentino'), ('dolar', 'dolar'), ('euro', 'euro')], default='peso_argentino', max_length=50),
),
]
# Generated by Django 4.1.9 on 2023-08-11 12:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('edicto', '0003_alter_precio_moneda'),
]
operations = [
migrations.AddField(
model_name='edicto',
name='comentarios',
field=models.CharField(blank=True, max_length=500, null=True),
),
]
# Generated by Django 4.1.9 on 2023-08-11 13:14
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('edicto', '0004_edicto_comentarios'),
]
operations = [
migrations.RenameField(
model_name='edicto',
old_name='comentarios',
new_name='observaciones',
),
]
# Generated by Django 4.1.9 on 2023-08-14 14:29
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('edicto', '0005_rename_comentarios_edicto_observaciones'),
]
operations = [
migrations.RemoveField(
model_name='comprobantepago',
name='edicto',
),
]
# Generated by Django 4.1.9 on 2023-08-14 22:33
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('edicto', '0006_remove_comprobantepago_edicto'),
]
operations = [
migrations.AlterField(
model_name='edicto',
name='usuario',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='Usuario', to=settings.AUTH_USER_MODEL),
),
]
# Generated by Django 4.1.9 on 2023-08-15 00:08
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('edicto', '0007_alter_edicto_usuario'),
]
operations = [
migrations.AlterField(
model_name='edicto',
name='fecha_publicacion',
field=models.DateField(blank=True, null=True),
),
migrations.AlterField(
model_name='edicto',
name='usuario',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Usuario'),
),
]
# Generated by Django 4.1.9 on 2023-09-06 10:15
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('edicto', '0008_alter_edicto_fecha_publicacion_alter_edicto_usuario'),
]
operations = [
migrations.AlterModelOptions(
name='precio',
options={'verbose_name': 'Precio', 'verbose_name_plural': 'Precios'},
),
migrations.RenameField(
model_name='comprobantepago',
old_name='resultado',
new_name='monto',
),
migrations.AddField(
model_name='comprobantepago',
name='edicto',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='edicto.edicto'),
preserve_default=False,
),
]
# Generated by Django 4.1.9 on 2023-09-06 10:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('edicto', '0009_alter_precio_options_and_more'),
]
operations = [
migrations.AlterField(
model_name='edicto',
name='fecha_creacion',
field=models.DateField(auto_now_add=True),
),
]
# Generated by Django 4.1.9 on 2023-09-08 11:10
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('edicto', '0010_alter_edicto_fecha_creacion'),
]
operations = [
migrations.AddField(
model_name='edicto',
name='uuid',
field=models.UUIDField(default=uuid.uuid4),
),
]
# Generated by Django 4.1.9 on 2023-09-08 11:19
from django.db import migrations, models
import uuid
def migrar_datos_uuid(apps, schema):
Edictos = apps.get_model('edicto', 'Edicto')
for edicto in Edictos.objects.all():
edicto.uuid = uuid.uuid4()
edicto.save()
class Migration(migrations.Migration):
dependencies = [
('edicto', '0011_edicto_uuid'),
]
operations = [
migrations.RunPython(migrar_datos_uuid, reverse_code=migrations.RunPython.noop),
migrations.AlterField(
model_name='edicto',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
),
]
# Generated by Django 4.1.9 on 2023-09-12 15:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('edicto', '0012_migracion_dato_uuid'),
]
operations = [
migrations.AlterField(
model_name='edicto',
name='estado',
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),
),
]
# Generated by Django 4.1.9 on 2023-09-12 21:23
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('edicto', '0013_alter_edicto_estado'),
]
operations = [
migrations.AddField(
model_name='edicto',
name='usuario_movimiento',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='udate_edicto', to=settings.AUTH_USER_MODEL),
),
]
# Generated by Django 4.1.9 on 2023-09-12 21:24
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
def migrar_edicto_usuario_movi(apps, schema):
Edictos = apps.get_model('edicto', 'Edicto')
user_move = 1
for edicto in Edictos.objects.all():
edicto.usuario_movimiento = user_move
edicto.save()
user_move = user_move+1
class Migration(migrations.Migration):
dependencies = [
('edicto', '0014_edicto_usuario_movimiento'),
]
operations = [
migrations.RunPython(migrar_edicto_usuario_movi, reverse_code=migrations.RunPython.noop),
migrations.AlterField(
model_name='edicto',
name='usuario_movimiento',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='udate_edicto', to=settings.AUTH_USER_MODEL)
),
]
# Generated by Django 4.1.9 on 2023-09-19 13:23
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('edicto', '0015_edicto_usuario_movi'),
]
operations = [
migrations.RemoveField(
model_name='edicto',
name='usuario',
),
migrations.RemoveField(
model_name='edicto',
name='usuario_movimiento',
),
migrations.AddField(
model_name='edicto',
name='creado_por',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Usuario'),
preserve_default=False,
),
migrations.AddField(
model_name='edicto',
name='modificado_por',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='udate_edicto', to=settings.AUTH_USER_MODEL),
preserve_default=False,
),
]
# Generated by Django 4.1.9 on 2023-09-19 13:29
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('edicto', '0016_remove_edicto_usuario_and_more'),
]
operations = [
migrations.RemoveField(
model_name='edicto',
name='id',
),
migrations.AlterField(
model_name='edicto',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True),
),
]
# Generated by Django 4.1.9 on 2023-09-19 13:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('edicto', '0017_remove_edicto_id_alter_edicto_uuid'),
]
operations = [
migrations.AlterField(
model_name='edicto',
name='fecha_modificacion',
field=models.DateTimeField(auto_now=True),
),
]
# Generated by Django 4.1.9 on 2023-09-20 13:27
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('edicto', '0018_alter_edicto_fecha_modificacion'),
]
operations = [
migrations.AddField(
model_name='comprobantepago',
name='archivo',
field=models.FileField(blank=True, upload_to='uploads/%Y/%m/%d/'),
),
migrations.AlterField(
model_name='comprobantepago',
name='edicto',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='edicto.edicto'),
),
migrations.AlterField(
model_name='comprobantepago',
name='fecha_pago',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AlterField(
model_name='comprobantepago',
name='monto',
field=models.FloatField(editable=False),
),
migrations.AlterField(
model_name='comprobantepago',
name='numero_comprobante',
field=models.CharField(blank=True, max_length=300, null=True),
),
migrations.AlterField(
model_name='edicto',
name='cantidad_palabras',
field=models.IntegerField(editable=False),
),
migrations.AlterField(
model_name='edicto',
name='modificado_por',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='update_edicto', to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='precio',
name='vigencia_hasta',
field=models.DateField(blank=True, null=True),
),
]
from uuid import uuid4
from django.db import models
from uuid import uuid4
from usuario.models import Usuario
from .constants import STATUS_CHOICE, MONEDA
from usuario.models import Usuario
# Create your models here.
class Precio (models.Model):
class Precio(models.Model):
precio = models.FloatField(max_length=50, blank=False, null=False)
vigencia_desde = models.DateField()
vigencia_hasta = models.DateField(blank=True, null=True)
usuario = models.ForeignKey(Usuario, on_delete=models.CASCADE)
moneda = models.CharField(max_length=50, blank=False, null=False, choices=MONEDA, default='peso_argentino')
moneda = models.CharField(max_length=50, blank=False, null=False, choices=MONEDA,
default='peso_argentino')
precio_ejemplar = models.FloatField(max_length=50, blank=False, null=False)
class Meta:
... ... @@ -25,39 +27,42 @@ class Precio (models.Model):
class Edicto(models.Model):
class Meta:
verbose_name = 'Edicto'
verbose_name_plural = 'Edictos'
uuid = models.UUIDField(unique=True, editable=False, default=uuid4, primary_key=True)
creado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario', editable=False)
cuerpo_edicto = models.TextField(blank=False, null=False)
archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", null=False, blank=False)
dias_publicar = models.PositiveIntegerField(blank=False, null=False)
cantidad_sellos = models.PositiveIntegerField(blank=False, null=False)
estado = models.CharField(max_length=150, choices=STATUS_CHOICE, default='inciado')
cantidad_palabras = models.IntegerField(blank=False, null=False, editable=False)
cantidad_copias = models.PositiveIntegerField(blank=False, null=False)
cuerpo_edicto = models.TextField(blank=False)
archivo = models.FileField(upload_to="uploads/%Y/%m/%d/")
dias_publicar = models.PositiveIntegerField()
cantidad_sellos = models.PositiveIntegerField()
estado = models.CharField(max_length=23, choices=STATUS_CHOICE, default='inciado')
cantidad_palabras = models.IntegerField(editable=False)
cantidad_copias = models.PositiveIntegerField()
observaciones = models.CharField(max_length=500, blank=True)
fecha_publicacion = models.DateField(blank=True, null=True)
observaciones = models.CharField(max_length=500, blank=True, null=True)
fecha_creacion = models.DateField(auto_now_add=True, editable=False)
fecha_modificacion = models.DateTimeField(auto_now=True, editable=False)
modificado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, related_name='update_edicto', editable=False)
class Meta:
verbose_name = 'Edicto'
verbose_name_plural = 'Edictos'
creado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario', editable=False)
modificado_por = models.ForeignKey(
Usuario, on_delete=models.CASCADE, related_name='update_edicto', editable=False
)
def __str__(self):
return self.creado_por
class ComprobantePago(models.Model):
monto = models.FloatField(blank=False, null=False, editable=False)
numero_comprobante = models.CharField(max_length=300, blank=True, null=True)
fecha_pago = models.DateTimeField(blank=True, null=True)
edicto = models.OneToOneField(Edicto, on_delete=models.CASCADE)
archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", blank=True, null=False)
class Meta:
verbose_name = 'ComprobantePago'
verbose_name_plural = 'ComprobantesPagos'
monto = models.FloatField()
numero_comprobante = models.CharField(max_length=300, blank=True, null=True)
fecha_pago = models.DateTimeField(blank=True, null=True)
edicto = models.OneToOneField(Edicto, on_delete=models.CASCADE)
archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", blank=True)
def __str__(self):
return self.numero_comprobante
... ...
from rest_framework import serializers
from usuario.serializers import UsuarioListaSerializer
from .constants import EXTENSIONES_VALIDAS
from .models import Edicto, Precio
from usuario.serializers import UsuarioListaSerializer
from .utils import contador
... ... @@ -16,31 +14,31 @@ class EdictoSerializer(serializers.ModelSerializer):
class Meta:
model = Edicto
fields = ('creado_por',
'modificado_por',
'estado',
'cuerpo_edicto',
'cantidad_palabras',
'dias_publicar',
'cantidad_sellos',
'cantidad_copias',
'archivo',
'fecha_creacion',
'observaciones',
'fecha_publicacion',
'fecha_modificacion'
)
fields = (
'creado_por',
'modificado_por',
'estado',
'cuerpo_edicto',
'cantidad_palabras',
'dias_publicar',
'cantidad_sellos',
'cantidad_copias',
'archivo',
'fecha_creacion',
'observaciones',
'fecha_publicacion',
'fecha_modificacion'
)
read_only_fields = ('fecha_publicacion',
)
read_only_fields = ('fecha_publicacion',)
def validate(self, data):
edicto = data.get('cuerpo_edicto', '')
data['cantidad_palabras'] = contador(edicto)
request = self.context['request']
data['cantidad_palabras'] = contador(data.get('cuerpo_edicto', ''))
if request.method == 'POST':
data['creado_por'] = request.user
data['modificado_por'] = request.user
return data
... ... @@ -53,17 +51,15 @@ class EdictoSerializer(serializers.ModelSerializer):
class PrecioSerializer(serializers.ModelSerializer):
class Meta:
model = Precio
fields = ('usuario',
'moneda',
'precio',
'precio_ejemplar',
'vigencia_desde',
'vigencia_hasta',
)
fields = (
'usuario',
'moneda',
'precio',
'precio_ejemplar',
'vigencia_desde',
'vigencia_hasta',
)
included_serializers = {
'usuario': UsuarioListaSerializer
}
included_serializers = {'usuario': UsuarioListaSerializer}
... ...
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
... ... @@ -6,14 +6,14 @@ from django.db import migrations, models
def asignar_valor_cuil(apps, schema):
Usuario = apps.get_model('usuario', 'Usuario')
nro_cuil = 1
for usuario in Usuario.objects.all():
usuario.cuil = nro_cuil
usuario.cuil = f"cuil-fake-{nro_cuil}"
usuario.save()
nro_cuil = nro_cuil+1
nro_cuil += 1
class Migration(migrations.Migration):
dependencies = [
('usuario', '0002_remove_usuario_documento_identidad_usuario_cuil'),
]
... ...