Repository: pypi/warehouse

Issue:
Make error message (for when the admin intervention flag is set) work with Test PyPI
Right now, when someone tries to upload a package to PyPI but the admin intervention flag is set (meaning that we're under a spam attack and the PyPI admins have temporarily shut off all uploads), the error message we send them includes -- hardcoded -- the URL https://pypi.org. Instead, we should use Pyramid's URL routing to refer to the URL of the PyPI in question, thus ensuring that we send error messages that, as appropriate, refer to pypi.org, test.pypi.org, or any other future PyPI.

To fix this, look at `warehouse/forklift/legacy.py` and `tests/unit/forklift/test_legacy.py` (the test is `test_fails_with_admin_flag_set`), and make changes similar to the changes I made in #3183. If you're used to string substitution/string formatting in Python, this should be a pretty approachable first Warehouse issue.

---

**Good First Issue**: This issue is good for first time contributors. If you've already contributed to Warehouse, please work on [another issue without this label](https://github.com/pypa/warehouse/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+-label%3A%22good+first+issue%22) instead. If there is not a corresponding pull request for this issue, it is up for grabs. For directions for getting set up, see our [Getting Started Guide](https://warehouse.pypa.io/development/getting-started/). If you are working on this issue and have questions, please feel free to ask them here, [`#pypa-dev` on Freenode](https://webchat.freenode.net/?channels=%23pypa-dev), or the [pypa-dev mailing list](https://groups.google.com/forum/#!forum/pypa-dev).



Discussion:

Resolving patch:
diff --git a/warehouse/forklift/legacy.py b/warehouse/forklift/legacy.py
--- a/warehouse/forklift/legacy.py
+++ b/warehouse/forklift/legacy.py
@@ -810,7 +810,10 @@ def file_upload(request):
             raise _exc_with_message(
                 HTTPForbidden,
                 ("New Project Registration Temporarily Disabled "
-                 "See https://pypi.org/help#admin-intervention for details"),
+                 "See {projecthelp} for details")
+                .format(
+                    projecthelp=request.route_url(
+                        'help', _anchor='admin-intervention')),
             ) from None
 
         # Ensure that user has at least one verified email address. This should


Test patch:
diff --git a/tests/unit/forklift/test_legacy.py b/tests/unit/forklift/test_legacy.py
--- a/tests/unit/forklift/test_legacy.py
+++ b/tests/unit/forklift/test_legacy.py
@@ -1045,6 +1045,10 @@ def test_fails_with_admin_flag_set(self, pyramid_config, db_request):
             ),
         })
 
+        db_request.route_url = pretend.call_recorder(
+            lambda route, **kw: "/the/help/url/"
+        )
+
         with pytest.raises(HTTPForbidden) as excinfo:
             legacy.file_upload(db_request)
 
@@ -1053,7 +1057,7 @@ def test_fails_with_admin_flag_set(self, pyramid_config, db_request):
         assert resp.status_code == 403
         assert resp.status == ("403 New Project Registration Temporarily "
                                "Disabled See "
-                               "https://pypi.org/help#admin-intervention for "
+                               "/the/help/url/ for "
                                "details")
 
     def test_upload_fails_without_file(self, pyramid_config, db_request):