lots in command add institution
This commit is contained in:
parent
abf9f31beb
commit
deffdc03f6
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue