diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py
index 696b4d1..3523e3d 100644
--- a/src/fellchensammlung/models.py
+++ b/src/fellchensammlung/models.py
@@ -466,10 +466,10 @@ class AdoptionNotice(models.Model):
return False
return self.adoptionnoticestatus.is_disabled_unchecked
- def set_closed(self):
+ def set_closed(self, minor_status=None):
self.last_checked = timezone.now()
self.save()
- self.adoptionnoticestatus.set_closed()
+ self.adoptionnoticestatus.set_closed(minor_status)
def set_active(self):
self.last_checked = timezone.now()
@@ -574,9 +574,12 @@ class AdoptionNoticeStatus(models.Model):
minor_status=minor_status,
adoption_notice=an_instance)
- def set_closed(self):
+ def set_closed(self, minor_status=None):
self.major_status = self.MAJOR_STATUS_CHOICES[self.CLOSED]
- self.minor_status = self.MINOR_STATUS_CHOICES[self.CLOSED]["other"]
+ if minor_status is None:
+ self.minor_status = self.MINOR_STATUS_CHOICES[self.CLOSED]["other"]
+ else:
+ self.minor_status = self.MINOR_STATUS_CHOICES[self.CLOSED][minor_status]
self.save()
def set_unchecked(self):
diff --git a/src/fellchensammlung/templates/fellchensammlung/details/detail-adoption-notice.html b/src/fellchensammlung/templates/fellchensammlung/details/detail-adoption-notice.html
index 88123db..f3a57f6 100644
--- a/src/fellchensammlung/templates/fellchensammlung/details/detail-adoption-notice.html
+++ b/src/fellchensammlung/templates/fellchensammlung/details/detail-adoption-notice.html
@@ -99,7 +99,7 @@
{% trans 'Tier hinzufügen' %}
-
+
{% trans 'Deaktivieren' %}
diff --git a/src/fellchensammlung/templates/fellchensammlung/misc/deactivate-an.html b/src/fellchensammlung/templates/fellchensammlung/misc/deactivate-an.html
new file mode 100644
index 0000000..c65d116
--- /dev/null
+++ b/src/fellchensammlung/templates/fellchensammlung/misc/deactivate-an.html
@@ -0,0 +1,26 @@
+{% extends "fellchensammlung/base.html" %}
+{% load i18n %}
+{% load widget_tweaks %}
+
+{% block content %}
+
{% translate 'Vermittlung deaktivieren' %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/src/fellchensammlung/urls.py b/src/fellchensammlung/urls.py
index eb8b560..015cded 100644
--- a/src/fellchensammlung/urls.py
+++ b/src/fellchensammlung/urls.py
@@ -35,6 +35,8 @@ urlpatterns = [
# ex: /adoption_notice/2/add-animal
path("vermittlung//add-animal", views.adoption_notice_add_animal,
name="adoption-notice-add-animal"),
+ path("vermittlung//close", views.deactivate_an,
+ name="adoption-notice-close"),
path("tierschutzorganisationen/", views.list_rescue_organizations, name="rescue-organizations"),
path("tierschutzorganisationen//", views.detail_view_rescue_organization,
diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py
index b05ab9d..13a3aab 100644
--- a/src/fellchensammlung/views.py
+++ b/src/fellchensammlung/views.py
@@ -622,8 +622,8 @@ def my_notifications(request):
context = {"notifications_unread": Notification.objects.filter(user_to_notify=request.user, read=False).order_by(
"-created_at"),
- "notifications_read_last": Notification.objects.filter(user_to_notify=request.user,
- read=True).order_by("-read_at")}
+ "notifications_read_last": Notification.objects.filter(user_to_notify=request.user,
+ read=True).order_by("-read_at")}
return render(request, 'fellchensammlung/notifications.html', context=context)
@@ -845,3 +845,13 @@ def rescue_organization_check_dq(request):
@user_passes_test(user_is_trust_level_or_above)
def moderation_tools_overview(request):
return render(request, 'fellchensammlung/mod-tool-overview.html')
+
+
+def deactivate_an(request, adoption_notice_id):
+ adoption_notice = get_object_or_404(AdoptionNotice, pk=adoption_notice_id)
+ if request.method == "POST":
+ reason_for_closing = request.POST.get("reason_for_closing")
+ adoption_notice.set_closed(reason_for_closing)
+ return redirect(reverse("adoption-notice-detail", args=[adoption_notice.pk], ))
+ context = {"adoption_notice": adoption_notice,}
+ return render(request, 'fellchensammlung/misc/deactivate-an.html', context=context)
\ No newline at end of file