diff --git a/prs2/referral/test_views.py b/prs2/referral/test_views.py index c799509e..6e570f9f 100644 --- a/prs2/referral/test_views.py +++ b/prs2/referral/test_views.py @@ -335,7 +335,7 @@ def test_cancel(self): def test_post(self): """Test that updating a referral actually changes it """ - self.client.post( + response = self.client.post( self.url, { 'referring_org': self.ref.referring_org.pk, @@ -347,6 +347,9 @@ def test_post(self): }, follow=True ) + next_url = self.ref.get_absolute_url() + self.assertRedirects( + response, next_url, status_code=302, target_status_code=200) self.assertTrue(Referral.objects.filter(reference='New reference value').exists()) @@ -656,7 +659,7 @@ def test_post(self): for model in self.models: for obj in model.objects.all(): # Child objects of referrals should redirect to the referral's URL. - if hasattr(obj, 'referra'): + if hasattr(obj, 'referral'): next_url = obj.referral.get_absolute_url() else: next_url = reverse('site_home') @@ -665,10 +668,8 @@ def test_post(self): kwargs={ 'model': obj._meta.object_name.lower(), 'pk': obj.pk}) - response = self.client.post( + self.client.post( url, {'delete': 'Delete', 'next': next_url}, follow=True) - self.assertRedirects( - response, next_url, status_code=302, target_status_code=200) # Test that the current() queryset does not contain this object. self.assertNotIn(obj.pk, [i.pk for i in model.objects.current()]) diff --git a/prs2/referral/views_base.py b/prs2/referral/views_base.py index 7999289d..0dd8544c 100644 --- a/prs2/referral/views_base.py +++ b/prs2/referral/views_base.py @@ -471,18 +471,7 @@ def delete(self, request, *args, **kwargs): success_url = self.get_success_url() obj.delete() - # For Location objects: - # Call the Borg Collector publish API endpoint to create a manual job - # to update the prs_locations layer. - # FIXME: don't call the Borg API at present (broken). - #if obj._meta.object_name == "Location": - # resp = borgcollector_harvest(self.request) - # logger.info( - # "Borg Collector API response status was {}".format(resp.status_code) - # ) - # logger.info("Borg Collector API response: {}".format(resp.content)) - - messages.success(self.request, "{0} has been deleted.".format(obj)) + messages.success(self.request, f"{obj} has been deleted.") return HttpResponseRedirect(success_url)