Skip to content

Commit

Permalink
Merge pull request #2835 from digitalfabrik/bugfix/dashboard-no-defau…
Browse files Browse the repository at this point in the history
…lt-language

Fix error in the region dashboard if no default language exists
  • Loading branch information
timobrembeck authored Jun 8, 2024
2 parents 6349da5 + 31d2423 commit 8f4c7d4
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
49 changes: 49 additions & 0 deletions integreat_cms/cms/fixtures/test_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,55 @@
"offers": []
}
},
{
"model": "cms.region",
"pk": 7,
"fields": {
"name": "Region without language",
"common_id": "",
"slug": "empty-region",
"status": "ARCHIVED",
"administrative_division": "RURAL_DISTRICT",
"aliases": {},
"custom_prefix": "",
"events_enabled": true,
"locations_enabled": true,
"push_notifications_enabled": true,
"latitude": 1.0,
"longitude": 1.0,
"longitude_min": 1.0,
"latitude_min": 1.0,
"longitude_max": 2.0,
"latitude_max": 2.0,
"postal_code": "00000",
"admin_mail": "[email protected]",
"timezone": "Europe/Berlin",
"created_date": "2024-06-08T13:05:49.864Z",
"last_updated": "2024-06-08T13:06:00.798Z",
"statistics_enabled": false,
"seo_enabled": false,
"matomo_id": null,
"matomo_token": "",
"page_permissions_enabled": false,
"icon": null,
"chat_enabled": true,
"administrative_division_included": false,
"short_urls_enabled": false,
"external_news_enabled": false,
"fallback_translations_enabled": true,
"hix_enabled": false,
"summ_ai_enabled": false,
"mt_renewal_month": 0,
"mt_addon_booked": false,
"mt_midyear_start_month": null,
"mt_budget_used": 0,
"machine_translate_pages": 1,
"machine_translate_events": 1,
"machine_translate_pois": 1,
"zammad_url": "",
"offers": []
}
},
{
"model": "cms.directory",
"pk": 1,
Expand Down
3 changes: 3 additions & 0 deletions integreat_cms/cms/views/dashboard/dashboard_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ def get_drafted_pages(
:return: Dictionary containing the context for drafted pages for one region.
"""
if not self.request.region.default_language:
return {}

drafted_pages = PageTranslation.objects.filter(
id__in=self.latest_version_ids,
status=status.DRAFT,
Expand Down
2 changes: 2 additions & 0 deletions integreat_cms/release_notes/current/unreleased/2834.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en: Fix error in the region dashboard if no default language exists
de: Behebe Fehler im Region-Dashboard, wenn keine Standard-Sprache existiert
50 changes: 50 additions & 0 deletions tests/cms/views/view_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,25 @@
# The kwargs for these views
{"region_slug": "nurnberg"},
),
(
[
("dashboard", STAFF_ROLES),
("languagetreenodes", STAFF_ROLES),
("media", STAFF_ROLES),
("mediacenter_directory_path", STAFF_ROLES),
("mediacenter_get_directory_content", STAFF_ROLES),
("new_region_user", STAFF_ROLES),
("region_feedback", STAFF_ROLES),
("region_users", STAFF_ROLES),
("organizations", STAFF_ROLES),
("new_organization", STAFF_ROLES),
("translation_coverage", STAFF_ROLES),
("user_settings", STAFF_ROLES),
("authenticate_modify_mfa", STAFF_ROLES),
],
# The kwargs for these views
{"region_slug": "empty-region"},
),
(
[
("sitemap:region_language", ALL_ROLES),
Expand Down Expand Up @@ -1730,6 +1749,37 @@
# The kwargs for these views
{"region_slug": "augsburg"},
),
(
[
(
"pages",
STAFF_ROLES,
reverse("languagetreenodes", kwargs={"region_slug": "empty-region"}),
),
(
"events",
STAFF_ROLES,
reverse("languagetreenodes", kwargs={"region_slug": "empty-region"}),
),
(
"pois",
STAFF_ROLES,
reverse("languagetreenodes", kwargs={"region_slug": "empty-region"}),
),
(
"push_notifications",
STAFF_ROLES,
reverse("languagetreenodes", kwargs={"region_slug": "empty-region"}),
),
(
"edit_imprint",
STAFF_ROLES,
reverse("languagetreenodes", kwargs={"region_slug": "empty-region"}),
),
],
# The kwargs for these views
{"region_slug": "empty-region"},
),
(
[
(
Expand Down

0 comments on commit 8f4c7d4

Please sign in to comment.