2025-01-17 11:03:00 +01:00
|
|
|
from flask import Blueprint, render_template
|
|
|
|
|
|
|
|
from .exceptions import exception_handler
|
|
|
|
from ..minifigure_list import BrickMinifigureList
|
|
|
|
from ..part import BrickPart
|
|
|
|
from ..part_list import BrickPartList
|
2025-02-03 17:38:39 +01:00
|
|
|
from ..set_owner_list import BrickSetOwnerList
|
2025-01-17 11:03:00 +01:00
|
|
|
from ..set_list import BrickSetList
|
2025-02-03 17:38:39 +01:00
|
|
|
from ..set_storage_list import BrickSetStorageList
|
|
|
|
from ..set_tag_list import BrickSetTagList
|
2025-01-17 11:03:00 +01:00
|
|
|
|
|
|
|
part_page = Blueprint('part', __name__, url_prefix='/parts')
|
|
|
|
|
|
|
|
|
|
|
|
# Index
|
|
|
|
@part_page.route('/', methods=['GET'])
|
|
|
|
@exception_handler(__file__)
|
|
|
|
def list() -> str:
|
|
|
|
return render_template(
|
|
|
|
'parts.html',
|
|
|
|
table_collection=BrickPartList().all()
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2025-01-31 20:46:36 +01:00
|
|
|
# Problem
|
|
|
|
@part_page.route('/problem', methods=['GET'])
|
2025-01-17 11:03:00 +01:00
|
|
|
@exception_handler(__file__)
|
2025-01-31 20:46:36 +01:00
|
|
|
def problem() -> str:
|
2025-01-17 11:03:00 +01:00
|
|
|
return render_template(
|
2025-01-31 20:46:36 +01:00
|
|
|
'problem.html',
|
|
|
|
table_collection=BrickPartList().problem()
|
2025-01-17 11:03:00 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Part details
|
2025-01-28 19:18:51 +01:00
|
|
|
@part_page.route('/<part>/<int:color>/details', methods=['GET']) # noqa: E501
|
2025-01-17 11:03:00 +01:00
|
|
|
@exception_handler(__file__)
|
2025-01-28 19:18:51 +01:00
|
|
|
def details(*, part: str, color: int) -> str:
|
2025-01-29 14:03:48 +01:00
|
|
|
brickpart = BrickPart().select_generic(part, color)
|
|
|
|
|
2025-01-17 11:03:00 +01:00
|
|
|
return render_template(
|
|
|
|
'part.html',
|
2025-01-29 14:03:48 +01:00
|
|
|
item=brickpart,
|
2025-01-17 11:03:00 +01:00
|
|
|
sets_using=BrickSetList().using_part(
|
2025-01-28 19:18:51 +01:00
|
|
|
part,
|
|
|
|
color
|
2025-01-17 11:03:00 +01:00
|
|
|
),
|
|
|
|
sets_missing=BrickSetList().missing_part(
|
2025-01-28 19:18:51 +01:00
|
|
|
part,
|
|
|
|
color
|
2025-01-17 11:03:00 +01:00
|
|
|
),
|
2025-01-31 20:46:36 +01:00
|
|
|
sets_damaged=BrickSetList().damaged_part(
|
|
|
|
part,
|
|
|
|
color
|
|
|
|
),
|
2025-01-17 11:03:00 +01:00
|
|
|
minifigures_using=BrickMinifigureList().using_part(
|
2025-01-28 19:18:51 +01:00
|
|
|
part,
|
|
|
|
color
|
2025-01-17 11:03:00 +01:00
|
|
|
),
|
|
|
|
minifigures_missing=BrickMinifigureList().missing_part(
|
2025-01-28 19:18:51 +01:00
|
|
|
part,
|
|
|
|
color
|
2025-01-17 11:03:00 +01:00
|
|
|
),
|
2025-01-31 20:46:36 +01:00
|
|
|
minifigures_damaged=BrickMinifigureList().damaged_part(
|
|
|
|
part,
|
|
|
|
color
|
|
|
|
),
|
2025-02-03 10:10:06 +01:00
|
|
|
different_color=BrickPartList().with_different_color(brickpart),
|
|
|
|
similar_prints=BrickPartList().from_print(brickpart),
|
2025-02-03 17:38:39 +01:00
|
|
|
brickset_owners=BrickSetOwnerList.list(),
|
|
|
|
brickset_storages=BrickSetStorageList.list(as_class=True),
|
|
|
|
brickset_tags=BrickSetTagList.list(),
|
2025-01-17 11:03:00 +01:00
|
|
|
)
|