From deffdc03f62d99edd644f581b21a6bd6dc207cb4 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 25 Feb 2025 13:34:07 +0100 Subject: [PATCH] lots in command add institution --- user/management/commands/add_institution.py | 59 ++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/user/management/commands/add_institution.py b/user/management/commands/add_institution.py index 346d2fc..7bc8c9b 100644 --- a/user/management/commands/add_institution.py +++ b/user/management/commands/add_institution.py @@ -1,6 +1,6 @@ from django.core.management.base import BaseCommand from user.models import Institution -from lot.models import LotTag +from lot.models import LotTag, Lot class Command(BaseCommand): @@ -12,6 +12,7 @@ class Command(BaseCommand): def handle(self, *args, **kwargs): self.institution = Institution.objects.create(name=kwargs['name']) self.create_lot_tags() + self.create_lots() def create_lot_tags(self): LotTag.objects.create( @@ -29,3 +30,59 @@ class Command(BaseCommand): name=tag, owner=self.institution ) + + def create_lots(self): + for g in LotTag.objects.all(): + if g.name == "Entrada": + Lot.objects.create( + name="donante-orgA", + owner=self.institution, + archived=True, + type=g + ) + Lot.objects.create( + name="donante-orgB", + owner=self.institution, + type=g + ) + Lot.objects.create( + name="donante-orgC", + owner=self.institution, + type=g + ) + + if g.name == "Salida": + Lot.objects.create( + name="beneficiario-org1", + owner=self.institution, + type=g + ) + Lot.objects.create( + name="beneficiario-org2", + owner=self.institution, + archived=True, + type=g + ) + Lot.objects.create( + name="beneficiario-org3", + owner=self.institution, + type=g + ) + + if g.name == "Temporal": + Lot.objects.create( + name="palet1", + owner=self.institution, + type=g + ) + Lot.objects.create( + name="palet2", + owner=self.institution, + type=g + ) + Lot.objects.create( + name="palet3", + owner=self.institution, + archived=True, + type=g + )