From f9ef8a5fbc908cba78604d122fa1f9a437d2cadb Mon Sep 17 00:00:00 2001 From: George Hickman Date: Wed, 6 Sep 2023 14:56:16 +0100 Subject: [PATCH] Stop building redirects when a Project's Org is changed Orgs are no longer part of a Project's URL structure so we don't need to build redirects for them anymore. --- staff/views/projects.py | 2 +- tests/unit/staff/views/test_projects.py | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/staff/views/projects.py b/staff/views/projects.py index 10f994b6a..0f876b586 100644 --- a/staff/views/projects.py +++ b/staff/views/projects.py @@ -199,7 +199,7 @@ def form_valid(self, form): # new.project because self.object is mutated when ModelForm._post_clean # updates the instance it was passed. This is because form.instance is # set from the passed in self.object. - if {"org", "slug"} & set(form.changed_data): + if "slug" in form.changed_data: new.redirects.create( created_by=self.request.user, old_url=old.get_absolute_url(), diff --git a/tests/unit/staff/views/test_projects.py b/tests/unit/staff/views/test_projects.py index 0c95ec760..8b7cb6a14 100644 --- a/tests/unit/staff/views/test_projects.py +++ b/tests/unit/staff/views/test_projects.py @@ -315,9 +315,6 @@ def test_projectedit_post_success(rf, core_developer): Redirect.objects.count() == 1 redirect = Redirect.objects.first() assert redirect.project_id == original.pk - assert redirect.old_url == original.get_absolute_url().replace( - updated.org.get_absolute_url(), old_org.get_absolute_url() - ) def test_projectedit_post_success_when_not_changing_org_or_slug(rf, core_developer):