forked from FrederikBaerentsen/BrickTracker
bricktracker
migrations
sql
views
__init__.py
app.py
config.py
configuration.py
configuration_list.py
exceptions.py
fields.py
instructions.py
instructions_list.py
login.py
metadata.py
metadata_list.py
minifigure.py
minifigure_list.py
navbar.py
parser.py
part.py
part_list.py
rebrickable.py
rebrickable_image.py
rebrickable_minifigure.py
rebrickable_part.py
rebrickable_set.py
rebrickable_set_list.py
record.py
record_list.py
reload.py
retired.py
retired_list.py
set.py
set_list.py
set_status.py
set_status_list.py
socket.py
socket_decorator.py
sql.py
sql_counter.py
sql_migration.py
sql_migration_list.py
sql_stats.py
theme.py
theme_list.py
version.py
wish.py
wish_list.py
docs
static
templates
.dockerignore
.env.sample
.gitignore
CHANGELOG.md
Dockerfile
LICENSE
README.md
__init__.py
app.py
compose.legacy.yml
compose.local.yaml
compose.yaml
entrypoint.sh
requirements.txt
test-server.sh
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
from typing import Self
|
|
|
|
from flask import url_for
|
|
|
|
from .exceptions import NotFoundException
|
|
from .rebrickable_set import RebrickableSet
|
|
from .sql import BrickSQL
|
|
|
|
|
|
# Lego brick wished set
|
|
class BrickWish(RebrickableSet):
|
|
# Flags
|
|
resolve_instructions: bool = False
|
|
|
|
# Queries
|
|
select_query: str = 'wish/select'
|
|
insert_query: str = 'wish/insert'
|
|
|
|
# Delete a wished set
|
|
def delete(self, /) -> None:
|
|
BrickSQL().execute_and_commit(
|
|
'wish/delete/wish',
|
|
parameters=self.sql_parameters()
|
|
)
|
|
|
|
# Select a specific part (with a set and an id)
|
|
def select_specific(self, set: str, /) -> Self:
|
|
# Save the parameters to the fields
|
|
self.fields.set = set
|
|
|
|
# Load from database
|
|
if not self.select():
|
|
raise NotFoundException(
|
|
'Wish for set {set} was not found in the database'.format( # noqa: E501
|
|
set=self.fields.set,
|
|
),
|
|
)
|
|
|
|
return self
|
|
|
|
# Deletion url
|
|
def url_for_delete(self, /) -> str:
|
|
return url_for('wish.delete', number=self.fields.set)
|