Use Rebrickable URL for cosmetics if available

This commit is contained in:
Gregoo 2025-01-29 09:04:09 +01:00
parent fe13cfdb08
commit d93723ab4e

View File

@ -138,10 +138,17 @@ class RebrickablePart(BrickRecord):
def url_for_rebrickable(self, /) -> str: def url_for_rebrickable(self, /) -> str:
if current_app.config['REBRICKABLE_LINKS']: if current_app.config['REBRICKABLE_LINKS']:
try: try:
return current_app.config['REBRICKABLE_LINK_PART_PATTERN'].format( # noqa: E501 if self.fields.url is not None:
part=self.fields.part, # The URL does not contain color info...
color=self.fields.color, return '{url}{color}'.format(
) url=self.fields.url,
color=self.fields.color
)
else:
return current_app.config['REBRICKABLE_LINK_PART_PATTERN'].format( # noqa: E501
part=self.fields.part,
color=self.fields.color,
)
except Exception: except Exception:
pass pass