We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Page tree broken after searching and going back
### Describe the Bug
When using the back button of the browser after searching, the page tree is expanded. After that, the collapsing function is broken.

Can we tell the browser to reload the full page after using the back button? However, it would be the best solution to actually keep the status of the tree after using the back button.

~~This could be related to #1131~~

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `integreat_cms/cms/views/pages/page_tree_view.py`
Content:
```
1 import logging
2 
3 from django.contrib import messages
4 from django.shortcuts import render, redirect
5 from django.utils.decorators import method_decorator
6 from django.utils.translation import ugettext as _
7 from django.views.generic import TemplateView
8 
9 from ...constants import translation_status
10 from ...decorators import permission_required
11 from ...forms import PageFilterForm
12 from ...models import Language
13 from .page_context_mixin import PageContextMixin
14 
15 logger = logging.getLogger(__name__)
16 
17 
18 @method_decorator(permission_required("cms.view_page"), name="dispatch")
19 class PageTreeView(TemplateView, PageContextMixin):
20     """
21     View for showing the page tree
22     """
23 
24     #: Template for list of non-archived pages
25     template = "pages/page_tree.html"
26     #: Template for list of archived pages
27     template_archived = "pages/page_tree_archived.html"
28     #: Whether or not to show archived pages
29     archived = False
30 
31     @property
32     def template_name(self):
33         """
34         Select correct HTML template, depending on :attr:`~integreat_cms.cms.views.pages.page_tree_view.PageTreeView.archived` flag
35         (see :class:`~django.views.generic.base.TemplateResponseMixin`)
36 
37         :return: Path to HTML template
38         :rtype: str
39         """
40 
41         return self.template_archived if self.archived else self.template
42 
43     def get(self, request, *args, **kwargs):
44         r"""
45         Render page tree
46 
47         :param request: The current request
48         :type request: ~django.http.HttpResponse
49 
50         :param \*args: The supplied arguments
51         :type \*args: list
52 
53         :param \**kwargs: The supplied keyword arguments
54         :type \**kwargs: dict
55 
56         :return: The rendered template response
57         :rtype: ~django.template.response.TemplateResponse
58         """
59 
60         # current region
61         region_slug = kwargs.get("region_slug")
62         region = request.region
63 
64         # current language
65         language_slug = kwargs.get("language_slug")
66         if language_slug:
67             language = Language.objects.get(slug=language_slug)
68         elif region.default_language:
69             return redirect(
70                 "pages",
71                 **{
72                     "region_slug": region_slug,
73                     "language_slug": region.default_language.slug,
74                 }
75             )
76         else:
77             messages.error(
78                 request,
79                 _("Please create at least one language node before creating pages."),
80             )
81             return redirect(
82                 "language_tree",
83                 **{
84                     "region_slug": region_slug,
85                 }
86             )
87 
88         if not request.user.has_perm("cms.change_page"):
89             messages.warning(
90                 request, _("You don't have the permission to edit or create pages.")
91             )
92 
93         # Filter pages according to given filters, if any
94         filter_data = kwargs.get("filter_data")
95 
96         if filter_data or self.archived:
97             page_queryset = region.pages.all()
98         else:
99             page_queryset = region.pages.filter(lft=1)
100         pages = page_queryset.cache_tree(archived=self.archived)[0]
101 
102         if filter_data:
103             # Set data for filter form rendering
104             filter_form = PageFilterForm(data=filter_data)
105             pages = self.filter_pages(pages, language_slug, filter_form)
106         else:
107             filter_form = PageFilterForm()
108             filter_form.changed_data.clear()
109 
110         return render(
111             request,
112             self.template_name,
113             {
114                 **self.get_context_data(**kwargs),
115                 "pages": pages,
116                 "language": language,
117                 "languages": region.active_languages,
118                 "filter_form": filter_form,
119             },
120         )
121 
122     def post(self, request, *args, **kwargs):
123         r"""
124         Apply page filters and render page tree
125 
126         :param request: The current request
127         :type request: ~django.http.HttpResponse
128 
129         :param \*args: The supplied arguments
130         :type \*args: list
131 
132         :param \**kwargs: The supplied keyword arguments
133         :type \**kwargs: dict
134 
135         :return: The rendered template response
136         :rtype: ~django.template.response.TemplateResponse
137         """
138         return self.get(request, *args, **kwargs, filter_data=request.POST)
139 
140     @staticmethod
141     def filter_pages(pages, language_slug, filter_form):
142         """
143         Filter the pages list according to the given filter data
144 
145         :param pages: The list of pages
146         :type pages: list
147 
148         :param language_slug: The slug of the current language
149         :type language_slug: str
150 
151         :param filter_form: The filter form
152         :type filter_form: integreat_cms.cms.forms.pages.page_filter_form.PageFilterForm
153 
154         :return: The filtered page list
155         :rtype: list
156         """
157         if filter_form.is_valid():
158             query = filter_form.cleaned_data["query"]
159             if query:
160                 # Buffer variable because the pages list should not be modified during iteration
161                 filtered_pages = []
162                 for page in pages:
163                     translation = page.get_translation(language_slug)
164                     if translation and (
165                         query.lower() in translation.slug
166                         or query.lower() in translation.title.lower()
167                     ):
168                         filtered_pages.append(page)
169                 pages = filtered_pages
170 
171             selected_status = filter_form.cleaned_data["translation_status"]
172             # Only filter if at least one checkbox but not all are checked
173             if 0 < len(selected_status) < len(translation_status.CHOICES):
174                 # Buffer variable because the pages list should not be modified during iteration
175                 filtered_pages = []
176                 for page in pages:
177                     translation_state = page.translation_states.get(language_slug)
178                     if translation_state and translation_state[1] in selected_status:
179                         filtered_pages.append(page)
180                 pages = filtered_pages
181         return pages
182
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/integreat_cms/cms/views/pages/page_tree_view.py b/integreat_cms/cms/views/pages/page_tree_view.py
--- a/integreat_cms/cms/views/pages/page_tree_view.py
+++ b/integreat_cms/cms/views/pages/page_tree_view.py
@@ -107,7 +107,7 @@
             filter_form = PageFilterForm()
             filter_form.changed_data.clear()
 
-        return render(
+        response = render(
             request,
             self.template_name,
             {
@@ -118,6 +118,9 @@
                 "filter_form": filter_form,
             },
         )
+        # Disable browser cache of page tree to prevent subpages from being expanded after using "back"-button
+        response["Cache-Control"] = "no-store, must-revalidate"
+        return response
 
     def post(self, request, *args, **kwargs):
         r"""

{"golden_diff": "diff --git a/integreat_cms/cms/views/pages/page_tree_view.py b/integreat_cms/cms/views/pages/page_tree_view.py\n--- a/integreat_cms/cms/views/pages/page_tree_view.py\n+++ b/integreat_cms/cms/views/pages/page_tree_view.py\n@@ -107,7 +107,7 @@\n             filter_form = PageFilterForm()\n             filter_form.changed_data.clear()\n \n-        return render(\n+        response = render(\n             request,\n             self.template_name,\n             {\n@@ -118,6 +118,9 @@\n                 \"filter_form\": filter_form,\n             },\n         )\n+        # Disable browser cache of page tree to prevent subpages from being expanded after using \"back\"-button\n+        response[\"Cache-Control\"] = \"no-store, must-revalidate\"\n+        return response\n \n     def post(self, request, *args, **kwargs):\n         r\"\"\"\n", "issue": "Page tree broken after searching and going back\n### Describe the Bug\r\nWhen using the back button of the browser after searching, the page tree is expanded. After that, the collapsing function is broken.\r\n\r\nCan we tell the browser to reload the full page after using the back button? However, it would be the best solution to actually keep the status of the tree after using the back button.\r\n\r\n~~This could be related to #1131~~\n", "before_files": [{"content": "import logging\n\nfrom django.contrib import messages\nfrom django.shortcuts import render, redirect\nfrom django.utils.decorators import method_decorator\nfrom django.utils.translation import ugettext as _\nfrom django.views.generic import TemplateView\n\nfrom ...constants import translation_status\nfrom ...decorators import permission_required\nfrom ...forms import PageFilterForm\nfrom ...models import Language\nfrom .page_context_mixin import PageContextMixin\n\nlogger = logging.getLogger(__name__)\n\n\n@method_decorator(permission_required(\"cms.view_page\"), name=\"dispatch\")\nclass PageTreeView(TemplateView, PageContextMixin):\n    \"\"\"\n    View for showing the page tree\n    \"\"\"\n\n    #: Template for list of non-archived pages\n    template = \"pages/page_tree.html\"\n    #: Template for list of archived pages\n    template_archived = \"pages/page_tree_archived.html\"\n    #: Whether or not to show archived pages\n    archived = False\n\n    @property\n    def template_name(self):\n        \"\"\"\n        Select correct HTML template, depending on :attr:`~integreat_cms.cms.views.pages.page_tree_view.PageTreeView.archived` flag\n        (see :class:`~django.views.generic.base.TemplateResponseMixin`)\n\n        :return: Path to HTML template\n        :rtype: str\n        \"\"\"\n\n        return self.template_archived if self.archived else self.template\n\n    def get(self, request, *args, **kwargs):\n        r\"\"\"\n        Render page tree\n\n        :param request: The current request\n        :type request: ~django.http.HttpResponse\n\n        :param \\*args: The supplied arguments\n        :type \\*args: list\n\n        :param \\**kwargs: The supplied keyword arguments\n        :type \\**kwargs: dict\n\n        :return: The rendered template response\n        :rtype: ~django.template.response.TemplateResponse\n        \"\"\"\n\n        # current region\n        region_slug = kwargs.get(\"region_slug\")\n        region = request.region\n\n        # current language\n        language_slug = kwargs.get(\"language_slug\")\n        if language_slug:\n            language = Language.objects.get(slug=language_slug)\n        elif region.default_language:\n            return redirect(\n                \"pages\",\n                **{\n                    \"region_slug\": region_slug,\n                    \"language_slug\": region.default_language.slug,\n                }\n            )\n        else:\n            messages.error(\n                request,\n                _(\"Please create at least one language node before creating pages.\"),\n            )\n            return redirect(\n                \"language_tree\",\n                **{\n                    \"region_slug\": region_slug,\n                }\n            )\n\n        if not request.user.has_perm(\"cms.change_page\"):\n            messages.warning(\n                request, _(\"You don't have the permission to edit or create pages.\")\n            )\n\n        # Filter pages according to given filters, if any\n        filter_data = kwargs.get(\"filter_data\")\n\n        if filter_data or self.archived:\n            page_queryset = region.pages.all()\n        else:\n            page_queryset = region.pages.filter(lft=1)\n        pages = page_queryset.cache_tree(archived=self.archived)[0]\n\n        if filter_data:\n            # Set data for filter form rendering\n            filter_form = PageFilterForm(data=filter_data)\n            pages = self.filter_pages(pages, language_slug, filter_form)\n        else:\n            filter_form = PageFilterForm()\n            filter_form.changed_data.clear()\n\n        return render(\n            request,\n            self.template_name,\n            {\n                **self.get_context_data(**kwargs),\n                \"pages\": pages,\n                \"language\": language,\n                \"languages\": region.active_languages,\n                \"filter_form\": filter_form,\n            },\n        )\n\n    def post(self, request, *args, **kwargs):\n        r\"\"\"\n        Apply page filters and render page tree\n\n        :param request: The current request\n        :type request: ~django.http.HttpResponse\n\n        :param \\*args: The supplied arguments\n        :type \\*args: list\n\n        :param \\**kwargs: The supplied keyword arguments\n        :type \\**kwargs: dict\n\n        :return: The rendered template response\n        :rtype: ~django.template.response.TemplateResponse\n        \"\"\"\n        return self.get(request, *args, **kwargs, filter_data=request.POST)\n\n    @staticmethod\n    def filter_pages(pages, language_slug, filter_form):\n        \"\"\"\n        Filter the pages list according to the given filter data\n\n        :param pages: The list of pages\n        :type pages: list\n\n        :param language_slug: The slug of the current language\n        :type language_slug: str\n\n        :param filter_form: The filter form\n        :type filter_form: integreat_cms.cms.forms.pages.page_filter_form.PageFilterForm\n\n        :return: The filtered page list\n        :rtype: list\n        \"\"\"\n        if filter_form.is_valid():\n            query = filter_form.cleaned_data[\"query\"]\n            if query:\n                # Buffer variable because the pages list should not be modified during iteration\n                filtered_pages = []\n                for page in pages:\n                    translation = page.get_translation(language_slug)\n                    if translation and (\n                        query.lower() in translation.slug\n                        or query.lower() in translation.title.lower()\n                    ):\n                        filtered_pages.append(page)\n                pages = filtered_pages\n\n            selected_status = filter_form.cleaned_data[\"translation_status\"]\n            # Only filter if at least one checkbox but not all are checked\n            if 0 < len(selected_status) < len(translation_status.CHOICES):\n                # Buffer variable because the pages list should not be modified during iteration\n                filtered_pages = []\n                for page in pages:\n                    translation_state = page.translation_states.get(language_slug)\n                    if translation_state and translation_state[1] in selected_status:\n                        filtered_pages.append(page)\n                pages = filtered_pages\n        return pages\n", "path": "integreat_cms/cms/views/pages/page_tree_view.py"}], "after_files": [{"content": "import logging\n\nfrom django.contrib import messages\nfrom django.shortcuts import render, redirect\nfrom django.utils.decorators import method_decorator\nfrom django.utils.translation import ugettext as _\nfrom django.views.generic import TemplateView\n\nfrom ...constants import translation_status\nfrom ...decorators import permission_required\nfrom ...forms import PageFilterForm\nfrom ...models import Language\nfrom .page_context_mixin import PageContextMixin\n\nlogger = logging.getLogger(__name__)\n\n\n@method_decorator(permission_required(\"cms.view_page\"), name=\"dispatch\")\nclass PageTreeView(TemplateView, PageContextMixin):\n    \"\"\"\n    View for showing the page tree\n    \"\"\"\n\n    #: Template for list of non-archived pages\n    template = \"pages/page_tree.html\"\n    #: Template for list of archived pages\n    template_archived = \"pages/page_tree_archived.html\"\n    #: Whether or not to show archived pages\n    archived = False\n\n    @property\n    def template_name(self):\n        \"\"\"\n        Select correct HTML template, depending on :attr:`~integreat_cms.cms.views.pages.page_tree_view.PageTreeView.archived` flag\n        (see :class:`~django.views.generic.base.TemplateResponseMixin`)\n\n        :return: Path to HTML template\n        :rtype: str\n        \"\"\"\n\n        return self.template_archived if self.archived else self.template\n\n    def get(self, request, *args, **kwargs):\n        r\"\"\"\n        Render page tree\n\n        :param request: The current request\n        :type request: ~django.http.HttpResponse\n\n        :param \\*args: The supplied arguments\n        :type \\*args: list\n\n        :param \\**kwargs: The supplied keyword arguments\n        :type \\**kwargs: dict\n\n        :return: The rendered template response\n        :rtype: ~django.template.response.TemplateResponse\n        \"\"\"\n\n        # current region\n        region_slug = kwargs.get(\"region_slug\")\n        region = request.region\n\n        # current language\n        language_slug = kwargs.get(\"language_slug\")\n        if language_slug:\n            language = Language.objects.get(slug=language_slug)\n        elif region.default_language:\n            return redirect(\n                \"pages\",\n                **{\n                    \"region_slug\": region_slug,\n                    \"language_slug\": region.default_language.slug,\n                }\n            )\n        else:\n            messages.error(\n                request,\n                _(\"Please create at least one language node before creating pages.\"),\n            )\n            return redirect(\n                \"language_tree\",\n                **{\n                    \"region_slug\": region_slug,\n                }\n            )\n\n        if not request.user.has_perm(\"cms.change_page\"):\n            messages.warning(\n                request, _(\"You don't have the permission to edit or create pages.\")\n            )\n\n        # Filter pages according to given filters, if any\n        filter_data = kwargs.get(\"filter_data\")\n\n        if filter_data or self.archived:\n            page_queryset = region.pages.all()\n        else:\n            page_queryset = region.pages.filter(lft=1)\n        pages = page_queryset.cache_tree(archived=self.archived)[0]\n\n        if filter_data:\n            # Set data for filter form rendering\n            filter_form = PageFilterForm(data=filter_data)\n            pages = self.filter_pages(pages, language_slug, filter_form)\n        else:\n            filter_form = PageFilterForm()\n            filter_form.changed_data.clear()\n\n        response = render(\n            request,\n            self.template_name,\n            {\n                **self.get_context_data(**kwargs),\n                \"pages\": pages,\n                \"language\": language,\n                \"languages\": region.active_languages,\n                \"filter_form\": filter_form,\n            },\n        )\n        # Disable browser cache of page tree to prevent subpages from being expanded after using \"back\"-button\n        response[\"Cache-Control\"] = \"no-store, must-revalidate\"\n        return response\n\n    def post(self, request, *args, **kwargs):\n        r\"\"\"\n        Apply page filters and render page tree\n\n        :param request: The current request\n        :type request: ~django.http.HttpResponse\n\n        :param \\*args: The supplied arguments\n        :type \\*args: list\n\n        :param \\**kwargs: The supplied keyword arguments\n        :type \\**kwargs: dict\n\n        :return: The rendered template response\n        :rtype: ~django.template.response.TemplateResponse\n        \"\"\"\n        return self.get(request, *args, **kwargs, filter_data=request.POST)\n\n    @staticmethod\n    def filter_pages(pages, language_slug, filter_form):\n        \"\"\"\n        Filter the pages list according to the given filter data\n\n        :param pages: The list of pages\n        :type pages: list\n\n        :param language_slug: The slug of the current language\n        :type language_slug: str\n\n        :param filter_form: The filter form\n        :type filter_form: integreat_cms.cms.forms.pages.page_filter_form.PageFilterForm\n\n        :return: The filtered page list\n        :rtype: list\n        \"\"\"\n        if filter_form.is_valid():\n            query = filter_form.cleaned_data[\"query\"]\n            if query:\n                # Buffer variable because the pages list should not be modified during iteration\n                filtered_pages = []\n                for page in pages:\n                    translation = page.get_translation(language_slug)\n                    if translation and (\n                        query.lower() in translation.slug\n                        or query.lower() in translation.title.lower()\n                    ):\n                        filtered_pages.append(page)\n                pages = filtered_pages\n\n            selected_status = filter_form.cleaned_data[\"translation_status\"]\n            # Only filter if at least one checkbox but not all are checked\n            if 0 < len(selected_status) < len(translation_status.CHOICES):\n                # Buffer variable because the pages list should not be modified during iteration\n                filtered_pages = []\n                for page in pages:\n                    translation_state = page.translation_states.get(language_slug)\n                    if translation_state and translation_state[1] in selected_status:\n                        filtered_pages.append(page)\n                pages = filtered_pages\n        return pages\n", "path": "integreat_cms/cms/views/pages/page_tree_view.py"}]}