Skip to content

Commit

Permalink
Merge pull request #3527 from opensafely-core/stop-adding-redirects-f…
Browse files Browse the repository at this point in the history
…or-org-change

Stop building redirects when a Project's Org is changed
  • Loading branch information
ghickman authored Sep 11, 2023
2 parents 142757e + f9ef8a5 commit 85c05c8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
2 changes: 1 addition & 1 deletion staff/views/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/staff/views/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 85c05c8

Please sign in to comment.