From e00dda1dc2a8913f5304785a8b86bb4ecef396f2 Mon Sep 17 00:00:00 2001 From: moanos Date: Sun, 13 Jul 2025 12:58:14 +0200 Subject: [PATCH] feat: add option to mark a rescue org to be in active communication That enables to filter them out from a check without forgetting there are to-dos. Most often this will be used when you want to call a rescue org but they can currently not be reached --- ...nization_ongoing_communication_and_more.py | 25 +++++++++++++++++++ src/fellchensammlung/models.py | 3 +++ .../rescue-organization-check.html | 12 +++++++++ src/fellchensammlung/views.py | 10 +++++--- 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 src/fellchensammlung/migrations/0055_rescueorganization_ongoing_communication_and_more.py diff --git a/src/fellchensammlung/migrations/0055_rescueorganization_ongoing_communication_and_more.py b/src/fellchensammlung/migrations/0055_rescueorganization_ongoing_communication_and_more.py new file mode 100644 index 0000000..2707eaf --- /dev/null +++ b/src/fellchensammlung/migrations/0055_rescueorganization_ongoing_communication_and_more.py @@ -0,0 +1,25 @@ +# Generated by Django 5.2.1 on 2025-07-13 10:54 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fellchensammlung', '0054_alter_notification_comment'), + ] + + operations = [ + migrations.AddField( + model_name='rescueorganization', + name='ongoing_communication', + field=models.BooleanField(default=False, help_text='Es findet gerade Kommunikation zwischen Notfellchen und der Organisation statt.', verbose_name='In aktiver Kommunikation'), + ), + migrations.AlterField( + model_name='notification', + name='user_to_notify', + field=models.ForeignKey(help_text='Useraccount der Benachrichtigt wird', on_delete=django.db.models.deletion.CASCADE, related_name='user', to=settings.AUTH_USER_MODEL, verbose_name='Empfänger*in'), + ), + ] diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index 3523e3d..aa92f8a 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -151,6 +151,9 @@ 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")) + ongoing_communication = models.BooleanField(default=False, verbose_name=_('In aktiver Kommunikation'), + help_text=_( + "Es findet gerade Kommunikation zwischen Notfellchen und der Organisation statt.")) parent_org = models.ForeignKey("RescueOrganization", on_delete=models.PROTECT, blank=True, null=True) class Meta: diff --git a/src/fellchensammlung/templates/fellchensammlung/rescue-organization-check.html b/src/fellchensammlung/templates/fellchensammlung/rescue-organization-check.html index 94346de..60b8f84 100644 --- a/src/fellchensammlung/templates/fellchensammlung/rescue-organization-check.html +++ b/src/fellchensammlung/templates/fellchensammlung/rescue-organization-check.html @@ -30,6 +30,18 @@
+
+

{% translate "In aktiver Kommunikation" %}

+
+ {% for rescue_org in rescue_orgs_with_ongoing_communication %} +
+ {% include "fellchensammlung/partials/partial-check-rescue-org.html" %} +
+ {% endfor %} +
+
+
+

{% translate "Zuletzt geprüft" %}

diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index 13a3aab..4a41ac7 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -803,12 +803,15 @@ def rescue_organization_check(request, context=None): if comment_form.is_valid(): comment_form.save() - rescue_orgs_to_check = RescueOrganization.objects.filter(exclude_from_check=False).order_by("last_checked")[:10] + rescue_orgs_to_check = RescueOrganization.objects.filter(exclude_from_check=False, ongoing_communication=False).order_by("last_checked")[:3] + rescue_orgs_with_ongoing_communication = RescueOrganization.objects.filter(ongoing_communication=True).order_by("updated_at") + rescue_orgs_last_checked = RescueOrganization.objects.filter().order_by("-last_checked")[:10] + rescue_orgs_to_comment = rescue_orgs_to_check | rescue_orgs_with_ongoing_communication | rescue_orgs_last_checked # Prepare a form for each organization comment_forms = { - org.id: RescueOrgInternalComment(instance=org) for org in rescue_orgs_to_check + org.id: RescueOrgInternalComment(instance=org) for org in rescue_orgs_to_comment } - rescue_orgs_last_checked = RescueOrganization.objects.filter().order_by("-last_checked")[:10] + timeframe = timezone.now().date() - timedelta(days=14) num_rescue_orgs_to_check = RescueOrganization.objects.filter(exclude_from_check=False).filter( last_checked__lt=timeframe).count() @@ -826,6 +829,7 @@ def rescue_organization_check(request, context=None): context["num_rescue_orgs_to_check"] = num_rescue_orgs_to_check context["percentage_checked"] = percentage_checked context["num_rescue_orgs_checked"] = num_rescue_orgs_checked + context["rescue_orgs_with_ongoing_communication"] = rescue_orgs_with_ongoing_communication return render(request, 'fellchensammlung/rescue-organization-check.html', context=context)