google-code-export / django-page-cms

Automatically exported from code.google.com/p/django-page-cms
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

"View on site" link doesn't show the language #149

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. During page editing in the admin section

In "View on site" I expect to see the link like /en/main/ but I have a link
/None/main/. The same with french version of the page.

I use 1.0.6
settings:
PAGE_LANGUAGES = (
    ('fr', gettext_noop('French')),
    ('en', gettext_noop('English')),
)
PAGE_USE_LANGUAGE_PREFIX = True

Original issue reported on code.google.com by pakhomov...@yandex.ru on 17 Aug 2009 at 7:08

GoogleCodeExporter commented 9 years ago
I think you don't have set PAGE_DEFAULT_LANGUAGE in your settings because I 
can't
reproduce this bug.

Original comment by batiste....@gmail.com on 17 Aug 2009 at 7:44

GoogleCodeExporter commented 9 years ago
well, I had:
LANGUAGE_CODE = 'en' in project.settings.

ok, I added PAGE_DEFAULT_LANGUAGE, but nothing has changed.

Now I have:
LANGUAGE_CODE = 'en'

gettext_noop = lambda s: s

PAGE_LANGUAGES = (
    ('fr', gettext_noop('French')),
    ('en', gettext_noop('English')),
)
PAGE_USE_LANGUAGE_PREFIX = True

PAGE_TINYMCE = True
PAGE_PERMISSION = False
PAGE_DEFAULT_LANGUAGE = 'en'

Original comment by pakhomov...@yandex.ru on 18 Aug 2009 at 6:26

GoogleCodeExporter commented 9 years ago
Can you try to update to the last revision. With the last revision it's now 
working fine.

Original comment by batiste....@gmail.com on 19 Aug 2009 at 11:31

GoogleCodeExporter commented 9 years ago
I updated to revision 649 but still with no luck.
And have links like: http://127.0.0.1:8000/None/home/test/
I doubt may be I'm installing it in a wrong way? I just copy "pages" folder from
checkout source to my project.

Original comment by pakhomov...@yandex.ru on 20 Aug 2009 at 8:27

GoogleCodeExporter commented 9 years ago
I can't understand you bug... The code that set the lang variable in
pages/admin/__init__/list_pages is the following:

{{{
def get_language_from_request(request):
    """Return the most obvious language according the request."""
    language = request.GET.get('language', None)
    if language:
        return language

    if hasattr(request, 'LANGUAGE_CODE'):
        return settings.PAGE_LANGUAGE_MAPPING(str(request.LANGUAGE_CODE))
    else:
        return settings.PAGE_DEFAULT_LANGUAGE
}}}

It don't make sense that you get a None... PAGE_LANGUAGE_MAPPING is set to that 
if
undefined:

PAGE_LANGUAGE_MAPPING = getattr(settings, 'PAGE_LANGUAGE_MAPPING', lambda l: l)

Can you investigate into get_language_from_request to know what is happenning?

Original comment by batiste....@gmail.com on 25 Aug 2009 at 7:08

GoogleCodeExporter commented 9 years ago
This bug isn't in pages list but in page edit page - /admin/pages/page/1/

Original comment by pakhomov...@yandex.ru on 25 Aug 2009 at 7:44

GoogleCodeExporter commented 9 years ago
in page list it's ok - link looks like /en/home/test/

Original comment by pakhomov...@yandex.ru on 25 Aug 2009 at 7:45

GoogleCodeExporter commented 9 years ago
Oki, should be fixed with revision 660. Can you check?

Original comment by batiste....@gmail.com on 25 Aug 2009 at 8:11

GoogleCodeExporter commented 9 years ago
sorry but it isn't fixed with revision 660. 

in models.py if I add print statement:

 def get_absolute_url(self, language=None):
        """Return the absolute page url. Add the language prefix if
        ``PAGE_USE_LANGUAGE_PREFIX`` setting is set to **True***."""
        print language
        url = reverse('pages-root')
        if settings.PAGE_USE_LANGUAGE_PREFIX:
            url += str(language) + '/'
        return url + self.get_url(language)

it prints: None

Should we pass the language to this function?

Original comment by pakhomov...@yandex.ru on 25 Aug 2009 at 10:43

GoogleCodeExporter commented 9 years ago
Woups, sorry. I haven't really tested. What about now?

Original comment by batiste....@gmail.com on 25 Aug 2009 at 11:17

GoogleCodeExporter commented 9 years ago
now it works perfectly. Thank you!

Original comment by pakhomov...@yandex.ru on 25 Aug 2009 at 11:37

GoogleCodeExporter commented 9 years ago

Original comment by batiste....@gmail.com on 25 Aug 2009 at 1:05