url_for_missing should be part of BrickPart, not RebrickablePart
This commit is contained in:
parent
160ab066b2
commit
56ad9fba13
@ -2,6 +2,8 @@ import logging
|
|||||||
from typing import Any, Self, TYPE_CHECKING
|
from typing import Any, Self, TYPE_CHECKING
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
from flask import url_for
|
||||||
|
|
||||||
from .exceptions import ErrorException, NotFoundException
|
from .exceptions import ErrorException, NotFoundException
|
||||||
from .rebrickable_part import RebrickablePart
|
from .rebrickable_part import RebrickablePart
|
||||||
from .sql import BrickSQL
|
from .sql import BrickSQL
|
||||||
@ -169,3 +171,20 @@ class BrickPart(RebrickablePart):
|
|||||||
'part/update/missing',
|
'part/update/missing',
|
||||||
parameters=self.sql_parameters()
|
parameters=self.sql_parameters()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Compute the url for missing part
|
||||||
|
def url_for_missing(self, /) -> str:
|
||||||
|
# Different URL for a minifigure part
|
||||||
|
if self.minifigure is not None:
|
||||||
|
figure = self.minifigure.fields.figure
|
||||||
|
else:
|
||||||
|
figure = None
|
||||||
|
|
||||||
|
return url_for(
|
||||||
|
'set.missing_part',
|
||||||
|
id=self.fields.id,
|
||||||
|
figure=figure,
|
||||||
|
part=self.fields.part,
|
||||||
|
color=self.fields.color,
|
||||||
|
spare=self.fields.spare,
|
||||||
|
)
|
||||||
|
@ -117,23 +117,6 @@ class RebrickablePart(BrickRecord):
|
|||||||
else:
|
else:
|
||||||
return self.fields.image
|
return self.fields.image
|
||||||
|
|
||||||
# Compute the url for missing part
|
|
||||||
def url_for_missing(self, /) -> str:
|
|
||||||
# Different URL for a minifigure part
|
|
||||||
if self.minifigure is not None:
|
|
||||||
figure = self.minifigure.fields.figure
|
|
||||||
else:
|
|
||||||
figure = None
|
|
||||||
|
|
||||||
return url_for(
|
|
||||||
'set.missing_part',
|
|
||||||
id=self.fields.id,
|
|
||||||
figure=figure,
|
|
||||||
part=self.fields.part,
|
|
||||||
color=self.fields.color,
|
|
||||||
spare=self.fields.spare,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Compute the url for the original of the printed part
|
# Compute the url for the original of the printed part
|
||||||
def url_for_print(self, /) -> str:
|
def url_for_print(self, /) -> str:
|
||||||
return url_for(
|
return url_for(
|
||||||
|
Loading…
Reference in New Issue
Block a user