File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 6
6
7
7
from cms .models import Title
8
8
from cms .utils import get_current_site
9
+ from cms .utils .i18n import get_public_languages
9
10
10
11
11
12
def from_iterable (iterables ):
@@ -45,10 +46,13 @@ def items(self):
45
46
# If, for some reason, you require redirecting pages (Titles) to be
46
47
# included, simply create a new class inheriting from this one, and
47
48
# supply a new items() method which doesn't filter out the redirects.
49
+ site = get_current_site ()
50
+ languages = get_public_languages (site_id = site .pk )
48
51
all_titles = Title .objects .public ().filter (
49
52
Q (redirect = '' ) | Q (redirect__isnull = True ),
53
+ language__in = languages ,
50
54
page__login_required = False ,
51
- page__node__site = get_current_site () ,
55
+ page__node__site = site ,
52
56
).order_by ('page__node__path' )
53
57
return all_titles
54
58
Original file line number Diff line number Diff line change 1
1
# -*- coding: utf-8 -*-
2
+ import copy
3
+
4
+ from cms .api import create_page , create_title
2
5
from cms .models import Title , Page
3
6
from cms .sitemaps import CMSSitemap
4
7
from cms .test_utils .testcases import CMSTestCase
5
- from cms .api import create_page , create_title
8
+ from cms .utils . conf import get_cms_setting
6
9
7
10
8
11
class SitemapTestCase (CMSTestCase ):
@@ -144,3 +147,21 @@ def test_sitemap_unpublished_titles(self):
144
147
else :
145
148
url = 'http://example.com/%s/%s' % (title .language , title .path )
146
149
self .assertFalse (url in locations )
150
+
151
+ def test_sitemap_uses_public_languages_only (self ):
152
+ """
153
+ Pages on the sitemap should only show public languages.
154
+ """
155
+ lang_settings = copy .deepcopy (get_cms_setting ('LANGUAGES' ))
156
+ # sanity check
157
+ assert lang_settings [1 ][1 ]['code' ] == 'de'
158
+ # set german as private
159
+ lang_settings [1 ][1 ]['public' ] = False
160
+
161
+ with self .settings (CMS_LANGUAGES = lang_settings ):
162
+ for item in CMSSitemap ().get_urls ():
163
+ url = 'http://example.com/en/'
164
+
165
+ if item ['item' ].path :
166
+ url += item ['item' ].path + '/'
167
+ self .assertEqual (item ['location' ], url )
You can’t perform that action at this time.
0 commit comments