Browse Source

made js catalogue view configurable

Rafał Pitoń 8 years ago
parent
commit
8708be003f
4 changed files with 18 additions and 6 deletions
  1. 6 0
      docs/settings/Core.md
  2. 8 0
      misago/conf/defaults.py
  3. 1 3
      misago/core/tests/test_views.py
  4. 3 3
      misago/core/views.py

+ 6 - 0
docs/settings/Core.md

@@ -123,6 +123,12 @@ In case of more events than specified being found, oldest events will be truncat
 Hourly limit of posts that may be posted from single account. Fail-safe for situations when forum is flooded by spam bot. Change to 0 to lift this restriction.
 Hourly limit of posts that may be posted from single account. Fail-safe for situations when forum is flooded by spam bot. Change to 0 to lift this restriction.
 
 
 
 
+## `MISAGO_JS_CATALOG_PACKAGES`
+
+List of packages that should be included in Misago's default JS I18n catalog, available under the `/django-i18n.js` url. Defaults to `['misago']`. See [Django documentation](https://docs.djangoproject.com/en/1.10/topics/i18n/translation/#internationalization-in-javascript-code) for further explanation.
+
+
+
 ## `MISAGO_LOGIN_API_URL`
 ## `MISAGO_LOGIN_API_URL`
 URL to API endpoint used to authenticate sign-in credentials. Musn't contain api prefix or wrapping slashes. Defaults to 'auth/login'.
 URL to API endpoint used to authenticate sign-in credentials. Musn't contain api prefix or wrapping slashes. Defaults to 'auth/login'.
 
 

+ 8 - 0
misago/conf/defaults.py

@@ -244,6 +244,14 @@ MISAGO_USERS_PER_PAGE = 12
 MISAGO_READTRACKER_CUTOFF = 40
 MISAGO_READTRACKER_CUTOFF = 40
 
 
 
 
+# List of packages that should be included in Misago's default JS I18n catalog
+# https://docs.djangoproject.com/en/1.10/topics/i18n/translation/#internationalization-in-javascript-code
+
+MISAGO_JS_CATALOG_PACKAGES = [
+    'misago',
+]
+
+
 # Available Moment.js locales
 # Available Moment.js locales
 
 
 MISAGO_MOMENT_JS_LOCALES = [
 MISAGO_MOMENT_JS_LOCALES = [

+ 1 - 3
misago/core/tests/test_views.py

@@ -2,14 +2,12 @@ from django.test import TestCase, override_settings
 from django.urls import reverse
 from django.urls import reverse
 
 
 
 
-class PreloadJSDataViewTests(TestCase):
+class CoreViewsTests(TestCase):
     def test_js_catalog_view_returns_200(self):
     def test_js_catalog_view_returns_200(self):
         """js catalog view has no show-stoppers"""
         """js catalog view has no show-stoppers"""
         response = self.client.get('/django-i18n.js')
         response = self.client.get('/django-i18n.js')
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
-
-class RobotsTxtViewTests(TestCase):
     def test_robots_txt_returns_200(self):
     def test_robots_txt_returns_200(self):
         """robots.txt has no showstoppers"""
         """robots.txt has no showstoppers"""
         response = self.client.get('/robots.txt')
         response = self.client.get('/robots.txt')

+ 3 - 3
misago/core/views.py

@@ -4,6 +4,8 @@ from django.views import i18n
 from django.views.decorators.cache import cache_page
 from django.views.decorators.cache import cache_page
 from django.views.decorators.http import last_modified
 from django.views.decorators.http import last_modified
 
 
+from misago.conf import settings
+
 
 
 def forum_index(request):
 def forum_index(request):
     return  # blow up as this view is normally non-reachable!
     return  # blow up as this view is normally non-reachable!
@@ -20,8 +22,6 @@ def javascript_catalog(request):
         request,
         request,
         'djangojs',
         'djangojs',
         {
         {
-            'packages': [
-                'misago',
-            ],
+            'packages': settings.MISAGO_JS_CATALOG_PACKAGES,
         },
         },
     )
     )