Manufacturer lists

This commit is contained in:
Johannes Schriewer 2025-01-05 19:04:02 +01:00
parent 4b2e8ccabb
commit 37388ba7be
2 changed files with 53 additions and 2 deletions

View file

@ -0,0 +1,45 @@
{% extends "base.html" %}
{% load static %}
{% block title %}Manufacturers{% endblock %}
{% block header_bar %}
Inventory management - Manufacturers
{% endblock %}
{% block content %}
<table class="list">
<thead>
<tr>
<th>Logo</th>
<th>Manufacturer</th>
<th></th>
</tr>
</thead>
<tbody>
{% for manufacturer in object_list %}
<tr>
<td class="logo">
{% if manufacturer.icon %}
<img src="{{ manufacturer.icon.url }}">
{% endif %}
</td>
<td>
<a href="{% url 'manufacturer-detail' manufacturer.id %}" title="{{ manufacturer.description }}">{{ manufacturer.name }}</a>
</td>
<td>
{% if user.is_staff %}
<a class="edit" href="{% url "admin:inventory_manufacturer_change" object_id=manufacturer.pk %}"><img class="icon" src="{% static 'inventory/img/edit.svg' %}"></a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if user.is_staff %}
<p><a href="{% url "admin:inventory_manufacturer_add" %}?layout=1">Create new manufacturer...</a></p>
{% endif %}
{% endblock %}

View file

@ -1,9 +1,15 @@
from django.views import View from django.views import View
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.views.generic import ListView, DetailView
from inventory.models import Manufacturer
class ManufacturerView(View): class ManufacturerView(View):
pass pass
class ManufacturerListView(View): @method_decorator(login_required, name='dispatch')
pass class ManufacturerListView(ListView):
model = Manufacturer