Merge branch 'feature/#45_agregar_uuid_a_los_edictos' into 'develop'
Closed feature/#45_agregar_uuid_a_los_edictos See merge request !35
Showing
3 changed files
with
48 additions
and
0 deletions
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 | from django.db import models | 1 | from django.db import models |
2 | 2 | ||
3 | +from uuid import uuid4 | ||
3 | from .constants import STATUS_CHOICE, MONEDA | 4 | from .constants import STATUS_CHOICE, MONEDA |
4 | 5 | ||
5 | from usuario.models import Usuario | 6 | from usuario.models import Usuario |
@@ -24,6 +25,7 @@ class Precio (models.Model): | @@ -24,6 +25,7 @@ class Precio (models.Model): | ||
24 | 25 | ||
25 | 26 | ||
26 | class Edicto(models.Model): | 27 | class Edicto(models.Model): |
28 | + uuid = models.UUIDField(unique=True, editable=False, default=uuid4) | ||
27 | usuario = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario') | 29 | usuario = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario') |
28 | cuerpo_edicto = models.TextField(blank=False, null=False) | 30 | cuerpo_edicto = models.TextField(blank=False, null=False) |
29 | archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", null=False, blank=False) | 31 | archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", null=False, blank=False) |
-
Please register or login to post a comment