Skip to content

Commit

Permalink
Add delete message
Browse files Browse the repository at this point in the history
  • Loading branch information
Tammo-Feldmann committed Oct 19, 2023
1 parent 60ae854 commit ffe621d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ <h1 class="my-5">{{ object.short_name }}</h1>
Edit
</a>
{% endif %}
<button class="btn btn-secondary" data-toggle="modal" data-target="#deletePopup">
Delete
</button>
{% if not is_delete_in_progress %}
<button class="btn btn-secondary" data-toggle="modal" data-target="#deletePopup">
Delete
</button>
{% endif %}
</div>
{% endblock actions %}

Expand Down
11 changes: 11 additions & 0 deletions app/admin_ui/views/v2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Dict

from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.utils.decorators import method_decorator
from django.views.generic.detail import DetailView
from django.forms import modelform_factory
Expand Down Expand Up @@ -198,6 +199,11 @@ def get_context_data(self, **kwargs):
"has_progress_draft": Change.objects.related_in_progress_drafts(
self.kwargs[self.pk_url_kwarg]
).exists(),
"is_delete_in_progress": Change.objects.related_in_progress_drafts(
self.kwargs[self.pk_url_kwarg]
)
.filter(action=Change.Actions.DELETE)
.exists(),
}


Expand All @@ -221,6 +227,11 @@ def get_queryset(self):
return Change.objects.all()

def get(self, request, *args, **kwargs):
messages.add_message(
request,
messages.WARNING,
"Deletion in progress. Only after admin approval will the published version be removed.",
)
self.object = self.get_object()
in_progress_drafts = Change.objects.related_in_progress_drafts(
self.kwargs["canonical_uuid"]
Expand Down

0 comments on commit ffe621d

Please sign in to comment.