From d72bd22f6d13a1ee6786b7a1603b401ad5cf5d79 Mon Sep 17 00:00:00 2001 From: moanos Date: Thu, 3 Jul 2025 11:29:03 +0200 Subject: [PATCH] feat: Add species specialization and parent option to Rescue Orgs --- docs/admin/monitoring.rst | 1 + ...zation_parent_org_speciesspecialization.py | 27 +++++++++++++++++++ src/fellchensammlung/models.py | 14 +++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/fellchensammlung/migrations/0051_rescueorganization_parent_org_speciesspecialization.py diff --git a/docs/admin/monitoring.rst b/docs/admin/monitoring.rst index c12fa2f..46f38b7 100644 --- a/docs/admin/monitoring.rst +++ b/docs/admin/monitoring.rst @@ -67,5 +67,6 @@ Healthchecks You can configure notfellchen to give a hourly ping to a healthchecks server. If this ping is not received, you will get notified and cna check why the celery jobs are no running. Add the following to your `notfellchen.cfg` and adjust the URL to match your check. .. code:: + [monitoring] healthchecks_url=https://health.example.org/ping/5fa7c9b2-753a-4cb3-bcc9-f982f5bc68e8 diff --git a/src/fellchensammlung/migrations/0051_rescueorganization_parent_org_speciesspecialization.py b/src/fellchensammlung/migrations/0051_rescueorganization_parent_org_speciesspecialization.py new file mode 100644 index 0000000..6d1758c --- /dev/null +++ b/src/fellchensammlung/migrations/0051_rescueorganization_parent_org_speciesspecialization.py @@ -0,0 +1,27 @@ +# Generated by Django 5.2.1 on 2025-07-03 09:28 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fellchensammlung', '0050_rename_rescues_organization_speciesspecificurl_rescue_organization'), + ] + + operations = [ + migrations.AddField( + model_name='rescueorganization', + name='parent_org', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='fellchensammlung.rescueorganization'), + ), + migrations.CreateModel( + name='SpeciesSpecialization', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('rescue_organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fellchensammlung.rescueorganization', verbose_name='Tierschutzorganisation')), + ('species', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fellchensammlung.species', verbose_name='Tierart')), + ], + ), + ] diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index 8afc929..c40793b 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -68,7 +68,6 @@ class Location(models.Model): def position(self): return (self.latitude, self.longitude) - @staticmethod def get_location_from_string(location_string): try: @@ -150,6 +149,7 @@ 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")) + parent_org = models.ForeignKey("RescueOrganization", on_delete=models.PROTECT, blank=True, null=True) class Meta: unique_together = ('external_object_identifier', 'external_source_identifier',) @@ -990,3 +990,15 @@ class SpeciesSpecificURL(models.Model): rescue_organization = models.ForeignKey(RescueOrganization, on_delete=models.CASCADE, verbose_name=_("Tierschutzorganisation")) url = models.URLField(verbose_name=_("Tierartspezifische URL")) + + +class SpeciesSpecialization(models.Model): + """ + Model that allows to specify if a rescue organization has a specialization for dedicated species + """ + species = models.ForeignKey(Species, on_delete=models.CASCADE, verbose_name=_("Tierart")) + rescue_organization = models.ForeignKey(RescueOrganization, on_delete=models.CASCADE, + verbose_name=_("Tierschutzorganisation")) + + def ___str__(self): + return f"[{self.rescue_organization}] - {self.species}"