Repository: pypi/warehouse

Issue:
Removing a project from an organization leads to 403 error
If the user is not an Owner of the project, removing a project from an organization leads to an error

To recreate the issue-

- Click on Your Projects
- Select a Project and click on Manage
- Click on Settings
- Click on Remove Project
- Enter the Project name
- Click on Remove Project

The confirmation goes to /manage/project/project_name/settings/ which the user does not have access to as the user is not an Owner of the project anymore. 

![test11](https://user-images.githubusercontent.com/37237726/183537333-67d475d1-5ada-428e-ba29-bfeb5ea5189b.png)


The URL will have to be changed to the home page to see the confirmation message that the project has been removed from the organization.
![test12](https://user-images.githubusercontent.com/37237726/183537338-2a019437-e898-4dfe-8b6e-8e013521d3bc.png)




Discussion:
@s-mm this ticket mentions to redirect to the home page. I was thinking that a redirect to the Organization Project Management page seems appropriate? Maybe this is what you had in mind? Please have a look and let me know if this makes sense or if you were envisioning something different.
![image](https://user-images.githubusercontent.com/76828663/190928687-6cba0c98-00a2-41f1-9ad1-b79a9566eee3.png)

@sterbo Your suggestion is fine.

Resolving patch:
diff --git a/warehouse/manage/views.py b/warehouse/manage/views.py
--- a/warehouse/manage/views.py
+++ b/warehouse/manage/views.py
@@ -3153,6 +3153,17 @@ def remove_organization_project(project, request):
             queue="success",
         )
 
+        return HTTPSeeOther(
+            request.route_path(
+                "manage.organization.projects",
+                organization_name=organization.normalized_name,
+            )
+        )
+
+    request.session.flash(
+        ("Could not remove project from organization - no organization found"),
+        queue="error",
+    )
     return HTTPSeeOther(
         request.route_path("manage.project.settings", project_name=project.name)
     )


Test patch:
diff --git a/tests/unit/manage/test_views.py b/tests/unit/manage/test_views.py
--- a/tests/unit/manage/test_views.py
+++ b/tests/unit/manage/test_views.py
@@ -5912,7 +5912,12 @@ def test_remove_organization_project_no_current_organization(
 
         result = views.remove_organization_project(project, db_request)
 
-        assert db_request.session.flash.calls == []
+        assert db_request.session.flash.calls == [
+            pretend.call(
+                ("Could not remove project from organization - no organization found"),
+                queue="error",
+            )
+        ]
         assert db_request.route_path.calls == [
             pretend.call("manage.project.settings", project_name="foo")
         ]
@@ -6035,7 +6040,10 @@ def test_remove_organization_project(self, monkeypatch, db_request):
             pretend.call("Removed the project 'foo' from 'bar'", queue="success")
         ]
         assert db_request.route_path.calls == [
-            pretend.call("manage.project.settings", project_name="foo")
+            pretend.call(
+                "manage.organization.projects",
+                organization_name=project.organization.normalized_name,
+            )
         ]
         assert isinstance(result, HTTPSeeOther)
         assert result.headers["Location"] == "/the-redirect"