diff --git a/src/fellchensammlung/forms.py b/src/fellchensammlung/forms.py index 3e59f1d..8038c90 100644 --- a/src/fellchensammlung/forms.py +++ b/src/fellchensammlung/forms.py @@ -10,7 +10,7 @@ from django.utils.translation import gettext_lazy as _ from notfellchen.settings import MEDIA_URL from crispy_forms.layout import Div -from .tools.model_helpers import reason_for_signup_label, reason_for_signup_help_text +from .tools.model_helpers import reason_for_signup_label, reason_for_signup_help_text, AdoptionNoticeStatusChoices def animal_validator(value: str): @@ -184,3 +184,15 @@ class RescueOrgSearchForm(forms.Form): location_string = forms.CharField(max_length=100, label=_("Stadt"), required=False) max_distance = forms.ChoiceField(choices=DistanceChoices, initial=DistanceChoices.TWENTY, label=_("Suchradius")) + + +class CloseAdoptionNoticeForm(forms.ModelForm): + template_name = "fellchensammlung/forms/form_snippets.html" + + adoption_notice_status = forms.ChoiceField(choices=AdoptionNoticeStatusChoices.Closed, + label=_("Status"), + help_text=_("Gib den neuen Status der Vermittlung an")) + + class Meta: + model = AdoptionNotice + fields = ('adoption_notice_status',) diff --git a/src/fellchensammlung/migrations/0072_alter_adoptionnotice_adoption_notice_status_and_more.py b/src/fellchensammlung/migrations/0072_alter_adoptionnotice_adoption_notice_status_and_more.py new file mode 100644 index 0000000..4a87593 --- /dev/null +++ b/src/fellchensammlung/migrations/0072_alter_adoptionnotice_adoption_notice_status_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 5.2.8 on 2025-11-29 09:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fellchensammlung', '0071_historicaladoptionnotice_historicalanimal_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='adoptionnotice', + name='adoption_notice_status', + field=models.TextField(choices=[('active_searching', 'Searching'), ('active_interested', 'Interested'), ('awaiting_action_waiting_for_review', 'Waiting for review'), ('awaiting_action_needs_additional_info', 'Needs additional info'), ('awaiting_action_unchecked', 'Unchecked'), ('closed_successfully', 'Erfolgreich vermittelt'), ('closed_animal_died', 'Tier gestorben'), ('closed_for_other_adoption_notice', 'Vermittlung wurde zugunsten einer anderen geschlossen.'), ('closed_not_open_for_adoption_anymore', 'Tier(e) stehen nicht mehr zur Vermittlung bereit.'), ('closed_link_to_more_info_not_reachable', 'Der Link zu weiteren Informationen ist nicht mehr erreichbar.'), ('closed_other', 'Anderes'), ('disabled_against_the_rules', 'Against the rules'), ('disabled_other', 'Other (disabled)')], max_length=64, verbose_name='Status'), + ), + migrations.AlterField( + model_name='historicaladoptionnotice', + name='adoption_notice_status', + field=models.TextField(choices=[('active_searching', 'Searching'), ('active_interested', 'Interested'), ('awaiting_action_waiting_for_review', 'Waiting for review'), ('awaiting_action_needs_additional_info', 'Needs additional info'), ('awaiting_action_unchecked', 'Unchecked'), ('closed_successfully', 'Erfolgreich vermittelt'), ('closed_animal_died', 'Tier gestorben'), ('closed_for_other_adoption_notice', 'Vermittlung wurde zugunsten einer anderen geschlossen.'), ('closed_not_open_for_adoption_anymore', 'Tier(e) stehen nicht mehr zur Vermittlung bereit.'), ('closed_link_to_more_info_not_reachable', 'Der Link zu weiteren Informationen ist nicht mehr erreichbar.'), ('closed_other', 'Anderes'), ('disabled_against_the_rules', 'Against the rules'), ('disabled_other', 'Other (disabled)')], max_length=64, verbose_name='Status'), + ), + ] diff --git a/src/fellchensammlung/migrations/0073_adoption_notice_status_successful.py b/src/fellchensammlung/migrations/0073_adoption_notice_status_successful.py new file mode 100644 index 0000000..77fd31d --- /dev/null +++ b/src/fellchensammlung/migrations/0073_adoption_notice_status_successful.py @@ -0,0 +1,23 @@ +import logging + +from django.db import migrations + + +def migrate_status(apps, schema_editor): + # We can't import the model directly as it may be a newer + # version than this migration expects. We use the historical version. + AdoptionNotice = apps.get_model("fellchensammlung", "AdoptionNotice") + for adoption_notice in AdoptionNotice.objects.filter( + adoption_notice_status__in=("closed_successful_without_notfellchen", "closed_successful_with_notfellchen")): + adoption_notice.adoption_notice_status = "closed_successful" + adoption_notice.save() + + +class Migration(migrations.Migration): + dependencies = [ + ('fellchensammlung', '0072_alter_adoptionnotice_adoption_notice_status_and_more'), + ] + + operations = [ + migrations.RunPython(migrate_status), + ] diff --git a/src/fellchensammlung/templates/fellchensammlung/misc/deactivate-an.html b/src/fellchensammlung/templates/fellchensammlung/misc/deactivate-an.html index feeb03a..45268c0 100644 --- a/src/fellchensammlung/templates/fellchensammlung/misc/deactivate-an.html +++ b/src/fellchensammlung/templates/fellchensammlung/misc/deactivate-an.html @@ -6,21 +6,7 @@