Martín Miranda

Merge branch 'fix/modelo_edicto' into 'develop'

Fix/modelo edicto



See merge request !53
@@ -63,7 +63,6 @@ class Migration(migrations.Migration): @@ -63,7 +63,6 @@ class Migration(migrations.Migration):
63 models.UUIDField( 63 models.UUIDField(
64 default=uuid.uuid4, 64 default=uuid.uuid4,
65 editable=False, 65 editable=False,
66 - primary_key=True,  
67 serialize=False, 66 serialize=False,
68 unique=True, 67 unique=True,
69 ), 68 ),
  1 +# Generated by Django 4.1.9 on 2023-09-25 11:23
  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.RemoveField(
  14 + model_name='edicto',
  15 + name='uuid',
  16 + ),
  17 + migrations.AddField(
  18 + model_name='edicto',
  19 + name='id',
  20 + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
  21 + preserve_default=False,
  22 + ),
  23 + ]
  1 +# Generated by Django 4.1.9 on 2023-09-25 11:29
  2 +
  3 +from django.db import migrations, models
  4 +import uuid
  5 +
  6 +
  7 +class Migration(migrations.Migration):
  8 +
  9 + dependencies = [
  10 + ('edicto', '0002_remove_edicto_uuid_edicto_id'),
  11 + ]
  12 +
  13 + operations = [
  14 + migrations.AddField(
  15 + model_name='edicto',
  16 + name='uuid',
  17 + field=models.UUIDField(default=uuid.uuid4, editable=False, null=True, unique=True),
  18 + ),
  19 + ]
  1 +# Generated by Django 4.1.9 on 2023-09-25 11:35
  2 +
  3 +from django.db import migrations, models
  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', '0003_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 + ]
@@ -31,7 +31,7 @@ class Edicto(models.Model): @@ -31,7 +31,7 @@ class Edicto(models.Model):
31 verbose_name = 'Edicto' 31 verbose_name = 'Edicto'
32 verbose_name_plural = 'Edictos' 32 verbose_name_plural = 'Edictos'
33 33
34 - uuid = models.UUIDField(unique=True, editable=False, default=uuid4, primary_key=True) 34 + uuid = models.UUIDField(unique=True, editable=False, default=uuid4)
35 cuerpo_edicto = models.TextField(blank=False) 35 cuerpo_edicto = models.TextField(blank=False)
36 archivo = models.FileField(upload_to="uploads/%Y/%m/%d/") 36 archivo = models.FileField(upload_to="uploads/%Y/%m/%d/")
37 dias_publicar = models.PositiveIntegerField() 37 dias_publicar = models.PositiveIntegerField()
@@ -15,6 +15,7 @@ class EdictoSerializer(serializers.ModelSerializer): @@ -15,6 +15,7 @@ class EdictoSerializer(serializers.ModelSerializer):
15 class Meta: 15 class Meta:
16 model = Edicto 16 model = Edicto
17 fields = ( 17 fields = (
  18 + 'uuid',
18 'creado_por', 19 'creado_por',
19 'modificado_por', 20 'modificado_por',
20 'estado', 21 'estado',