feat: Fully replace the Adoption Notice Status model with the field

This commit is contained in:
2025-08-31 10:52:48 +02:00
parent 70f077e393
commit fd481fef2e
16 changed files with 102 additions and 219 deletions

View File

@@ -8,6 +8,7 @@ from django.test import TestCase
from model_bakery import baker
from fellchensammlung.models import AdoptionNotice, RescueOrganization
from fellchensammlung.tools.model_helpers import AdoptionNoticeStatusChoices
class DeactivationTest(TestCase):
@@ -25,10 +26,10 @@ class DeactivationTest(TestCase):
name="TestAdoption3",
created_at=less_than_three_weeks_ago)
cls.adoption1.set_active()
cls.adoption1.adoption_notice_status = AdoptionNoticeStatusChoices.Active.SEARCHING
cls.adoption1.last_checked = more_than_three_weeks_ago # Reset updated_at to simulate test conditions
cls.adoption1.save()
cls.adoption3.set_active()
cls.adoption3.adoption_notice_status = AdoptionNoticeStatusChoices.Active.SEARCHING
cls.adoption3.last_checked = less_than_three_weeks_ago # Reset updated_at to simulate test conditions
cls.adoption3.save()
@@ -67,20 +68,20 @@ class PingTest(TestCase):
name="TestAdoption1",
created_at=less_than_three_weeks_ago,
last_checked=less_than_three_weeks_ago,
further_information=link_active)
further_information=link_active,
adoption_notice_status=AdoptionNoticeStatusChoices.Active.SEARCHING)
cls.adoption2 = baker.make(AdoptionNotice,
name="TestAdoption2",
created_at=less_than_three_weeks_ago,
last_checked=less_than_three_weeks_ago,
further_information=link_inactive)
further_information=link_inactive,
adoption_notice_status=AdoptionNoticeStatusChoices.Active.SEARCHING)
cls.adoption3 = baker.make(AdoptionNotice,
name="TestAdoption3",
created_at=less_than_three_weeks_ago,
last_checked=less_than_three_weeks_ago,
further_information=None)
cls.adoption1.set_active()
cls.adoption2.set_active()
cls.adoption3.set_active()
further_information=None,
adoption_notice_status=AdoptionNoticeStatusChoices.Active.SEARCHING)
def test_is_404(self):
urls = [("https://hyteck.de/maxwell", True),

View File

@@ -7,7 +7,7 @@ from fellchensammlung.models import SearchSubscription, User, TrustLevel, Adopti
from model_bakery import baker
from fellchensammlung.tools.geo import LocationProxy
from fellchensammlung.tools.model_helpers import NotificationTypeChoices
from fellchensammlung.tools.model_helpers import NotificationTypeChoices, AdoptionNoticeStatusChoices
from fellchensammlung.tools.search import AdoptionNoticeSearch, notify_search_subscribers
@@ -45,7 +45,7 @@ class TestSearch(TestCase):
species=rat,
sex=SexChoices.MALE,
description="Eine unglaublich süße Ratte")
cls.adoption1.set_active()
cls.adoption1.adoption_notice_status = AdoptionNoticeStatusChoices.Active.SEARCHING
cls.adoption2 = baker.make(AdoptionNotice, name="TestAdoption2", owner=cls.test_user0, location=cls.location_berlin)
rat2 = baker.make(Animal,
@@ -54,7 +54,7 @@ class TestSearch(TestCase):
species=rat,
sex=SexChoices.FEMALE,
description="Eine unglaublich süße Ratte")
cls.adoption2.set_active()
cls.adoption2.adoption_notice_status = AdoptionNoticeStatusChoices.Active.SEARCHING
cls.subscription1 = SearchSubscription.objects.create(owner=cls.test_user1,
location=cls.location_tue,

View File

@@ -2,7 +2,7 @@ from django.test import TestCase
from model_bakery import baker
from fellchensammlung.models import User, TrustLevel, Species, Location, AdoptionNotice, Notification
from fellchensammlung.tools.model_helpers import NotificationTypeChoices
from fellchensammlung.tools.model_helpers import NotificationTypeChoices, AdoptionNoticeStatusChoices
from fellchensammlung.tools.notifications import notify_of_AN_to_be_checked
@@ -26,7 +26,7 @@ class TestNotifications(TestCase):
cls.test_user0.save()
cls.adoption1 = baker.make(AdoptionNotice, name="TestAdoption1", owner=cls.test_user1, )
cls.adoption1.set_unchecked() # Could also emit notification
cls.adoption1.adoption_notice_status = AdoptionNoticeStatusChoices.AwaitingAction.WAITING_FOR_REVIEW
def test_notify_of_AN_to_be_checked(self):
notify_of_AN_to_be_checked(self.adoption1)

View File

@@ -1,14 +1,11 @@
from django.test import TestCase
from django.contrib.auth.models import Permission
from django.urls import reverse
from model_bakery import baker
from fellchensammlung.models import Animal, Species, AdoptionNotice, User, Location, AdoptionNoticeStatus, TrustLevel, \
Animal, Subscriptions, Comment, Notification, SearchSubscription
from fellchensammlung.tools.geo import LocationProxy
from fellchensammlung.tools.model_helpers import NotificationTypeChoices
from fellchensammlung.views import add_adoption_notice
from fellchensammlung.models import Species, AdoptionNotice, User, Location, TrustLevel, \
Animal, Subscriptions, Comment, Notification
from fellchensammlung.tools.model_helpers import NotificationTypeChoices, AdoptionNoticeStatusChoices
class AnimalAndAdoptionTest(TestCase):
@@ -158,7 +155,7 @@ class UpdateQueueTest(TestCase):
# Make sure correct status is set and AN is not shown anymore
self.assertNotContains(response, "TestAdoption3")
self.assertFalse(self.adoption3.is_active)
self.assertEqual(self.adoption3.adoptionnoticestatus.major_status, AdoptionNoticeStatus.CLOSED)
self.assertTrue(self.adoption3.is_closed)
class AdoptionDetailTest(TestCase):
@@ -189,8 +186,8 @@ class AdoptionDetailTest(TestCase):
adoption3.location = stuttgart
adoption3.save()
adoption1.set_active()
adoption3.set_active()
adoption1.adoption_notice_status = AdoptionNoticeStatusChoices.Active.SEARCHING
adoption3.adoption_notice_status = AdoptionNoticeStatusChoices.Active.INTERESTED
adoption2.set_unchecked()
def test_basic_view(self):

View File

@@ -6,6 +6,8 @@ from fellchensammlung.models import User, TrustLevel, AdoptionNotice, Species, R
Location, ImportantLocation
from model_bakery import baker
from fellchensammlung.tools.model_helpers import AdoptionNoticeStatusChoices
class BasicViewTest(TestCase):
@classmethod
@@ -26,7 +28,10 @@ class BasicViewTest(TestCase):
for i in range(0, 8):
ans.append(baker.make(AdoptionNotice, name=f"TestAdoption{i}"))
for i in range(0, 4):
AdoptionNotice.objects.get(name=f"TestAdoption{i}").set_active()
adoption_notice = AdoptionNotice.objects.get(name=f"TestAdoption{i}")
adoption_notice.adoption_notice_status = AdoptionNoticeStatusChoices.Active.SEARCHING
adoption_notice.save()
rule1 = Rule.objects.create(title="Rule 1", rule_text="Description of r1", rule_identifier="rule1",
language=Language.objects.get(name="English"))

View File

@@ -4,11 +4,8 @@ from django.urls import reverse
from model_bakery import baker
from fellchensammlung.models import Animal, Species, AdoptionNotice, User, Location, AdoptionNoticeStatus, TrustLevel, \
Animal, Subscriptions, Comment, Notification, SearchSubscription
from fellchensammlung.tools.geo import LocationProxy
from fellchensammlung.tools.model_helpers import NotificationTypeChoices
from fellchensammlung.views import add_adoption_notice
from fellchensammlung.models import AdoptionNotice, User, Location, SearchSubscription
from fellchensammlung.tools.model_helpers import AdoptionNoticeStatusChoices
class SearchTest(TestCase):
@@ -28,9 +25,11 @@ class SearchTest(TestCase):
# Location of Berlin: lat 52.5170365 lon 13.3888599 PLZ 10115 (Mitte)
adoption1 = baker.make(AdoptionNotice, name="TestAdoption1")
adoption1 = baker.make(AdoptionNotice, name="TestAdoption1",
adoption_notice_status=AdoptionNoticeStatusChoices.Active.SEARCHING)
adoption2 = baker.make(AdoptionNotice, name="TestAdoption2")
adoption3 = baker.make(AdoptionNotice, name="TestAdoption3")
adoption3 = baker.make(AdoptionNotice, name="TestAdoption3",
adoption_notice_status=AdoptionNoticeStatusChoices.Active.INTERESTED)
berlin = Location.get_location_from_string("Berlin")
adoption1.location = berlin
@@ -40,8 +39,6 @@ class SearchTest(TestCase):
adoption3.location = stuttgart
adoption3.save()
adoption1.set_active()
adoption3.set_active()
adoption2.set_unchecked()
cls.subscription1 = SearchSubscription.objects.create(owner=test_user1,