Fixed broken wishlist page

This commit is contained in:
Frederik Baerentsen
2025-09-17 16:49:53 +02:00
parent 5fa145a9d7
commit 6bc406b70d
3 changed files with 22 additions and 22 deletions

View File

@@ -11,24 +11,19 @@ class RebrickableSetList(BrickRecordList[RebrickableSet]):
select_query: str = 'rebrickable/set/list'
refresh_query: str = 'rebrickable/set/need_refresh'
# All the sets
def all(self, /) -> Self:
# Implementation of abstract list method
def list(self, /, *, override_query: str | None = None, **context) -> None:
# Load the sets from the database
for record in self.select():
for record in self.select(override_query=override_query, **context):
rebrickable_set = RebrickableSet(record=record)
self.records.append(rebrickable_set)
# All the sets
def all(self, /) -> Self:
self.list()
return self
# Sets needing refresh
def need_refresh(self, /) -> Self:
# Load the sets from the database
for record in self.select(
override_query=self.refresh_query
):
rebrickable_set = RebrickableSet(record=record)
self.records.append(rebrickable_set)
self.list(override_query=self.refresh_query)
return self

View File

@@ -1,4 +1,3 @@
from abc import ABC, abstractmethod
from sqlite3 import Row
from typing import Any, Generator, Generic, ItemsView, Self, TypeVar, TYPE_CHECKING
@@ -34,7 +33,7 @@ T = TypeVar(
# SQLite records
class BrickRecordList(Generic[T], ABC):
class BrickRecordList(Generic[T]):
select_query: str
records: list[T]
@@ -147,8 +146,7 @@ class BrickRecordList(Generic[T], ABC):
return self, total_count
# Abstract method that subclasses must implement
@abstractmethod
# Base method that subclasses can override
def list(
self,
/,
@@ -156,8 +154,8 @@ class BrickRecordList(Generic[T], ABC):
override_query: str | None = None,
**context: Any,
) -> None:
"""Load records from database - must be implemented by subclasses"""
pass
"""Load records from database - should be implemented by subclasses that use pagination"""
raise NotImplementedError("Subclass must implement list() method")
# Generic SQL parameters from fields
def sql_parameters(self, /) -> dict[str, Any]:

View File

@@ -19,17 +19,24 @@ class BrickWishList(BrickRecordList[BrickWish]):
# Queries
select_query: str = 'wish/list/all'
# All the wished sets
def all(self, /) -> Self:
# Implementation of abstract list method
def list(self, /, *, override_query: str | None = None, **context) -> None:
# Use provided order or default
order = context.pop('order', current_app.config['WISHES_DEFAULT_ORDER'])
# Load the wished sets from the database
for record in self.select(
order=current_app.config['WISHES_DEFAULT_ORDER'],
override_query=override_query,
order=order,
owners=BrickWishOwnerList.as_columns(),
**context
):
brickwish = BrickWish(record=record)
self.records.append(brickwish)
# All the wished sets
def all(self, /) -> Self:
self.list()
return self
# Add a set to the wishlist