Skip to content

Commit

Permalink
insertion explode view
Browse files Browse the repository at this point in the history
  • Loading branch information
andywar65 committed Jan 2, 2023
1 parent b039bdd commit 3cf3552
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
8 changes: 8 additions & 0 deletions templates/djeocad/includes/insertion_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ <h4 class="card-title">
{% trans "Other actions" %}
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<li>
<a class="dropdown-item"
hx-get="{% url 'djeocad:insert_explode' username=object.layer.drawing.user.username pk=object.id %}"
hx-target="#content"
hx-push-url="true">
{% trans "Explode insertion" %}
</a>
</li>
<li>
<a class="dropdown-item"
hx-get="{% url 'djeocad:insert_delete' username=object.layer.drawing.user.username pk=object.id %}"
Expand Down
4 changes: 2 additions & 2 deletions templates/djeocad/insertion_confirm_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<div class="card mx-auto" style="width: 480px;">
<div class="card-header">
<h4 class="card-title">
{% trans "Delete insertion"%}
{% trans "Delete / explode insertion"%}
</h4>
</div>
<div class="card-body">
<p>
{% trans "Are you sure you want to delete insertion" %}
{% trans "Are you sure you want to delete / explode insertion" %}
<strong>{{ object }}</strong>?
</p>
<form method="POST" action="">
Expand Down
6 changes: 6 additions & 0 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
InsertionDeleteInlineView,
InsertionDeleteView,
InsertionExplodeInlineView,
InsertionExplodeView,
InsertionUpdateView,
LayerCreateView,
LayerDeleteInlineView,
Expand Down Expand Up @@ -98,6 +99,11 @@
InsertionDeleteView.as_view(),
name="insert_delete",
),
path(
_("<username>/block-instance/<pk>/explode/"),
InsertionExplodeView.as_view(),
name="insert_explode",
),
path(_("drawing/<pk>/download/"), drawing_download, name="drawing_download"),
# Inlines
path(
Expand Down
10 changes: 9 additions & 1 deletion views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import PermissionDenied
from django.http import Http404, HttpResponse
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -466,6 +466,14 @@ def get_success_url(self, *args, **kwargs):
)


class InsertionExplodeView(InsertionDeleteView):
def form_valid(self, form):
success_url = self.get_success_url()
self.object.explode_instance()
self.object.delete()
return HttpResponseRedirect(success_url)


class InsertionDeleteInlineView(PermissionRequiredMixin, TemplateView):
permission_required = "djeocad.delete_insertion"
template_name = "djeocad/htmx/item_delete.html"
Expand Down

0 comments on commit 3cf3552

Please sign in to comment.