Bugfix in item view: Tags can now be rendered

This commit is contained in:
Johannes Schriewer 2025-01-05 22:06:46 +01:00
parent a13a977206
commit 9c9a83cb47
2 changed files with 36 additions and 20 deletions

View file

@ -28,4 +28,4 @@ class Item(CanBeContained):
@property
def all_tags(self):
return self.tags.all() + self.form_factor.tags.all()
return list(self.tags.all()) + list(self.form_factor.tags.all())

View file

@ -22,9 +22,42 @@
<table class="attribute-list">
<tbody>
<tr>
<th>Description</th>
<td>{{ item }}</td>
<th>Name</th>
<td>{{ item.name }}</td>
</tr>
<tr>
<th>Description</th>
<td>{{ item.description }}</td>
</tr>
<tr>
<th>Tags</th>
<td>
<ul class="tag-list">
{% for tag in item.all_tags %}
<li><a href="{% url 'tag-detail' tag.id %}" title="{{ tag.name }}">{{ tag.name }}</a></li>
{% empty %}
No tags
{% endfor %}
</ul>
</td>
</tr>
{% if item.form_factor %}
<tr>
<th>Form factor</th>
<td>
{% if item.form_factor.datasheet %}
<a href="{% url 'distributor-detail' item.distributor.id %}">
{% if item.form_factor.icon %}<img src="{{ item.form_factor.icon.url }}" class="icon">{% endif %}
{{ item.form_factor.name }}
</a>
{% else %}
{% if item.form_factor.icon %}<img src="{{ item.form_factor.icon.url }}" class="icon">{% endif %}
{{ item.form_factor.name }}
{% endif %}
</td>
</tr>
{% endif %}
{% if item.manufacturer %}
<tr>
@ -48,23 +81,6 @@
</tr>
{% endif %}
{% if item.form_factor %}
<tr>
<th>Form factor</th>
<td>
{% if item.form_factor.datasheet %}
<a href="{% url 'distributor-detail' item.distributor.id %}">
{% if item.form_factor.icon %}<img src="{{ item.form_factor.icon.url }}" class="icon">{% endif %}
{{ item.form_factor.name }}
</a>
{% else %}
{% if item.form_factor.icon %}<img src="{{ item.form_factor.icon.url }}" class="icon">{% endif %}
{{ item.form_factor.name }}
{% endif %}
</td>
</tr>
{% endif %}
{% if item.price %}
<tr>
<th>Price</th>