Skip to content

Commit e551d21

Browse files
committed
WIP test fixing
1 parent 45d4160 commit e551d21

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/shop/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def _get_form_data(
714714
form_data[f"ticket-{opr.id}-INITIAL_FORMS"] = "1"
715715
form_data[f"ticket-{opr.id}-MIN_NUM_FORMS"] = "0"
716716
form_data[f"ticket-{opr.id}-MAX_NUM_FORMS"] = "1000"
717-
for index, ticket in enumerate(opr.shoptickets.all()):
717+
for index, ticket in enumerate(opr.shoptickets.order_by("-created").all()):
718718
form_data[f"ticket-{opr.id}-{index}-uuid"] = str(ticket.uuid)
719719
if ticket in refund_tickets:
720720
form_data[f"ticket-{opr.id}-{index}-refund"] = "on"
@@ -724,7 +724,7 @@ def _get_form_data(
724724
form_data[f"ticket-group-{opr.id}-INITIAL_FORMS"] = "1"
725725
form_data[f"ticket-group-{opr.id}-MIN_NUM_FORMS"] = "0"
726726
form_data[f"ticket-group-{opr.id}-MAX_NUM_FORMS"] = "1000"
727-
for index, ticket_group in enumerate(opr.ticketgroups.all()):
727+
for index, ticket_group in enumerate(opr.ticketgroups.order_by("-created").all()):
728728
form_data[f"ticket-group-{opr.id}-{index}-uuid"] = str(
729729
ticket_group.uuid,
730730
)

src/tickets/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def annotate_ticket_info(self):
246246
return self.annotate(
247247
has_used_tickets=Exists(used_tickets_subquery),
248248
has_tickets=Exists(tickets),
249-
).distinct("uuid")
249+
).distinct("uuid", "created")
250250

251251
objects = QuerySet.as_manager()
252252

src/utils/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Meta:
7171
class CreatedUpdatedModel(CleanedModel):
7272
class Meta:
7373
abstract = True
74+
ordering = ["-created"]
7475

7576
created = models.DateTimeField(auto_now_add=True)
7677
updated = models.DateTimeField(auto_now=True)
@@ -79,6 +80,7 @@ class Meta:
7980
class CreatedUpdatedUUIDModel(CleanedModel):
8081
class Meta:
8182
abstract = True
83+
ordering = ["-created"]
8284

8385
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
8486
created = models.DateTimeField(auto_now_add=True)
@@ -94,6 +96,7 @@ class CampRelatedModel(CreatedUpdatedModel):
9496

9597
class Meta:
9698
abstract = True
99+
ordering = ["-created"]
97100

98101
def save(self, **kwargs) -> None:
99102
if self.camp.read_only:

0 commit comments

Comments
 (0)