Skip to content
Snippets Groups Projects
Verified Commit af6ffc47 authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Add plot delete button

parent 028e9ced
No related branches found
No related tags found
No related merge requests found
Pipeline #7269 passed
{% extends 'uhepp_vault/base.html' %}
{% block content %}
<nav aria-label="breadcrumb" class="d-none d-sm-block">
<ol class="breadcrumb my-2">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'uhepp_vault:user-detail' plot.collection.owner.username %}">{{ plot.collection.owner }}</a></li>
<li class="breadcrumb-item"><a href="{% url 'uhepp_vault:collection-detail' plot.collection.id %}">{{ plot.collection.title }}</a></li>
<li class="breadcrumb-item active"><a href="{% url 'uhepp_vault:plot-detail' plot.uuid %}">{{ plot }}</a></li>
</ol>
</nav>
<h1>Delete plot</h1>
<form method="post">{% csrf_token %}
<p>Are you sure you want to delete plot <b>{{ plot }}</b>?</p>
<button type="submit" class="btn btn-outline-danger">Delete</button>
</form>
{% endblock %}
...@@ -11,11 +11,21 @@ ...@@ -11,11 +11,21 @@
</ol> </ol>
</nav> </nav>
<h1>{{ plot }} <h1 class="controls-head">
<i class="text-muted fas {% if plot.collection.visibility >= 30 %} fa-globe-europe <span>
{% elif plot.collection.visibility >= 20 %} fa-shield-alt {{ plot }}
{% elif plot.collection.visibility >= 10 %} fa-lock <i class="text-muted fas {% if plot.collection.visibility >= 30 %} fa-globe-europe
{% endif %}"></i></h1> {% elif plot.collection.visibility >= 20 %} fa-shield-alt
{% elif plot.collection.visibility >= 10 %} fa-lock
{% endif %}"></i>
</span>
{% if plot.collection.owner.pk == user.pk %}
<span>
<a class="btn btn-outline-danger" href="{% url 'uhepp_vault:plot-delete' plot.uuid %}">
<i class="fas fa-trash"></i>
</a>
</span>
{% endif %}</h1>
<div class="d-flex"> <div class="d-flex">
<span class="d-none d-md-inline">UUID: {{ plot.uuid }}</span> <span class="d-none d-md-inline">UUID: {{ plot.uuid }}</span>
......
...@@ -22,5 +22,6 @@ urlpatterns = [ ...@@ -22,5 +22,6 @@ urlpatterns = [
path('c/<str:pk>/delete', views.CollectionDeleteView.as_view(), name='collection-delete'), path('c/<str:pk>/delete', views.CollectionDeleteView.as_view(), name='collection-delete'),
path('p/', views.PlotListView.as_view(), name='plot-list'), path('p/', views.PlotListView.as_view(), name='plot-list'),
path('p/<str:uuid>', views.PlotDetail.as_view(), name='plot-detail'), path('p/<str:uuid>', views.PlotDetail.as_view(), name='plot-detail'),
path('p/<str:uuid>/delete', views.PlotDeleteView.as_view(), name='plot-delete'),
path('p/<str:uuid>/download', views.plot_download, name='plot-download'), path('p/<str:uuid>/download', views.plot_download, name='plot-download'),
] ]
...@@ -216,6 +216,19 @@ class PlotDetail(generic.DetailView): ...@@ -216,6 +216,19 @@ class PlotDetail(generic.DetailView):
raise original raise original
return redirect('%s?next=%s' % (settings.LOGIN_URL, request.path)) return redirect('%s?next=%s' % (settings.LOGIN_URL, request.path))
class PlotDeleteView(LoginRequiredMixin, generic.DeleteView):
model = Plot
slug_field = 'uuid'
slug_url_kwarg = 'uuid'
def get_success_url(self):
return reverse_lazy('uhepp_vault:collection-detail',
args=[self.object.collection.pk])
def get_queryset(self):
queryset = Plot.objects.filter(collection__owner=self.request.user)
return queryset
def plot_download(request, uuid): def plot_download(request, uuid):
if request.user.is_anonymous: if request.user.is_anonymous:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment