Display same parts using a different color
This commit is contained in:
parent
eac9fc1793
commit
34408a1bff
@ -63,6 +63,7 @@ Parts
|
|||||||
- Display if print of another part
|
- Display if print of another part
|
||||||
- Display prints using the same base
|
- Display prints using the same base
|
||||||
- Damaged parts
|
- Damaged parts
|
||||||
|
- Display same parts using a different color
|
||||||
|
|
||||||
- Sets
|
- Sets
|
||||||
- Add a flag to hide instructions in a set
|
- Add a flag to hide instructions in a set
|
||||||
|
@ -23,6 +23,7 @@ class BrickPartList(BrickRecordList[BrickPart]):
|
|||||||
|
|
||||||
# Queries
|
# Queries
|
||||||
all_query: str = 'part/list/all'
|
all_query: str = 'part/list/all'
|
||||||
|
different_color_query = 'part/list/with_different_color'
|
||||||
last_query: str = 'part/list/last'
|
last_query: str = 'part/list/last'
|
||||||
minifigure_query: str = 'part/list/from_minifigure'
|
minifigure_query: str = 'part/list/from_minifigure'
|
||||||
problem_query: str = 'part/list/problem'
|
problem_query: str = 'part/list/problem'
|
||||||
@ -166,6 +167,35 @@ class BrickPartList(BrickRecordList[BrickPart]):
|
|||||||
|
|
||||||
return parameters
|
return parameters
|
||||||
|
|
||||||
|
# Load generic parts with same base but different color
|
||||||
|
def with_different_color(
|
||||||
|
self,
|
||||||
|
brickpart: BrickPart,
|
||||||
|
/,
|
||||||
|
) -> Self:
|
||||||
|
# Save the part
|
||||||
|
self.fields.part = brickpart.fields.part
|
||||||
|
self.fields.color = brickpart.fields.color
|
||||||
|
|
||||||
|
# Load the parts from the database
|
||||||
|
for record in self.select(
|
||||||
|
override_query=self.different_color_query,
|
||||||
|
order=self.order
|
||||||
|
):
|
||||||
|
part = BrickPart(
|
||||||
|
record=record,
|
||||||
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
current_app.config['SKIP_SPARE_PARTS'] and
|
||||||
|
part.fields.spare
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.records.append(part)
|
||||||
|
|
||||||
|
return self
|
||||||
|
|
||||||
# Import the parts from Rebrickable
|
# Import the parts from Rebrickable
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def download(
|
def download(
|
||||||
|
17
bricktracker/sql/part/list/with_different_color.sql
Normal file
17
bricktracker/sql/part/list/with_different_color.sql
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
{% extends 'part/base/base.sql' %}
|
||||||
|
|
||||||
|
{% block total_missing %}{% endblock %}
|
||||||
|
|
||||||
|
{% block total_damaged %}{% endblock %}
|
||||||
|
|
||||||
|
{% block where %}
|
||||||
|
WHERE "bricktracker_parts"."color" IS DISTINCT FROM :color
|
||||||
|
AND "bricktracker_parts"."part" IS NOT DISTINCT FROM :part
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block group %}
|
||||||
|
GROUP BY
|
||||||
|
"bricktracker_parts"."part",
|
||||||
|
"bricktracker_parts"."color"
|
||||||
|
{% endblock %}
|
@ -62,5 +62,6 @@ def details(*, part: str, color: int) -> str:
|
|||||||
part,
|
part,
|
||||||
color
|
color
|
||||||
),
|
),
|
||||||
similar_prints=BrickPartList().from_print(brickpart)
|
different_color=BrickPartList().with_different_color(brickpart),
|
||||||
|
similar_prints=BrickPartList().from_print(brickpart),
|
||||||
)
|
)
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
{{ accordion.cards(minifigures_using, 'Minifigures using this part', 'minifigures-using-inventory', 'part-details', 'minifigure/card.html', icon='group-line') }}
|
{{ accordion.cards(minifigures_using, 'Minifigures using this part', 'minifigures-using-inventory', 'part-details', 'minifigure/card.html', icon='group-line') }}
|
||||||
{{ accordion.cards(minifigures_missing, 'Minifigures missing this part', 'minifigures-missing-inventory', 'part-details', 'minifigure/card.html', icon='question-line') }}
|
{{ accordion.cards(minifigures_missing, 'Minifigures missing this part', 'minifigures-missing-inventory', 'part-details', 'minifigure/card.html', icon='question-line') }}
|
||||||
{{ accordion.cards(minifigures_damaged, 'Minifigures with this part damaged', 'minifigures-damaged-inventory', 'part-details', 'minifigure/card.html', icon='error-warning-line') }}
|
{{ accordion.cards(minifigures_damaged, 'Minifigures with this part damaged', 'minifigures-damaged-inventory', 'part-details', 'minifigure/card.html', icon='error-warning-line') }}
|
||||||
|
{{ accordion.cards(different_color, 'Same part with a different color', 'different-color', 'part-details', 'part/card.html', icon='palette-line') }}
|
||||||
{{ accordion.cards(similar_prints, 'Prints using the same base', 'similar-prints', 'part-details', 'part/card.html', icon='paint-brush-line') }}
|
{{ accordion.cards(similar_prints, 'Prints using the same base', 'similar-prints', 'part-details', 'part/card.html', icon='paint-brush-line') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer"></div>
|
<div class="card-footer"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user