diff --git a/src/teams/templates/info_item_delete_confirm.html b/src/teams/templates/info_item_delete_confirm.html new file mode 100644 index 00000000..fe9f2403 --- /dev/null +++ b/src/teams/templates/info_item_delete_confirm.html @@ -0,0 +1,30 @@ +{% extends 'base.html' %} +{% load commonmark %} +{% load bootstrap3 %} + +{% block title %} +{% if form.instance.id %} +Edit Info Item: {{ form.instance.headline }} +{% else %} +Create Info item +{% endif %} +in {{ form.instance.category.headline }} +{% endblock %} + +{% block content %} +
+
+

+ Delete info item {{ object.name }} + in {{ form.instance.category.headline }} +

+
+
+
+ {% csrf_token %} +

Are you sure you want to delete "{{ object.headline }}" in the "{{ object.category.headline }}" category.

+ +
+
+
+{% endblock %} diff --git a/src/teams/templates/info_item_form.html b/src/teams/templates/info_item_form.html index 3a15e8e8..03d56ddf 100644 --- a/src/teams/templates/info_item_form.html +++ b/src/teams/templates/info_item_form.html @@ -3,31 +3,37 @@ {% load bootstrap3 %} {% block title %} -{% if form.instance.id %} -Edit Info Item: {{ form.instance.headline }} +{% if object %} +Editing "{{ object.headline }}" {% else %} Create Info item {% endif %} -in {{ form.instance.category.headline }} +in "{{ form.instance.category.headline }}" {% endblock %} {% block content %}

- {% if form.instance.id %} - Edit Info Item: {{ form.instance.name }} + {% if object %} + Editing "{{ object.headline }}" {% else %} Create Info Item {% endif %} - in {{ form.instance.category.headline }} + in "{{ object.category.headline }}"

{% csrf_token %} {% bootstrap_form form %} - + + {% if object %} + + Delete + + {% endif %}
diff --git a/src/teams/urls.py b/src/teams/urls.py index 4de29253..d528b2c1 100644 --- a/src/teams/urls.py +++ b/src/teams/urls.py @@ -10,7 +10,7 @@ from teams.views.base import ( TeamManageView, FixIrcAclView, ) -from teams.views.info import InfoItemUpdateView, InfoItemCreateView +from teams.views.info import InfoItemUpdateView, InfoItemCreateView, InfoItemDeleteView from teams.views.tasks import ( TaskCreateView, @@ -105,6 +105,11 @@ urlpatterns = [ InfoItemUpdateView.as_view(), name='info_item_update', ), + url( + r'^delete/$', + InfoItemDeleteView.as_view(), + name='info_item_delete', + ), ]), ), ]) diff --git a/src/teams/views/info.py b/src/teams/views/info.py index 740fdd9f..5a6efaaa 100644 --- a/src/teams/views/info.py +++ b/src/teams/views/info.py @@ -1,6 +1,6 @@ from django.contrib.auth.mixins import LoginRequiredMixin from django.http import HttpResponseRedirect -from django.views.generic import CreateView, UpdateView +from django.views.generic import CreateView, UpdateView, DeleteView from reversion.views import RevisionMixin from camps.mixins import CampViewMixin @@ -47,3 +47,16 @@ class InfoItemUpdateView(LoginRequiredMixin, CampViewMixin, EnsureTeamResponsibl if next: return next return self.team.get_absolute_url() + + +class InfoItemDeleteView(LoginRequiredMixin, CampViewMixin, EnsureTeamResponsibleMixin, RevisionMixin, DeleteView): + model = InfoItem + template_name = "info_item_delete_confirm.html" + slug_field = 'anchor' + slug_url_kwarg = 'item_anchor' + + def get_success_url(self): + next = self.request.GET.get('next') + if next: + return next + return self.team.get_absolute_url()