diff --git a/argocd/configmap.yaml b/argocd/configmap.yaml index 7f2eff0..0a81378 100644 --- a/argocd/configmap.yaml +++ b/argocd/configmap.yaml @@ -21,4 +21,4 @@ data: LOGOUT_REDIRECT_URL: "/login/" OIDC_AUTHENTICATION_FAILURE_REDIRECT_URL: "/login/" GUNICORN_OPTS: "--access-logfile -" - IMAGE_TAG: "0.078" + IMAGE_TAG: "0.079" diff --git a/argocd/deployment.yaml b/argocd/deployment.yaml index 01be0f2..ceb8851 100644 --- a/argocd/deployment.yaml +++ b/argocd/deployment.yaml @@ -27,7 +27,7 @@ spec: mountPath: /data containers: - name: web - image: git.baumann.gr/adebaumann/labhelper:0.078 + image: git.baumann.gr/adebaumann/labhelper:0.079 imagePullPolicy: Always ports: - containerPort: 8000 diff --git a/boxes/templates/boxes/edit_thing.html b/boxes/templates/boxes/edit_thing.html index 7418648..3f9cebb 100644 --- a/boxes/templates/boxes/edit_thing.html +++ b/boxes/templates/boxes/edit_thing.html @@ -284,6 +284,16 @@ +
+
+ {% csrf_token %} + +
+
+ {% endblock %} {% block extra_css %} diff --git a/boxes/views.py b/boxes/views.py index 2acac18..ae981ae 100644 --- a/boxes/views.py +++ b/boxes/views.py @@ -373,6 +373,21 @@ def delete_box(request, box_id): return redirect('box_management') +@login_required +def delete_thing(request, thing_id): + """Delete a thing and its associated files.""" + thing = get_object_or_404(Thing, pk=thing_id) + if request.method == 'POST': + box_id = thing.box.id + if thing.picture: + thing.picture.delete(save=False) + for thing_file in thing.files.all(): + thing_file.file.delete(save=False) + thing.delete() + return redirect('box_detail', box_id=box_id) + return redirect('edit_thing', thing_id=thing_id) + + @login_required def resources_list(request): """List all links and files from things that have them.""" diff --git a/labhelper/urls.py b/labhelper/urls.py index f9c6ecc..e4e4a50 100644 --- a/labhelper/urls.py +++ b/labhelper/urls.py @@ -29,6 +29,7 @@ from boxes.views import ( boxes_list, delete_box, delete_box_type, + delete_thing, edit_box, edit_box_type, edit_thing, @@ -53,6 +54,7 @@ urlpatterns = [ path('box//', box_detail, name='box_detail'), path('thing//', thing_detail, name='thing_detail'), path('thing//edit/', edit_thing, name='edit_thing'), + path('thing//delete/', delete_thing, name='delete_thing'), path('box//add/', add_things, name='add_things'), path('boxes/', boxes_list, name='boxes_list'), path('inventory/', boxes_list, name='inventory'),