add DeviceDeleteView
This commit is contained in:
parent
1279311055
commit
01afb1292c
|
@ -0,0 +1,11 @@
|
|||
{% extends "core/base.html" %}
|
||||
{% block section_title %}Delete Device{% endblock %}
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<form method="post">{% csrf_token %}
|
||||
<p>Are you sure you want to delete the device "{{ object }}"?</p>
|
||||
<button type="submit" class="btn btn-danger">Delete</button>
|
||||
<a href="{% url 'device' object.pk %}" class="btn btn-primary">Cancel</a>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -38,5 +38,6 @@
|
|||
</tr>
|
||||
</table>
|
||||
<a href="{% url 'device_update' pk %}" class="edit" title="Edit" data-toggle="tooltip"><i class="material-icons">edit</i></a>
|
||||
<a href="{% url 'device_delete' pk %}" class="delete" title="Delete" data-toggle="tooltip"><i class="material-icons">delete</i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -18,6 +18,8 @@ urlpatterns = [
|
|||
path('update/device/<int:pk>/',
|
||||
views.DeviceUpdateView.as_view(),
|
||||
name='device_update'),
|
||||
path('delete/device/<int:pk>/', views.DeviceDeleteView.as_view(),
|
||||
name='device_delete'),
|
||||
path('device/<int:pk>/add/warranty/', views.WarrantyCreateView.as_view(),
|
||||
name='warranty_create'),
|
||||
path('delete/warranty/<int:pk>/', views.WarrantyDeleteView.as_view(),
|
||||
|
|
|
@ -119,6 +119,13 @@ class DeviceUpdateView(LoginRequiredMixin, UpdateView):
|
|||
template_name = 'devices/device_update.html'
|
||||
|
||||
|
||||
class DeviceDeleteView(LoginRequiredMixin, DeleteView):
|
||||
model = Device
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('devices', args=(self.object.customer.pk,))
|
||||
|
||||
|
||||
class WarrantyCreateView(LoginRequiredMixin, CreateView):
|
||||
model = Warranty
|
||||
form_class = WarrantyCreateForm
|
||||
|
|
Loading…
Reference in New Issue