diff --git a/licenses/templates/licenses/license_block.html b/licenses/templates/licenses/license_block.html
index b706db7..c1ad8d4 100644
--- a/licenses/templates/licenses/license_block.html
+++ b/licenses/templates/licenses/license_block.html
@@ -4,6 +4,7 @@
{{ license.license.software }} |
{{ license.license.key }} |
+ delete |
{% endfor %}
diff --git a/licenses/templates/licenses/license_with_computer_confirm_delete.html b/licenses/templates/licenses/license_with_computer_confirm_delete.html
new file mode 100644
index 0000000..034d4af
--- /dev/null
+++ b/licenses/templates/licenses/license_with_computer_confirm_delete.html
@@ -0,0 +1,16 @@
+{% extends "core/base.html" %}
+{% block section_title %}Delete License Relation{% endblock %}
+{% block content %}
+
+{% endblock %}
diff --git a/licenses/tests/test_license_form_view.py b/licenses/tests/test_license_form_view.py
index 17171b5..cda9cc4 100644
--- a/licenses/tests/test_license_form_view.py
+++ b/licenses/tests/test_license_form_view.py
@@ -6,7 +6,7 @@ import pytest
pytestmark = pytest.mark.django_db
-def test_license_relation_create_view(create_admin_user):
+def test_license_with_computer_create_view(create_admin_user):
create_admin_user()
client = Client()
client.login(username="pharma-admin", password="password")
@@ -22,3 +22,14 @@ def test_license_relation_create_view(create_admin_user):
assert response.status_code == 302
+def test_license_with_computer_delete_view(create_admin_user):
+ create_admin_user()
+ client = Client()
+ client.login(username="pharma-admin", password="password")
+ computer = mixer.blend('computers.Computer', customer=mixer.SELECT)
+ license = mixer.blend('licenses.ComputerLicense')
+ license_with_computer = mixer.blend('licenses.LicenseWithComputer',
+ computer=computer, license=license)
+ url = '/delete/license-with-computer/{}/'.format(license_with_computer.id)
+ response = client.post(url)
+ assert response.status_code == 302
diff --git a/licenses/urls.py b/licenses/urls.py
index 65dc739..41ae3ff 100644
--- a/licenses/urls.py
+++ b/licenses/urls.py
@@ -8,4 +8,7 @@ urlpatterns = [
path('create/license-with/computer//',
views.LicenseWithComputerCreateView.as_view(),
name='license_with_computer_create'),
+ path('delete/license-with-computer//',
+ views.LicenseWithComputerDeleteView.as_view(),
+ name='license_with_computer_delete'),
]
diff --git a/licenses/views.py b/licenses/views.py
index 70fd707..2220280 100644
--- a/licenses/views.py
+++ b/licenses/views.py
@@ -4,6 +4,7 @@ from django.shortcuts import get_object_or_404
from django.shortcuts import render
from django.urls import reverse
from django.views.generic import CreateView
+from django.views.generic import DeleteView
from django_tables2 import RequestConfig
@@ -35,7 +36,6 @@ def licenses_table_view(request, pk):
class LicenseWithComputerCreateView(LoginRequiredMixin, CreateView):
model = LicenseWithComputer
- #form_class = ComputerSoftwareRelationCreateForm
template_name = 'licenses/license_with_computer_create.html'
fields = '__all__'
@@ -51,3 +51,13 @@ class LicenseWithComputerCreateView(LoginRequiredMixin, CreateView):
return {
'computer': self.computer,
}
+
+
+class LicenseWithComputerDeleteView(LoginRequiredMixin, DeleteView):
+ model = LicenseWithComputer
+ template_name = 'licenses/license_with_computer_confirm_delete.html'
+
+ def get_success_url(self):
+ return reverse('computer', args=(self.object.computer.pk,))
+
+