feat: Add functionality to deactivate AN with reason
This commit is contained in:
@@ -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):
|
||||
|
@@ -99,7 +99,7 @@
|
||||
<i class="fas fa-plus fa-fw"
|
||||
aria-hidden="true"></i> {% trans 'Tier hinzufügen' %}
|
||||
</a>
|
||||
<a class="dropdown-item">
|
||||
<a class="dropdown-item" href="{% url 'adoption-notice-close' adoption_notice_id=adoption_notice.pk%}">
|
||||
<i class="fas fa-circle-xmark fa-fw"
|
||||
aria-hidden="true"></i> {% trans 'Deaktivieren' %}
|
||||
</a>
|
||||
|
@@ -0,0 +1,26 @@
|
||||
{% extends "fellchensammlung/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="title is-1">{% translate 'Vermittlung deaktivieren' %}</h1>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<div class="field">
|
||||
<label class="label" for="reason_for_closing">{% translate 'Warum schließt du die Vermittlung?' %}</label>
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
<select id="reason_for_closing" name="reason_for_closing">
|
||||
<option value="successful_with_notfellchen">{% translate 'Vermittelt mit Hilfe von Notfellchen' %}</option>
|
||||
<option value="successful_without_notfellchen">{% translate 'Vermittelt ohne Hilfe von Notfellchen' %}</option>
|
||||
<option value="closed_for_other_adoption_notice">{% translate 'Vermittlung zugunsten einer anderen geschlossen' %}</option>
|
||||
<option value="not_open_for_adoption_anymore">{% translate 'Nicht mehr zu vermitteln (z.B. aufgrund von Krankheit)' %}</option>
|
||||
<option value="animal_died">{% translate 'Tod des Tiers' %}</option>
|
||||
<option value="other">{% translate 'Anderer Grund' %}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input class="button is-warning" type="submit" value="{% translate "Vermittlung deaktivieren" %}">
|
||||
</form>
|
||||
{% endblock %}
|
@@ -35,6 +35,8 @@ urlpatterns = [
|
||||
# ex: /adoption_notice/2/add-animal
|
||||
path("vermittlung/<int:adoption_notice_id>/add-animal", views.adoption_notice_add_animal,
|
||||
name="adoption-notice-add-animal"),
|
||||
path("vermittlung/<int:adoption_notice_id>/close", views.deactivate_an,
|
||||
name="adoption-notice-close"),
|
||||
|
||||
path("tierschutzorganisationen/", views.list_rescue_organizations, name="rescue-organizations"),
|
||||
path("tierschutzorganisationen/<int:rescue_organization_id>/", views.detail_view_rescue_organization,
|
||||
|
@@ -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)
|
Reference in New Issue
Block a user