Refactored container views to new style.

This commit is contained in:
2022-03-17 10:27:31 +01:00
parent e5a81452f2
commit 1267e8a587
11 changed files with 161 additions and 103 deletions

View File

@@ -5,7 +5,6 @@
{% block content %}
<div class="container">
<div>New Assets:</div>
{% if asset_list %}
<table class="table table-striped table-hover">
<thead>
@@ -16,7 +15,7 @@
<tbody>
{% for asset in asset_list %}
<tr>
<td><a href="{% url 'asset:asset-update' asset.id %}"><div>{{ asset.named_id }}: {{ asset.description }}</div></a></td>
<td><a href="{% url 'asset:update' asset.id %}"><div>{{ asset.named_id }}: {{ asset.description }}</div></a></td>
<td>{{ asset.quantity }}</td>
<td><a class="btn btn-outline-primary btn-sm" href="{% url 'asset:delete' asset.id %}" role="button">Delete</a></td>
</tr>

View File

@@ -6,9 +6,8 @@ app_name = 'asset'
urlpatterns = [
path('', AssetListView.as_view(), name='list'),
path('add/', AssetCreateView.as_view(), name='add'),
path('<int:pk>/', AssetUpdateView.as_view(), name='asset-update'),
path('<int:pk>/', AssetUpdateView.as_view(), name='update'),
path('<int:pk>/', AssetUpdateView.as_view(), name='detail'),
path('<int:asset_id>/save', views.asset_save, name='asset-save'),
path('<int:pk>/delete/', AssetDeleteView.as_view(), name='delete'),
]

View File

@@ -27,7 +27,7 @@ class AssetUpdateView(UpdateView):
class AssetDeleteView(DeleteView):
model = Asset
success_url = reverse_lazy('asset-index')
success_url = reverse_lazy('asset:list')
class AssetListView(generic.ListView):
@@ -48,4 +48,4 @@ def asset_save(request, asset_id):
asset.description = request.POST['description']
asset.quantity = request.POST['quantity']
asset.save();
return HttpResponseRedirect(reverse('asset:index'))
return HttpResponseRedirect(reverse('asset:list'))