We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Rename points of interest
### Motivation
<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->
The term "points of interest" (POIs) is not recognized as locations on the map.

### Proposed Solution
<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->
Change the wording, e.g.
- English: "Locations on map"
- German: "Orte auf Karte"
Rename points of interest
### Motivation
<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->
The term "points of interest" (POIs) is not recognized as locations on the map.

### Proposed Solution
<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->
Change the wording, e.g.
- English: "Locations on map"
- German: "Orte auf Karte"

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/cms/views/pois/poi_view.py`
Content:
```
1 """
2 A view representing an instance of a point of interest. POIs can be created or updated via this view.
3 """
4 import logging
5 
6 from django.contrib import messages
7 from django.contrib.auth.decorators import login_required
8 from django.contrib.auth.mixins import PermissionRequiredMixin
9 from django.shortcuts import render, redirect
10 from django.utils.decorators import method_decorator
11 from django.utils.translation import ugettext as _
12 from django.views.generic import TemplateView
13 
14 from ...constants import status
15 from ...decorators import region_permission_required
16 from ...forms.pois import POIForm, POITranslationForm
17 from ...models import POI, POITranslation, Region, Language
18 
19 logger = logging.getLogger(__name__)
20 
21 
22 @method_decorator(login_required, name="dispatch")
23 @method_decorator(region_permission_required, name="dispatch")
24 class POIView(PermissionRequiredMixin, TemplateView):
25     permission_required = "cms.manage_pois"
26     raise_exception = True
27 
28     template_name = "pois/poi_form.html"
29     base_context = {"current_menu_item": "pois"}
30 
31     def get(self, request, *args, **kwargs):
32 
33         region = Region.get_current_region(request)
34         language = Language.objects.get(code=kwargs.get("language_code"))
35 
36         # get poi and translation objects if they exist
37         poi = POI.objects.filter(id=kwargs.get("poi_id")).first()
38         poi_translation = POITranslation.objects.filter(
39             poi=poi,
40             language=language,
41         ).first()
42 
43         if poi and poi.archived:
44             messages.warning(
45                 request, _("You cannot edit this POI because it is archived.")
46             )
47 
48         poi_form = POIForm(instance=poi)
49         poi_translation_form = POITranslationForm(instance=poi_translation)
50 
51         return render(
52             request,
53             self.template_name,
54             {
55                 **self.base_context,
56                 "poi_form": poi_form,
57                 "poi_translation_form": poi_translation_form,
58                 "language": language,
59                 # Languages for tab view
60                 "languages": region.languages if poi else [language],
61             },
62         )
63 
64     # pylint: disable=too-many-branches,too-many-locals,unused-argument
65     def post(self, request, *args, **kwargs):
66 
67         region = Region.get_current_region(request)
68         language = Language.objects.get(code=kwargs.get("language_code"))
69 
70         poi_instance = POI.objects.filter(id=kwargs.get("poi_id")).first()
71         poi_translation_instance = POITranslation.objects.filter(
72             poi=poi_instance,
73             language=language,
74         ).first()
75 
76         if poi_instance and poi_instance.archived:
77             return redirect(
78                 "edit_poi",
79                 **{
80                     "poi_id": poi_instance.id,
81                     "region_slug": region.slug,
82                     "language_code": language.code,
83                 }
84             )
85 
86         poi_form = POIForm(
87             request.POST,
88             instance=poi_instance,
89         )
90         poi_translation_form = POITranslationForm(
91             request.POST,
92             instance=poi_translation_instance,
93             region=region,
94             language=language,
95         )
96 
97         if not poi_form.is_valid() or not poi_translation_form.is_valid():
98 
99             # Add error messages
100             for form in [poi_form, poi_translation_form]:
101                 for field in form:
102                     for error in field.errors:
103                         messages.error(request, _(field.label) + ": " + _(error))
104                 for error in form.non_field_errors():
105                     messages.error(request, _(error))
106 
107         elif not poi_form.has_changed() and not poi_translation_form.has_changed():
108 
109             messages.info(request, _("No changes detected."))
110 
111         else:
112 
113             poi = poi_form.save(region=region)
114             poi_translation_form.save(poi=poi, user=request.user)
115 
116             published = poi_translation_form.instance.status == status.PUBLIC
117             if not poi_instance:
118                 if published:
119                     messages.success(
120                         request, _("POI was successfully created and published.")
121                     )
122                 else:
123                     messages.success(request, _("POI was successfully created."))
124                 return redirect(
125                     "edit_poi",
126                     **{
127                         "poi_id": poi.id,
128                         "region_slug": region.slug,
129                         "language_code": language.code,
130                     }
131                 )
132             if published:
133                 messages.success(request, _("POI was successfully published."))
134             else:
135                 messages.success(request, _("POI was successfully saved."))
136 
137         return render(
138             request,
139             self.template_name,
140             {
141                 **self.base_context,
142                 "poi_form": poi_form,
143                 "poi_translation_form": poi_translation_form,
144                 "language": language,
145                 # Languages for tab view
146                 "languages": region.languages if poi_instance else [language],
147             },
148         )
149
```

Path: `src/cms/views/pois/poi_list_view.py`
Content:
```
1 from django.contrib import messages
2 from django.contrib.auth.decorators import login_required
3 from django.contrib.auth.mixins import PermissionRequiredMixin
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 ...decorators import region_permission_required
10 from ...models import Region, Language
11 
12 
13 @method_decorator(login_required, name="dispatch")
14 @method_decorator(region_permission_required, name="dispatch")
15 class POIListView(PermissionRequiredMixin, TemplateView):
16     permission_required = "cms.manage_pois"
17     raise_exception = True
18 
19     template = "pois/poi_list.html"
20     template_archived = "pois/poi_list_archived.html"
21     archived = False
22 
23     @property
24     def template_name(self):
25         return self.template_archived if self.archived else self.template
26 
27     def get(self, request, *args, **kwargs):
28         # current region
29         region_slug = kwargs.get("region_slug")
30         region = Region.get_current_region(request)
31 
32         # current language
33         language_code = kwargs.get("language_code")
34         if language_code:
35             language = Language.objects.get(code=language_code)
36         elif region.default_language:
37             return redirect(
38                 "pois",
39                 **{
40                     "region_slug": region_slug,
41                     "language_code": region.default_language.code,
42                 }
43             )
44         else:
45             messages.error(
46                 request,
47                 _("Please create at least one language node before creating POIs."),
48             )
49             return redirect(
50                 "language_tree",
51                 **{
52                     "region_slug": region_slug,
53                 }
54             )
55 
56         if language != region.default_language:
57             messages.warning(
58                 request,
59                 _("You can only create POIs in the default language (%(language)s).")
60                 % {"language": region.default_language.translated_name},
61             )
62 
63         return render(
64             request,
65             self.template_name,
66             {
67                 "current_menu_item": "pois",
68                 "pois": region.pois.filter(archived=self.archived),
69                 "archived_count": region.pois.filter(archived=True).count(),
70                 "language": language,
71                 "languages": region.languages,
72             },
73         )
74
```

Path: `src/cms/views/pois/poi_actions.py`
Content:
```
1 """
2 A view representing an instance of a point of interest. POIs can be added, changed or retrieved via this view.
3 """
4 import logging
5 
6 from django.contrib import messages
7 from django.contrib.auth.decorators import login_required, permission_required
8 from django.http import Http404
9 from django.shortcuts import render, redirect
10 from django.utils.translation import ugettext as _
11 
12 from ...decorators import region_permission_required, staff_required
13 from ...models import POI
14 
15 logger = logging.getLogger(__name__)
16 
17 
18 @login_required
19 @region_permission_required
20 @permission_required("cms.manage_pois", raise_exception=True)
21 def archive_poi(request, poi_id, region_slug, language_code):
22     poi = POI.objects.get(id=poi_id)
23 
24     poi.archived = True
25     poi.save()
26 
27     messages.success(request, _("POI was successfully archived."))
28 
29     return redirect(
30         "pois",
31         **{
32             "region_slug": region_slug,
33             "language_code": language_code,
34         }
35     )
36 
37 
38 @login_required
39 @region_permission_required
40 @permission_required("cms.manage_pois", raise_exception=True)
41 def restore_poi(request, poi_id, region_slug, language_code):
42     poi = POI.objects.get(id=poi_id)
43 
44     poi.archived = False
45     poi.save()
46 
47     messages.success(request, _("POI was successfully restored."))
48 
49     return redirect(
50         "pois",
51         **{
52             "region_slug": region_slug,
53             "language_code": language_code,
54         }
55     )
56 
57 
58 @login_required
59 @staff_required
60 def delete_poi(request, poi_id, region_slug, language_code):
61 
62     poi = POI.objects.get(id=poi_id)
63     poi.delete()
64     messages.success(request, _("POI was successfully deleted."))
65 
66     return redirect(
67         "pois",
68         **{
69             "region_slug": region_slug,
70             "language_code": language_code,
71         }
72     )
73 
74 
75 @login_required
76 @region_permission_required
77 @permission_required("cms.manage_pois", raise_exception=True)
78 # pylint: disable=unused-argument
79 def view_poi(request, poi_id, region_slug, language_code):
80     template_name = "pois/poi_view.html"
81     poi = POI.objects.get(id=poi_id)
82 
83     poi_translation = poi.get_translation(language_code)
84 
85     if not poi_translation:
86         raise Http404
87 
88     return render(request, template_name, {"poi_translation": poi_translation})
89
```
--- 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/src/cms/views/pois/poi_actions.py b/src/cms/views/pois/poi_actions.py
--- a/src/cms/views/pois/poi_actions.py
+++ b/src/cms/views/pois/poi_actions.py
@@ -24,7 +24,7 @@
     poi.archived = True
     poi.save()
 
-    messages.success(request, _("POI was successfully archived."))
+    messages.success(request, _("Location was successfully archived."))
 
     return redirect(
         "pois",
@@ -44,7 +44,7 @@
     poi.archived = False
     poi.save()
 
-    messages.success(request, _("POI was successfully restored."))
+    messages.success(request, _("Location was successfully restored."))
 
     return redirect(
         "pois",
@@ -61,7 +61,7 @@
 
     poi = POI.objects.get(id=poi_id)
     poi.delete()
-    messages.success(request, _("POI was successfully deleted."))
+    messages.success(request, _("Location was successfully deleted."))
 
     return redirect(
         "pois",
diff --git a/src/cms/views/pois/poi_list_view.py b/src/cms/views/pois/poi_list_view.py
--- a/src/cms/views/pois/poi_list_view.py
+++ b/src/cms/views/pois/poi_list_view.py
@@ -44,7 +44,9 @@
         else:
             messages.error(
                 request,
-                _("Please create at least one language node before creating POIs."),
+                _(
+                    "Please create at least one language node before creating locations."
+                ),
             )
             return redirect(
                 "language_tree",
@@ -56,7 +58,9 @@
         if language != region.default_language:
             messages.warning(
                 request,
-                _("You can only create POIs in the default language (%(language)s).")
+                _(
+                    "You can only create locations in the default language (%(language)s)."
+                )
                 % {"language": region.default_language.translated_name},
             )
 
diff --git a/src/cms/views/pois/poi_view.py b/src/cms/views/pois/poi_view.py
--- a/src/cms/views/pois/poi_view.py
+++ b/src/cms/views/pois/poi_view.py
@@ -42,7 +42,7 @@
 
         if poi and poi.archived:
             messages.warning(
-                request, _("You cannot edit this POI because it is archived.")
+                request, _("You cannot edit this location because it is archived.")
             )
 
         poi_form = POIForm(instance=poi)
@@ -117,10 +117,10 @@
             if not poi_instance:
                 if published:
                     messages.success(
-                        request, _("POI was successfully created and published.")
+                        request, _("Location was successfully created and published.")
                     )
                 else:
-                    messages.success(request, _("POI was successfully created."))
+                    messages.success(request, _("Location was successfully created."))
                 return redirect(
                     "edit_poi",
                     **{
@@ -130,9 +130,9 @@
                     }
                 )
             if published:
-                messages.success(request, _("POI was successfully published."))
+                messages.success(request, _("Location was successfully published."))
             else:
-                messages.success(request, _("POI was successfully saved."))
+                messages.success(request, _("Location was successfully saved."))
 
         return render(
             request,

{"golden_diff": "diff --git a/src/cms/views/pois/poi_actions.py b/src/cms/views/pois/poi_actions.py\n--- a/src/cms/views/pois/poi_actions.py\n+++ b/src/cms/views/pois/poi_actions.py\n@@ -24,7 +24,7 @@\n     poi.archived = True\n     poi.save()\n \n-    messages.success(request, _(\"POI was successfully archived.\"))\n+    messages.success(request, _(\"Location was successfully archived.\"))\n \n     return redirect(\n         \"pois\",\n@@ -44,7 +44,7 @@\n     poi.archived = False\n     poi.save()\n \n-    messages.success(request, _(\"POI was successfully restored.\"))\n+    messages.success(request, _(\"Location was successfully restored.\"))\n \n     return redirect(\n         \"pois\",\n@@ -61,7 +61,7 @@\n \n     poi = POI.objects.get(id=poi_id)\n     poi.delete()\n-    messages.success(request, _(\"POI was successfully deleted.\"))\n+    messages.success(request, _(\"Location was successfully deleted.\"))\n \n     return redirect(\n         \"pois\",\ndiff --git a/src/cms/views/pois/poi_list_view.py b/src/cms/views/pois/poi_list_view.py\n--- a/src/cms/views/pois/poi_list_view.py\n+++ b/src/cms/views/pois/poi_list_view.py\n@@ -44,7 +44,9 @@\n         else:\n             messages.error(\n                 request,\n-                _(\"Please create at least one language node before creating POIs.\"),\n+                _(\n+                    \"Please create at least one language node before creating locations.\"\n+                ),\n             )\n             return redirect(\n                 \"language_tree\",\n@@ -56,7 +58,9 @@\n         if language != region.default_language:\n             messages.warning(\n                 request,\n-                _(\"You can only create POIs in the default language (%(language)s).\")\n+                _(\n+                    \"You can only create locations in the default language (%(language)s).\"\n+                )\n                 % {\"language\": region.default_language.translated_name},\n             )\n \ndiff --git a/src/cms/views/pois/poi_view.py b/src/cms/views/pois/poi_view.py\n--- a/src/cms/views/pois/poi_view.py\n+++ b/src/cms/views/pois/poi_view.py\n@@ -42,7 +42,7 @@\n \n         if poi and poi.archived:\n             messages.warning(\n-                request, _(\"You cannot edit this POI because it is archived.\")\n+                request, _(\"You cannot edit this location because it is archived.\")\n             )\n \n         poi_form = POIForm(instance=poi)\n@@ -117,10 +117,10 @@\n             if not poi_instance:\n                 if published:\n                     messages.success(\n-                        request, _(\"POI was successfully created and published.\")\n+                        request, _(\"Location was successfully created and published.\")\n                     )\n                 else:\n-                    messages.success(request, _(\"POI was successfully created.\"))\n+                    messages.success(request, _(\"Location was successfully created.\"))\n                 return redirect(\n                     \"edit_poi\",\n                     **{\n@@ -130,9 +130,9 @@\n                     }\n                 )\n             if published:\n-                messages.success(request, _(\"POI was successfully published.\"))\n+                messages.success(request, _(\"Location was successfully published.\"))\n             else:\n-                messages.success(request, _(\"POI was successfully saved.\"))\n+                messages.success(request, _(\"Location was successfully saved.\"))\n \n         return render(\n             request,\n", "issue": "Rename points of interest\n### Motivation\r\n<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->\r\nThe term \"points of interest\" (POIs) is not recognized as locations on the map.\r\n\r\n### Proposed Solution\r\n<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->\r\nChange the wording, e.g.\r\n- English: \"Locations on map\"\r\n- German: \"Orte auf Karte\"\nRename points of interest\n### Motivation\r\n<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->\r\nThe term \"points of interest\" (POIs) is not recognized as locations on the map.\r\n\r\n### Proposed Solution\r\n<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->\r\nChange the wording, e.g.\r\n- English: \"Locations on map\"\r\n- German: \"Orte auf Karte\"\n", "before_files": [{"content": "\"\"\"\nA view representing an instance of a point of interest. POIs can be created or updated via this view.\n\"\"\"\nimport logging\n\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.contrib.auth.mixins import PermissionRequiredMixin\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 status\nfrom ...decorators import region_permission_required\nfrom ...forms.pois import POIForm, POITranslationForm\nfrom ...models import POI, POITranslation, Region, Language\n\nlogger = logging.getLogger(__name__)\n\n\n@method_decorator(login_required, name=\"dispatch\")\n@method_decorator(region_permission_required, name=\"dispatch\")\nclass POIView(PermissionRequiredMixin, TemplateView):\n    permission_required = \"cms.manage_pois\"\n    raise_exception = True\n\n    template_name = \"pois/poi_form.html\"\n    base_context = {\"current_menu_item\": \"pois\"}\n\n    def get(self, request, *args, **kwargs):\n\n        region = Region.get_current_region(request)\n        language = Language.objects.get(code=kwargs.get(\"language_code\"))\n\n        # get poi and translation objects if they exist\n        poi = POI.objects.filter(id=kwargs.get(\"poi_id\")).first()\n        poi_translation = POITranslation.objects.filter(\n            poi=poi,\n            language=language,\n        ).first()\n\n        if poi and poi.archived:\n            messages.warning(\n                request, _(\"You cannot edit this POI because it is archived.\")\n            )\n\n        poi_form = POIForm(instance=poi)\n        poi_translation_form = POITranslationForm(instance=poi_translation)\n\n        return render(\n            request,\n            self.template_name,\n            {\n                **self.base_context,\n                \"poi_form\": poi_form,\n                \"poi_translation_form\": poi_translation_form,\n                \"language\": language,\n                # Languages for tab view\n                \"languages\": region.languages if poi else [language],\n            },\n        )\n\n    # pylint: disable=too-many-branches,too-many-locals,unused-argument\n    def post(self, request, *args, **kwargs):\n\n        region = Region.get_current_region(request)\n        language = Language.objects.get(code=kwargs.get(\"language_code\"))\n\n        poi_instance = POI.objects.filter(id=kwargs.get(\"poi_id\")).first()\n        poi_translation_instance = POITranslation.objects.filter(\n            poi=poi_instance,\n            language=language,\n        ).first()\n\n        if poi_instance and poi_instance.archived:\n            return redirect(\n                \"edit_poi\",\n                **{\n                    \"poi_id\": poi_instance.id,\n                    \"region_slug\": region.slug,\n                    \"language_code\": language.code,\n                }\n            )\n\n        poi_form = POIForm(\n            request.POST,\n            instance=poi_instance,\n        )\n        poi_translation_form = POITranslationForm(\n            request.POST,\n            instance=poi_translation_instance,\n            region=region,\n            language=language,\n        )\n\n        if not poi_form.is_valid() or not poi_translation_form.is_valid():\n\n            # Add error messages\n            for form in [poi_form, poi_translation_form]:\n                for field in form:\n                    for error in field.errors:\n                        messages.error(request, _(field.label) + \": \" + _(error))\n                for error in form.non_field_errors():\n                    messages.error(request, _(error))\n\n        elif not poi_form.has_changed() and not poi_translation_form.has_changed():\n\n            messages.info(request, _(\"No changes detected.\"))\n\n        else:\n\n            poi = poi_form.save(region=region)\n            poi_translation_form.save(poi=poi, user=request.user)\n\n            published = poi_translation_form.instance.status == status.PUBLIC\n            if not poi_instance:\n                if published:\n                    messages.success(\n                        request, _(\"POI was successfully created and published.\")\n                    )\n                else:\n                    messages.success(request, _(\"POI was successfully created.\"))\n                return redirect(\n                    \"edit_poi\",\n                    **{\n                        \"poi_id\": poi.id,\n                        \"region_slug\": region.slug,\n                        \"language_code\": language.code,\n                    }\n                )\n            if published:\n                messages.success(request, _(\"POI was successfully published.\"))\n            else:\n                messages.success(request, _(\"POI was successfully saved.\"))\n\n        return render(\n            request,\n            self.template_name,\n            {\n                **self.base_context,\n                \"poi_form\": poi_form,\n                \"poi_translation_form\": poi_translation_form,\n                \"language\": language,\n                # Languages for tab view\n                \"languages\": region.languages if poi_instance else [language],\n            },\n        )\n", "path": "src/cms/views/pois/poi_view.py"}, {"content": "from django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.contrib.auth.mixins import PermissionRequiredMixin\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 ...decorators import region_permission_required\nfrom ...models import Region, Language\n\n\n@method_decorator(login_required, name=\"dispatch\")\n@method_decorator(region_permission_required, name=\"dispatch\")\nclass POIListView(PermissionRequiredMixin, TemplateView):\n    permission_required = \"cms.manage_pois\"\n    raise_exception = True\n\n    template = \"pois/poi_list.html\"\n    template_archived = \"pois/poi_list_archived.html\"\n    archived = False\n\n    @property\n    def template_name(self):\n        return self.template_archived if self.archived else self.template\n\n    def get(self, request, *args, **kwargs):\n        # current region\n        region_slug = kwargs.get(\"region_slug\")\n        region = Region.get_current_region(request)\n\n        # current language\n        language_code = kwargs.get(\"language_code\")\n        if language_code:\n            language = Language.objects.get(code=language_code)\n        elif region.default_language:\n            return redirect(\n                \"pois\",\n                **{\n                    \"region_slug\": region_slug,\n                    \"language_code\": region.default_language.code,\n                }\n            )\n        else:\n            messages.error(\n                request,\n                _(\"Please create at least one language node before creating POIs.\"),\n            )\n            return redirect(\n                \"language_tree\",\n                **{\n                    \"region_slug\": region_slug,\n                }\n            )\n\n        if language != region.default_language:\n            messages.warning(\n                request,\n                _(\"You can only create POIs in the default language (%(language)s).\")\n                % {\"language\": region.default_language.translated_name},\n            )\n\n        return render(\n            request,\n            self.template_name,\n            {\n                \"current_menu_item\": \"pois\",\n                \"pois\": region.pois.filter(archived=self.archived),\n                \"archived_count\": region.pois.filter(archived=True).count(),\n                \"language\": language,\n                \"languages\": region.languages,\n            },\n        )\n", "path": "src/cms/views/pois/poi_list_view.py"}, {"content": "\"\"\"\nA view representing an instance of a point of interest. POIs can be added, changed or retrieved via this view.\n\"\"\"\nimport logging\n\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required, permission_required\nfrom django.http import Http404\nfrom django.shortcuts import render, redirect\nfrom django.utils.translation import ugettext as _\n\nfrom ...decorators import region_permission_required, staff_required\nfrom ...models import POI\n\nlogger = logging.getLogger(__name__)\n\n\n@login_required\n@region_permission_required\n@permission_required(\"cms.manage_pois\", raise_exception=True)\ndef archive_poi(request, poi_id, region_slug, language_code):\n    poi = POI.objects.get(id=poi_id)\n\n    poi.archived = True\n    poi.save()\n\n    messages.success(request, _(\"POI was successfully archived.\"))\n\n    return redirect(\n        \"pois\",\n        **{\n            \"region_slug\": region_slug,\n            \"language_code\": language_code,\n        }\n    )\n\n\n@login_required\n@region_permission_required\n@permission_required(\"cms.manage_pois\", raise_exception=True)\ndef restore_poi(request, poi_id, region_slug, language_code):\n    poi = POI.objects.get(id=poi_id)\n\n    poi.archived = False\n    poi.save()\n\n    messages.success(request, _(\"POI was successfully restored.\"))\n\n    return redirect(\n        \"pois\",\n        **{\n            \"region_slug\": region_slug,\n            \"language_code\": language_code,\n        }\n    )\n\n\n@login_required\n@staff_required\ndef delete_poi(request, poi_id, region_slug, language_code):\n\n    poi = POI.objects.get(id=poi_id)\n    poi.delete()\n    messages.success(request, _(\"POI was successfully deleted.\"))\n\n    return redirect(\n        \"pois\",\n        **{\n            \"region_slug\": region_slug,\n            \"language_code\": language_code,\n        }\n    )\n\n\n@login_required\n@region_permission_required\n@permission_required(\"cms.manage_pois\", raise_exception=True)\n# pylint: disable=unused-argument\ndef view_poi(request, poi_id, region_slug, language_code):\n    template_name = \"pois/poi_view.html\"\n    poi = POI.objects.get(id=poi_id)\n\n    poi_translation = poi.get_translation(language_code)\n\n    if not poi_translation:\n        raise Http404\n\n    return render(request, template_name, {\"poi_translation\": poi_translation})\n", "path": "src/cms/views/pois/poi_actions.py"}], "after_files": [{"content": "\"\"\"\nA view representing an instance of a point of interest. POIs can be created or updated via this view.\n\"\"\"\nimport logging\n\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.contrib.auth.mixins import PermissionRequiredMixin\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 status\nfrom ...decorators import region_permission_required\nfrom ...forms.pois import POIForm, POITranslationForm\nfrom ...models import POI, POITranslation, Region, Language\n\nlogger = logging.getLogger(__name__)\n\n\n@method_decorator(login_required, name=\"dispatch\")\n@method_decorator(region_permission_required, name=\"dispatch\")\nclass POIView(PermissionRequiredMixin, TemplateView):\n    permission_required = \"cms.manage_pois\"\n    raise_exception = True\n\n    template_name = \"pois/poi_form.html\"\n    base_context = {\"current_menu_item\": \"pois\"}\n\n    def get(self, request, *args, **kwargs):\n\n        region = Region.get_current_region(request)\n        language = Language.objects.get(code=kwargs.get(\"language_code\"))\n\n        # get poi and translation objects if they exist\n        poi = POI.objects.filter(id=kwargs.get(\"poi_id\")).first()\n        poi_translation = POITranslation.objects.filter(\n            poi=poi,\n            language=language,\n        ).first()\n\n        if poi and poi.archived:\n            messages.warning(\n                request, _(\"You cannot edit this location because it is archived.\")\n            )\n\n        poi_form = POIForm(instance=poi)\n        poi_translation_form = POITranslationForm(instance=poi_translation)\n\n        return render(\n            request,\n            self.template_name,\n            {\n                **self.base_context,\n                \"poi_form\": poi_form,\n                \"poi_translation_form\": poi_translation_form,\n                \"language\": language,\n                # Languages for tab view\n                \"languages\": region.languages if poi else [language],\n            },\n        )\n\n    # pylint: disable=too-many-branches,too-many-locals,unused-argument\n    def post(self, request, *args, **kwargs):\n\n        region = Region.get_current_region(request)\n        language = Language.objects.get(code=kwargs.get(\"language_code\"))\n\n        poi_instance = POI.objects.filter(id=kwargs.get(\"poi_id\")).first()\n        poi_translation_instance = POITranslation.objects.filter(\n            poi=poi_instance,\n            language=language,\n        ).first()\n\n        if poi_instance and poi_instance.archived:\n            return redirect(\n                \"edit_poi\",\n                **{\n                    \"poi_id\": poi_instance.id,\n                    \"region_slug\": region.slug,\n                    \"language_code\": language.code,\n                }\n            )\n\n        poi_form = POIForm(\n            request.POST,\n            instance=poi_instance,\n        )\n        poi_translation_form = POITranslationForm(\n            request.POST,\n            instance=poi_translation_instance,\n            region=region,\n            language=language,\n        )\n\n        if not poi_form.is_valid() or not poi_translation_form.is_valid():\n\n            # Add error messages\n            for form in [poi_form, poi_translation_form]:\n                for field in form:\n                    for error in field.errors:\n                        messages.error(request, _(field.label) + \": \" + _(error))\n                for error in form.non_field_errors():\n                    messages.error(request, _(error))\n\n        elif not poi_form.has_changed() and not poi_translation_form.has_changed():\n\n            messages.info(request, _(\"No changes detected.\"))\n\n        else:\n\n            poi = poi_form.save(region=region)\n            poi_translation_form.save(poi=poi, user=request.user)\n\n            published = poi_translation_form.instance.status == status.PUBLIC\n            if not poi_instance:\n                if published:\n                    messages.success(\n                        request, _(\"Location was successfully created and published.\")\n                    )\n                else:\n                    messages.success(request, _(\"Location was successfully created.\"))\n                return redirect(\n                    \"edit_poi\",\n                    **{\n                        \"poi_id\": poi.id,\n                        \"region_slug\": region.slug,\n                        \"language_code\": language.code,\n                    }\n                )\n            if published:\n                messages.success(request, _(\"Location was successfully published.\"))\n            else:\n                messages.success(request, _(\"Location was successfully saved.\"))\n\n        return render(\n            request,\n            self.template_name,\n            {\n                **self.base_context,\n                \"poi_form\": poi_form,\n                \"poi_translation_form\": poi_translation_form,\n                \"language\": language,\n                # Languages for tab view\n                \"languages\": region.languages if poi_instance else [language],\n            },\n        )\n", "path": "src/cms/views/pois/poi_view.py"}, {"content": "from django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.contrib.auth.mixins import PermissionRequiredMixin\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 ...decorators import region_permission_required\nfrom ...models import Region, Language\n\n\n@method_decorator(login_required, name=\"dispatch\")\n@method_decorator(region_permission_required, name=\"dispatch\")\nclass POIListView(PermissionRequiredMixin, TemplateView):\n    permission_required = \"cms.manage_pois\"\n    raise_exception = True\n\n    template = \"pois/poi_list.html\"\n    template_archived = \"pois/poi_list_archived.html\"\n    archived = False\n\n    @property\n    def template_name(self):\n        return self.template_archived if self.archived else self.template\n\n    def get(self, request, *args, **kwargs):\n        # current region\n        region_slug = kwargs.get(\"region_slug\")\n        region = Region.get_current_region(request)\n\n        # current language\n        language_code = kwargs.get(\"language_code\")\n        if language_code:\n            language = Language.objects.get(code=language_code)\n        elif region.default_language:\n            return redirect(\n                \"pois\",\n                **{\n                    \"region_slug\": region_slug,\n                    \"language_code\": region.default_language.code,\n                }\n            )\n        else:\n            messages.error(\n                request,\n                _(\n                    \"Please create at least one language node before creating locations.\"\n                ),\n            )\n            return redirect(\n                \"language_tree\",\n                **{\n                    \"region_slug\": region_slug,\n                }\n            )\n\n        if language != region.default_language:\n            messages.warning(\n                request,\n                _(\n                    \"You can only create locations in the default language (%(language)s).\"\n                )\n                % {\"language\": region.default_language.translated_name},\n            )\n\n        return render(\n            request,\n            self.template_name,\n            {\n                \"current_menu_item\": \"pois\",\n                \"pois\": region.pois.filter(archived=self.archived),\n                \"archived_count\": region.pois.filter(archived=True).count(),\n                \"language\": language,\n                \"languages\": region.languages,\n            },\n        )\n", "path": "src/cms/views/pois/poi_list_view.py"}, {"content": "\"\"\"\nA view representing an instance of a point of interest. POIs can be added, changed or retrieved via this view.\n\"\"\"\nimport logging\n\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required, permission_required\nfrom django.http import Http404\nfrom django.shortcuts import render, redirect\nfrom django.utils.translation import ugettext as _\n\nfrom ...decorators import region_permission_required, staff_required\nfrom ...models import POI\n\nlogger = logging.getLogger(__name__)\n\n\n@login_required\n@region_permission_required\n@permission_required(\"cms.manage_pois\", raise_exception=True)\ndef archive_poi(request, poi_id, region_slug, language_code):\n    poi = POI.objects.get(id=poi_id)\n\n    poi.archived = True\n    poi.save()\n\n    messages.success(request, _(\"Location was successfully archived.\"))\n\n    return redirect(\n        \"pois\",\n        **{\n            \"region_slug\": region_slug,\n            \"language_code\": language_code,\n        }\n    )\n\n\n@login_required\n@region_permission_required\n@permission_required(\"cms.manage_pois\", raise_exception=True)\ndef restore_poi(request, poi_id, region_slug, language_code):\n    poi = POI.objects.get(id=poi_id)\n\n    poi.archived = False\n    poi.save()\n\n    messages.success(request, _(\"Location was successfully restored.\"))\n\n    return redirect(\n        \"pois\",\n        **{\n            \"region_slug\": region_slug,\n            \"language_code\": language_code,\n        }\n    )\n\n\n@login_required\n@staff_required\ndef delete_poi(request, poi_id, region_slug, language_code):\n\n    poi = POI.objects.get(id=poi_id)\n    poi.delete()\n    messages.success(request, _(\"Location was successfully deleted.\"))\n\n    return redirect(\n        \"pois\",\n        **{\n            \"region_slug\": region_slug,\n            \"language_code\": language_code,\n        }\n    )\n\n\n@login_required\n@region_permission_required\n@permission_required(\"cms.manage_pois\", raise_exception=True)\n# pylint: disable=unused-argument\ndef view_poi(request, poi_id, region_slug, language_code):\n    template_name = \"pois/poi_view.html\"\n    poi = POI.objects.get(id=poi_id)\n\n    poi_translation = poi.get_translation(language_code)\n\n    if not poi_translation:\n        raise Http404\n\n    return render(request, template_name, {\"poi_translation\": poi_translation})\n", "path": "src/cms/views/pois/poi_actions.py"}]}