From 0352a60e285eb43ff18179ce064bd29799e86fc8 Mon Sep 17 00:00:00 2001 From: moanos Date: Mon, 20 Oct 2025 10:54:23 +0200 Subject: [PATCH] feat: Add reason why rescue org was excluded from check --- src/fellchensammlung/forms.py | 8 +++++++ ...rescueorganization_regular_check_status.py | 18 +++++++++++++++ src/fellchensammlung/models.py | 8 ++++++- .../forms/form-exclude-org-from-check.html | 18 +++++++++++++++ .../partials/partial-check-rescue-org.html | 10 +-------- src/fellchensammlung/tools/model_helpers.py | 11 +++++++++- src/fellchensammlung/urls.py | 2 ++ src/fellchensammlung/views.py | 22 +++++++++++++++++-- 8 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 src/fellchensammlung/migrations/0069_rescueorganization_regular_check_status.py create mode 100644 src/fellchensammlung/templates/fellchensammlung/forms/form-exclude-org-from-check.html diff --git a/src/fellchensammlung/forms.py b/src/fellchensammlung/forms.py index cc4bcb6..5f257bc 100644 --- a/src/fellchensammlung/forms.py +++ b/src/fellchensammlung/forms.py @@ -57,6 +57,14 @@ class AnimalForm(forms.ModelForm): } +class UpdateRescueOrgRegularCheckStatus(forms.ModelForm): + template_name = "fellchensammlung/forms/form_snippets.html" + + class Meta: + model = RescueOrganization + fields = ["regular_check_status"] + + class ImageForm(forms.ModelForm): def __init__(self, *args, **kwargs): if 'in_flow' in kwargs: diff --git a/src/fellchensammlung/migrations/0069_rescueorganization_regular_check_status.py b/src/fellchensammlung/migrations/0069_rescueorganization_regular_check_status.py new file mode 100644 index 0000000..46555af --- /dev/null +++ b/src/fellchensammlung/migrations/0069_rescueorganization_regular_check_status.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.1 on 2025-10-20 08:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fellchensammlung', '0068_alter_adoptionnotice_adoption_notice_status_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='rescueorganization', + name='regular_check_status', + field=models.CharField(choices=[('regular_check', 'Wird regelmäßig geprüft'), ('excluded_no_online_listing', 'Exkludiert: Tiere werden nicht online gelistet'), ('excluded_other_org', 'Exkludiert: Andere Organisation wird geprüft'), ('excluded_scope', 'Exkludiert: Organisation hat nie Notfellchen-relevanten Vermittlungen'), ('excluded_other', 'Exkludiert: Anderer Grund')], default='regular_check', help_text='Organisationen können, durch ändern dieser Einstellung, von der regelmäßigen Prüfung ausgeschlossen werden.', max_length=30, verbose_name='Status der regelmäßigen Prüfung'), + ), + ] diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index 4681d8e..b968284 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -13,7 +13,7 @@ from notfellchen.settings import MEDIA_URL, base_url from .tools.geo import LocationProxy, Position from .tools.misc import time_since_as_hr_string from .tools.model_helpers import NotificationTypeChoices, AdoptionNoticeStatusChoices, AdoptionProcess, \ - AdoptionNoticeStatusChoicesDescriptions + AdoptionNoticeStatusChoicesDescriptions, RegularCheckStatusChoices from .tools.model_helpers import ndm as NotificationDisplayMapping @@ -172,6 +172,12 @@ class RescueOrganization(models.Model): exclude_from_check = models.BooleanField(default=False, verbose_name=_('Von Prüfung ausschließen'), help_text=_("Organisation von der manuellen Überprüfung ausschließen, " "z.B. weil Tiere nicht online geführt werden")) + regular_check_status = models.CharField(max_length=30, choices=RegularCheckStatusChoices.choices, + default=RegularCheckStatusChoices.REGULAR_CHECK, + verbose_name=_('Status der regelmäßigen Prüfung'), + help_text=_( + "Organisationen können, durch ändern dieser Einstellung, von der " + "regelmäßigen Prüfung ausgeschlossen werden.")) ongoing_communication = models.BooleanField(default=False, verbose_name=_('In aktiver Kommunikation'), help_text=_( "Es findet gerade Kommunikation zwischen Notfellchen und der Organisation statt.")) diff --git a/src/fellchensammlung/templates/fellchensammlung/forms/form-exclude-org-from-check.html b/src/fellchensammlung/templates/fellchensammlung/forms/form-exclude-org-from-check.html new file mode 100644 index 0000000..8318104 --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/forms/form-exclude-org-from-check.html @@ -0,0 +1,18 @@ +{% extends "fellchensammlung/base.html" %} +{% load i18n %} +{% load widget_tweaks %} + +{% block title %} + Organisation {{ rescue_org }} von regelmäßiger Prüfung ausschließen +{% endblock %} + +{% block content %} +

Organisation {{ rescue_org }} von regelmäßiger Prüfung ausschließen

+
+ {% csrf_token %} + {{ form }} + + {% translate "Zurück (nicht exkludieren)" %} + +
+{% endblock %} \ No newline at end of file diff --git a/src/fellchensammlung/templates/fellchensammlung/partials/partial-check-rescue-org.html b/src/fellchensammlung/templates/fellchensammlung/partials/partial-check-rescue-org.html index 34910e8..c95a5a3 100644 --- a/src/fellchensammlung/templates/fellchensammlung/partials/partial-check-rescue-org.html +++ b/src/fellchensammlung/templates/fellchensammlung/partials/partial-check-rescue-org.html @@ -75,15 +75,7 @@ \ No newline at end of file diff --git a/src/fellchensammlung/tools/model_helpers.py b/src/fellchensammlung/tools/model_helpers.py index cd6206b..46730b1 100644 --- a/src/fellchensammlung/tools/model_helpers.py +++ b/src/fellchensammlung/tools/model_helpers.py @@ -110,7 +110,8 @@ class AdoptionNoticeStatusChoicesDescriptions: _ansc.AwaitingAction.WAITING_FOR_REVIEW: _( "Deaktiviert bis Moderator*innen die Vermittlung prüfen können."), _ansc.AwaitingAction.NEEDS_ADDITIONAL_INFO: _("Deaktiviert bis Informationen nachgetragen werden."), - _ansc.AwaitingAction.UNCHECKED: _("Vermittlung deaktiviert bis sie vom Team auf Aktualität geprüft wurde."), + _ansc.AwaitingAction.UNCHECKED: _( + "Vermittlung deaktiviert bis sie vom Team auf Aktualität geprüft wurde."), _ansc.Disabled.AGAINST_RULES: _("Vermittlung deaktiviert da sie gegen die Regeln verstößt."), _ansc.Disabled.OTHER: _("Vermittlung deaktiviert.") @@ -125,3 +126,11 @@ class AdoptionNoticeProcessTemplates: _bp = "fellchensammlung/partials/adoption_process/" # Base path for ease mapping = {AdoptionProcess.CONTACT_PERSON_IN_AN: f"{_bp}contact_person_in_an.html", } + + +class RegularCheckStatusChoices(models.TextChoices): + REGULAR_CHECK = "regular_check", _("Wird regelmäßig geprüft") + EXCLUDED_NO_ONLINE_LISTING = "excluded_no_online_listing", _("Exkludiert: Tiere werden nicht online gelistet") + EXCLUDED_OTHER_ORG = "excluded_other_org", _("Exkludiert: Andere Organisation wird geprüft") + EXCLUDED_SCOPE = "excluded_scope", _("Exkludiert: Organisation hat nie Notfellchen-relevanten Vermittlungen") + EXCLUDED_OTHER = "excluded_other", _("Exkludiert: Anderer Grund") diff --git a/src/fellchensammlung/urls.py b/src/fellchensammlung/urls.py index dad34e7..0680084 100644 --- a/src/fellchensammlung/urls.py +++ b/src/fellchensammlung/urls.py @@ -47,6 +47,8 @@ urlpatterns = [ path("tierschutzorganisationen/", views.list_rescue_organizations, name="rescue-organizations"), path("tierschutzorganisationen//", views.detail_view_rescue_organization, name="rescue-organization-detail"), + path("tierschutzorganisationen//exkludieren", views.exclude_from_regular_check, + name="rescue-organization-exclude"), path("tierschutzorganisationen/spezialisierung/", views.specialized_rescues, name="specialized-rescue-organizations"), diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index 121def5..0ffde6f 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -25,7 +25,8 @@ from .models import AdoptionNotice, Text, Animal, Rule, Image, Report, Moderatio Species, Log, Timestamp, TrustLevel, SexChoicesWithAll, SearchSubscription, \ ImportantLocation, SpeciesSpecificURL, NotificationTypeChoices, SocialMediaPost from .forms import AdoptionNoticeForm, ImageForm, ReportAdoptionNoticeForm, \ - CommentForm, ReportCommentForm, AnimalForm, AdoptionNoticeFormAutoAnimal, SpeciesURLForm, RescueOrgInternalComment + CommentForm, ReportCommentForm, AnimalForm, AdoptionNoticeFormAutoAnimal, SpeciesURLForm, RescueOrgInternalComment, \ + UpdateRescueOrgRegularCheckStatus from .models import Language, Announcement from .tools import i18n, img from .tools.fedi import post_an_to_fedi @@ -36,7 +37,7 @@ from .tools.admin import clean_locations, get_unchecked_adoption_notices, deacti from .tasks import post_adoption_notice_save from rest_framework.authtoken.models import Token -from .tools.model_helpers import AdoptionNoticeStatusChoices, AdoptionNoticeProcessTemplates +from .tools.model_helpers import AdoptionNoticeStatusChoices, AdoptionNoticeProcessTemplates, RegularCheckStatusChoices from .tools.search import AdoptionNoticeSearch, RescueOrgSearch @@ -896,6 +897,23 @@ def rescue_organization_check_dq(request): return rescue_organization_check(request, context) +@user_passes_test(user_is_trust_level_or_above) +def exclude_from_regular_check(request, rescue_organization_id): + rescue_org = get_object_or_404(RescueOrganization, pk=rescue_organization_id) + if request.method == "POST": + form = UpdateRescueOrgRegularCheckStatus(request.POST, instance=rescue_org) + if form.is_valid(): + form.save() + if form.cleaned_data["regular_check_status"] != RegularCheckStatusChoices.REGULAR_CHECK: + rescue_org.exclude_from_check = True + rescue_org.save() + return redirect(reverse("organization-check")) + else: + form = UpdateRescueOrgRegularCheckStatus(instance=rescue_org) + context = {"form": form, rescue_org: rescue_org} + return render(request, 'fellchensammlung/forms/form-exclude-org-from-check.html', context=context) + + @user_passes_test(user_is_trust_level_or_above) def moderation_tools_overview(request): context = None