Repository: mdn/kuma

Issue:
/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype
# Request type
<!-- Select the appropriate option -->
- [ ] Please close this issue, I accidentally submitted it without adding any details
- [ ] New documentation
- [x] Correction or update


# Details
I was trying to make it redirect to the main `Array` document, but I can't edit it. (404)
Seems like that if the upstream document (`/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype`) is removed, localized ones throw 404 in `$edit`.


Discussion:
So basically, you want 

https://wiki.developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype

to just redirect to 

https://wiki.developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array

In which case, yes, confirmed. When I try to edit https://wiki.developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype to put the redirect in place, it gives me a 404.

I think this needs to be fixed by the devs; I'm going to transfer it over to the kuma repo.
It's not the first time we've seen this. The reasons is that https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array is deleted. (aka. soft delete)
<img width="1162" alt="Screen Shot 2020-02-10 at 11 28 30 AM" src="https://user-images.githubusercontent.com/26739/74169130-d2460c00-4bf8-11ea-9e7f-67a391d4bce8.png">

I think a simple solution is to dig into the `$edit` and wherever it looks up its parent, it should also accept that the parent might be (soft) deleted. 
Perhaps also, a warning message somewhere too. 
I can reproduce this locally. 
@atopal we've put this as a p3, but feel free to prioritize.

Resolving patch:
diff --git a/kuma/wiki/managers.py b/kuma/wiki/managers.py
--- a/kuma/wiki/managers.py
+++ b/kuma/wiki/managers.py
@@ -104,6 +104,13 @@ def get_queryset(self):
         return super(DeletedDocumentManager, self).get_queryset().filter(deleted=True)
 
 
+class AllDocumentManager(BaseDocumentManager):
+    """
+    Similar to DocumentAdminManager class but more explicit in its name.
+    Use this when you don't want *any* filtering by 'deleted'.
+    """
+
+
 class DocumentAdminManager(BaseDocumentManager):
     """
     A manager used only in the admin site, which does not perform any
diff --git a/kuma/wiki/models.py b/kuma/wiki/models.py
--- a/kuma/wiki/models.py
+++ b/kuma/wiki/models.py
@@ -56,6 +56,7 @@
 )
 from .jobs import DocumentContributorsJob, DocumentTagsJob
 from .managers import (
+    AllDocumentManager,
     DeletedDocumentManager,
     DocumentAdminManager,
     DocumentManager,
@@ -330,6 +331,7 @@ class Meta(object):
 
     objects = DocumentManager()
     deleted_objects = DeletedDocumentManager()
+    all_objects = AllDocumentManager()
     admin_objects = DocumentAdminManager()
 
     def __str__(self):
diff --git a/kuma/wiki/views/translate.py b/kuma/wiki/views/translate.py
--- a/kuma/wiki/views/translate.py
+++ b/kuma/wiki/views/translate.py
@@ -54,9 +54,15 @@ def translate(request, document_slug, document_locale):
     # That might help reduce the headache-inducing branchiness.
 
     # The parent document to translate from
-    parent_doc = get_object_or_404(
-        Document, locale=settings.WIKI_DEFAULT_LANGUAGE, slug=document_slug
-    )
+    try:
+        # Use '.all_objects' because the parent might have been soft deleted.
+        # And if we don't respect that fact, it would become impossible to
+        # edit a the child of it.
+        parent_doc = Document.all_objects.get(
+            locale=settings.WIKI_DEFAULT_LANGUAGE, slug=document_slug
+        )
+    except Document.DoesNotExist:
+        raise Http404("Parent document does not exist")
 
     # Get the mapping here and now so it can be used for input validation
     language_mapping = get_language_mapping()


Test patch: