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
|
|
|
|
from ..set_list import BrickSetList
|
|
|
|
|
|
|
|
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()
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Missing
|
|
|
|
@part_page.route('/missing', methods=['GET'])
|
|
|
|
@exception_handler(__file__)
|
|
|
|
def missing() -> str:
|
|
|
|
return render_template(
|
|
|
|
'missing.html',
|
|
|
|
table_collection=BrickPartList().missing()
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
),
|
|
|
|
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-29 14:03:48 +01:00
|
|
|
similar_prints=BrickPartList().from_print(brickpart)
|
2025-01-17 11:03:00 +01:00
|
|
|
)
|