Force items with variations to be last in the items list
@@ -54,7 +54,8 @@ def get_conference_tickets(conference: Conference, language: str) -> List[Ticket
def _is_hotel(item: dict):
return item.get("default_price") == "0.00"
- return [
+ return sorted(
+ [
TicketItem(
id=id,
name=item["name"].get("language", item["name"]["en"]),
@@ -66,7 +67,9 @@ def get_conference_tickets(conference: Conference, language: str) -> List[Ticket
variations=[
ProductVariation(
id=variation["id"],
- value=variation["value"].get(language, variation["value"]["en"]),
+ value=variation["value"].get(
+ language, variation["value"]["en"]
+ ),
description=variation["description"].get(language, ""),
active=variation["active"],
default_price=variation["default_price"],
@@ -81,4 +84,6 @@ def get_conference_tickets(conference: Conference, language: str) -> List[Ticket
)
for id, item in items.items()
if item["active"] and not _is_hotel(item)
- ]
+ ],
+ key=lambda ticket: len(ticket.variations) > 0,
+ )
