Repository: django-wiki/django-wiki

Issue:
SHOW_MAX_CHILDREN setting is ignored
There is a hardcoded value of 20 in wiki/views/mixins.py
<pre>
kwargs["children_slice"] = self.children_slice[:20]
kwargs["children_slice_more"] = len(self.children_slice) > 20
</pre>


Discussion:
Looks like you are right. It's like the setting is only used to fetch that amount of children, but then it gets sliced to 20 no matter what. Setting it to 30 would still trim it to 20.

If you can fix and test this (manually is fine), that would be most welcome :+1: 

Resolving patch:
diff --git a/src/wiki/views/mixins.py b/src/wiki/views/mixins.py
--- a/src/wiki/views/mixins.py
+++ b/src/wiki/views/mixins.py
@@ -37,7 +37,7 @@ def get_context_data(self, **kwargs):
         kwargs["urlpath"] = self.urlpath
         kwargs["article"] = self.article
         kwargs["article_tabs"] = registry.get_article_tabs()
-        kwargs["children_slice"] = self.children_slice[:20]
+        kwargs["children_slice"] = self.children_slice[: settings.SHOW_MAX_CHILDREN]
         kwargs["children_slice_more"] = len(self.children_slice) > 20
         kwargs["plugins"] = registry.get_plugins()
         return kwargs


Test patch:
diff --git a/tests/core/test_views.py b/tests/core/test_views.py
--- a/tests/core/test_views.py
+++ b/tests/core/test_views.py
@@ -9,6 +9,7 @@
 from django.utils.html import escape
 from django_functest import FuncBaseMixin
 from wiki import models
+from wiki.conf import settings as wiki_settings
 from wiki.forms import PermissionsForm
 from wiki.forms import validate_slug_numbers
 from wiki.models import ArticleRevision
@@ -149,12 +150,40 @@ def test_normaluser_root(self):
         response = self.client.get(reverse("wiki:get", kwargs={"path": ""}))
         self.assertEqual(response.status_code, 200)
 
+    def test_show_max_children(self):
+        response = self.client.post(
+            resolve_url("wiki:create", path=""),
+            {"title": "Main", "slug": "WikiRoot", "content": "Content level 1"},
+        )
+        self.assertRedirects(response, resolve_url("wiki:get", path="wikiroot/"))
+        response = self.client.get(reverse("wiki:get", kwargs={"path": "wikiroot/"}))
+        self.assertEqual(response.status_code, 200)
+        self.assertIsInstance(response.context["children_slice"], list)
+        self.assertEqual(len(response.context["children_slice"]), 0)
+        for idx in range(1, 40):
+            response = self.client.post(
+                resolve_url("wiki:create", path="wikiroot/"),
+                {
+                    "title": "Sub Article {0}".format(idx),
+                    "slug": "SubArticle{0}".format(idx),
+                    "content": "Sub Article {0}".format(idx),
+                },
+            )
+            self.assertRedirects(
+                response,
+                resolve_url("wiki:get", path="wikiroot/subarticle{0}/".format(idx)),
+            )
+        response = self.client.get(reverse("wiki:get", kwargs={"path": "wikiroot/"}))
+        self.assertEqual(response.status_code, 200)
+        self.assertEqual(
+            len(response.context["children_slice"]), wiki_settings.SHOW_MAX_CHILDREN
+        )
+
 
 class CreateViewTest(
     RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase
 ):
     def test_create_nested_article_in_article(self):
-
         response = self.client.post(
             resolve_url("wiki:create", path=""),
             {"title": "Level 1", "slug": "Level1", "content": "Content level 1"},