Pages on SITE_ID=2 give 404 Error if not logged in #1881

Closed
RacingTadpole opened this Issue May 25, 2013 · 16 comments

Projects

None yet

4 participants

@RacingTadpole

I just created a vanilla site with Django-CMS 2.4.1 and Django 1.5.1. I put two sites in, SITE_IDs 1 and 2, and then added pages to each using the admin panel, and published them.

Site 1 works fine.

The problem is that some of site 2's pages give 404 errors if you are not logged in. (The ok pages seem to be the home page, and pages with app-hooks.)

Has anyone else had this problem? (I also posted this at stackoverflow here: http://stackoverflow.com/questions/16745802/django-cms-2-4-pages-with-site-id-2-only-found-if-youre-logged-in).

thank you!

@yakky yakky added a commit to yakky/django-cms that referenced this issue May 27, 2013
@yakky yakky Added tentative test for bug #1881 1ecc414
@yakky

Could you have a look a this test : yakky@1ecc414 ?
It currently passes and apparently it checks the error conditions you described

@RacingTadpole

Yes, that does look like it's the situation I describe - when I try that on my site, a similar test fails.

I appreciate your looking into it!

Can you point me to what other settings you are using in that test? I'd like to compare them against mine to help me find the issue. Thanks!

@digi604
Divio AG member

you can find the settings in cms/test_utils/cli.py but beware that 2 are overwritten in the test.

@czpython
Divio AG member

I was able to reproduce this in CMS 3.x

@yakky

Maybe linked to #1885 ?

@RacingTadpole

I just realised I missed your setUp method when I tested it on my site, and I see that you have self.login_user_context(u) in there. I actually only found the problem if you were not logged in.

When I run your setUp and test methods on my site (just changing the template name and language), it passes there too. But if I add the line self._login_context.__exit__(None, None, None) to test_site_publish before getting the page URL, I get AssertionError: 404 != 200. Is that a sensible test?

Thanks!

@yakky yakky referenced this issue May 29, 2013
Merged

Test for #1881 #1891

@yakky

Actually the test fails for the wrong reason :)
I fixed the test

@RacingTadpole

Thanks!

I tried putting your newly changed test (https://github.com/yakky/django-cms/blob/feature/test_1881/cms/tests/site.py) into my own code, and I have a question.

How should I adapt the line lang_settings[3][1]['public'] = True for a single language in my settings? Using either 0 or 1 instead of 3 gave an IndexError.

Without this line, the test fails for me.

@digi604
Divio AG member

try: lang_settings[1][0]['public'] = True

@digi604
Divio AG member

do you have USE_I18N = True or False?

@RacingTadpole

Interesting. With lang_settings[1][0]['public'] = True it fails for me.

I have pretty standard settings, I think. The language-y ones are:

LANGUAGE_CODE = 'en'
USE_TZ = True
USE_I18N = True
USE_L10N = True
CMS_LANGUAGES = {
    1: [
        {
            'code': 'en',
            'name': gettext('English'),
            'public': True,
            },
        ],
    'default': {
        'fallbacks': ['en',],
        'public': False,
        }
}
LANGUAGES = [
    ('en', 'English'),
]
@RacingTadpole

Hi, in an effort to pinpoint the problem, I have created as simple a test case as I can which demonstrates it:

There is no problem when I do this: I can see both pages of both sites whether logged in or not.

However, when I add the CMS_LANGUAGES setting described at http://docs.django-cms.org/en/2.4.0/getting_started/configuration.html, I see the problem: I can only see page 2 of site 2 if I am logged in.

I then changed LANGUAGE_CODE to 'en' (the tutorial uses 'en-us'), but this does not help.

I have uploaded this project to github at: https://github.com/RacingTadpole/djangocms-test . This also includes your test (slightly modified for English only) in sampletests. The URL of page 2 on site 2 is /test.

This project includes the data as a fixture - I typed:
python manage.py dumpdata sites cms text --indent 2 > sampletests/fixtures/cms.json
so you can quickly set up the database with python manage.py loaddata cms.

Sorry it took me so long to get a simple demonstration to you - I really appreciate your effort so far!

@yakky

You don't have a CMS_LANGUAGES entry for site 2, so default takes effect, and in the snippet above, default has public=False which hides the language for the website 2.
Maybe we should change that line in the tutorial to defaults to True?

@RacingTadpole

Ah! Thank you! That's great to know. I must admit I used that CMS_LANGUAGES setting without trying to understand it... I didn't realise the "1" key was a SITE_ID, though it is clearly stated in the docs now that I look. Can I suggest including an explanation of the "public" setting in the docs too?

@yakky

Is there, actually: http://django-cms.readthedocs.org/en/2.4.0/getting_started/configuration.html#public
But I guess that public=False in code is misleading.
@digi604: is False for a reason? Could we change that value to True?

@yakky

Fixed in #1944

@yakky yakky closed this Jun 24, 2013
@yakky yakky added a commit to yakky/django-cms that referenced this issue Aug 17, 2013
@yakky yakky Added tentative test for bug #1881 57a5deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment