Skip to content

Commit 0635011

Browse files
committed
arguably nicer thing for retrieving domain objects
1 parent ca1b0bc commit 0635011

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/allocation/adapters/repository.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self):
1919
self.django_models = models
2020

2121
def add(self, batch):
22-
self.django_models.Batch.from_domain(batch).save()
22+
self.django_models.Batch.update_from_domain(batch)
2323

2424
def get(self, reference):
2525
return (

‎src/djangoproject/alloc/models.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class Batch(models.Model):
99
eta = models.DateField(blank=True, null=True)
1010

1111
@classmethod
12-
def from_domain(self, batch: domain_model.Batch):
12+
def update_from_domain(self, batch: domain_model.Batch):
1313
try:
1414
b = Batch.objects.get(reference=batch.reference)
1515
except Batch.DoesNotExist:
1616
b = Batch(reference=batch.reference)
1717
b.sku = batch.sku
1818
b.qty = batch._purchased_quantity
1919
b.eta = batch.eta
20-
return b
20+
b.save()
2121

2222
def to_domain(self):
2323
b = domain_model.Batch(

0 commit comments

Comments
 (0)