Giter Club home page Giter Club logo

django-page-cms's Introduction

django-page-cms

image

Code Climate

Scrutinizer Code Quality

This Django CMS enables you to create and administrate hierarchical pages in a simple and powerful way.

For a quick demo.

$ pip3 install "django-page-cms[full]"; gerbi --create mywebsite

Or with docker

docker compose up fast
# or if you want to build it yourself
docker compose up web

To create a super user account

docker compose run fast python example/manage.py createsuperuser

To create a demo website

docker compose run fast python example/manage.py pages_demo

To run tests with docker

docker compose run run-test

More informations

Django page CMS is based around a placeholders concept. Placeholder is a special template tag that you use in your page templates. Every time you add a placeholder in your template such field dynamically appears in the page admin interface.

Each page can have a different template with different placeholders.

image

Those placeholder can also be edited inline

image

django-page-cms's People

Contributors

a-iv avatar aaloy avatar batiste avatar beniwohli avatar ddc67cd avatar dependabot[bot] avatar dvd0101 avatar elky avatar facconi avatar gautier avatar greut avatar homebrew79 avatar jacquesbeaurain avatar jezdez avatar macropin avatar matinfo avatar mireq avatar nicksergeant avatar paolodina avatar poxip avatar puffin avatar remik avatar siemiatj avatar sjl avatar smorstabilini avatar summerisgone avatar theunraveler avatar thomw avatar toban avatar wardi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-page-cms's Issues

get_content does not resolves language as variable

class GetContentNode(template.Node):
"""Get content node"""
def init(self, page, content_type, varname, lang):
self.page = page
self.content_type = content_type
self.varname = varname
self.lang = lang

def render(self, context):
    context[self.varname] = _get_content(
        context,
        self.page.resolve(context),
        self.content_type.resolve(context),
        self.lang
    )
    return ''

change to

class GetContentNode(template.Node):
"""Get content node"""
def init(self, page, content_type, varname, lang):
self.page = page
self.content_type = content_type
self.varname = varname
self.lang = lang

def render(self, context):
    context[self.varname] = _get_content(
        context,
        self.page.resolve(context),
        self.content_type.resolve(context),
        self.lang.resolve(context)
    )
    return ''

Problem with Timezone-aware datetimes

Hypothesis

There seems to be a problem with timezone-aware datetimes in django 1.4. I realize the readme doesn't list django 1.4 as a supported version yet, so I guess you can think of this as an early warning or something to tackle on the way to 1.4-compatibility

Evidence

Setup

  • Django 1.4
  • USE_TZ = True (so django uses timezone-aware datetimes)
  • django-page-cms==1.4.5

Symptoms

I created and saved a page just fine with a 'published' state. When trying to go back and change the state to draft, a 500 error is returned with the following relevant stacktrace:

File "/Users/jannon/VEs/TG/lib/python2.7/site-packages/pages/admin/views.py" in change_status
23.         page.save()
File "/Users/jannon/VEs/TG/lib/python2.7/site-packages/pages/models.py" in save
136.                         self.publication_date <= datetime.now()):

Exception Type: TypeError at /admin/pages/page/2/change-status/
Exception Value: can't compare offset-naive and offset-aware datetimes

And sure enough, editing the pages models.py to read:

from django.utils import timezone
self.publication_date <= datetime.utcnow().replace(tzinfo=timezone.utc)):

causes everything to work just fine

Conclusion

So, I guess django-page-cms should check for the USE_TZ setting and modify its datetime operations accordingly
If that seems like a reasonable approach, I might find some time to work on it and submit a pull request...

Setup from pypi broken

Hello Batiste!

We are migrating to buildout+pypi distribution for our projects. So, in page-cms's dependencies you declared django-mptt>0.2.1. But last version in pypi is 0.2.1. Running buildout gives an error:

Getting distribution for 'django-mptt>0.2.1'.
While:
Installing django.
Getting distribution for 'django-mptt>0.2.1'.
Error: Couldn't find a distribution for 'django-mptt>0.2.1'.

Could you solve this dependency, please? Is it so necessary to use trunk version of mptt?
Thank you for attention.

DOCUMENTATION CLARIFICATION: Where should I place my custom placeholder file?

I have placed my custom placeholder files in multiple places in the path of my app but my template tags are still not working.

I followed the documentation here:
http://pythonhosted.org/django-page-cms/placeholders.html#create-your-own-placeholder

Do I place the tag in the main installation path for the pages app?

For my installation that would be here:
/usr/local/lib/python2.7/dist-packages/pages/mycustomplaceholders.py

Or do I place it in my app path (tried this but it did not work):
/home/me/mydjangocms/someapp/mycustomplaceholders.py

NameError: global name 'Http404' is not defined

When attempting to use the sample cool template the following trace stack happens ad infinitum:

[Sat Apr 07 00:44:22 2012] [error] ERROR Internal Server Error: /admin/pages/page/2/template/images/portfolio/ventilationchamber_thumb.jpg/
[Sat Apr 07 00:44:22 2012] [error] Traceback (most recent call last):
[Sat Apr 07 00:44:22 2012] [error] File "/srv/www/django/webdesign.danols.com/virtualenv/src/django/django/core/handlers/base.py", line 111, in get_response
[Sat Apr 07 00:44:22 2012] [error] response = callback(request, _callback_args, *_callback_kwargs)
[Sat Apr 07 00:44:22 2012] [error] File "/srv/www/django/webdesign.danols.com/virtualenv/src/django/django/contrib/admin/options.py", line 368, in wrapper
[Sat Apr 07 00:44:22 2012] [error] return self.admin_site.admin_view(view)(_args, *_kwargs)
[Sat Apr 07 00:44:22 2012] [error] File "/srv/www/django/webdesign.danols.com/virtualenv/src/django/django/utils/decorators.py", line 91, in _wrapped_view
[Sat Apr 07 00:44:22 2012] [error] response = view_func(request, _args, *_kwargs)
[Sat Apr 07 00:44:22 2012] [error] File "/srv/www/django/webdesign.danols.com/virtualenv/src/django/django/views/decorators/cache.py", line 88, in _wrapped_view_func
[Sat Apr 07 00:44:22 2012] [error] response = view_func(request, _args, *_kwargs)
[Sat Apr 07 00:44:22 2012] [error] File "/srv/www/django/webdesign.danols.com/virtualenv/src/django/django/contrib/admin/sites.py", line 192, in inner
[Sat Apr 07 00:44:22 2012] [error] return view(request, _args, *_kwargs)
[Sat Apr 07 00:44:22 2012] [error] File "/srv/www/django/webdesign.danols.com/virtualenv/lib/python2.6/site-packages/pages/admin/init.py", line 263, in change_view
[Sat Apr 07 00:44:22 2012] [error] raise Http404('The "%s" part of the location is invalid.'
[Sat Apr 07 00:44:22 2012] [error] NameError: global name 'Http404' is not defined

Locales not included with installation from pypi

Whether installing with pip, or downloading and running python setup.py install (checked in a virtualenv), the locales directory is missing from the installation.

Could be cause pages/locale is missing from MANIFEST.in

STATIC_URL is not set

Using the latest development version of django and django-page-cms, After the commit 6d3c8da

the STATIC_URL of the templates is not wroking.

It works with commit 547466c so the last commit introduced this bug.

compatibility with Grappelli

Could you please make django-page-cms to be more compatible with grappelli? Take a look at the pages changelist with grappelli... It doesn't look very nice :/. I think the popularity of grappelli is raising so it would be a nice feature.

Fails on makemessages: unterminated strings

./manage.py makemessages -a

processing language jp
Error: errors happened while running xgettext on forms.py
./pages/admin/forms.py:15: warning: unterminated string
./pages/admin/forms.py:16: warning: unterminated string
./pages/admin/forms.py:17: warning: unterminated string
./pages/admin/forms.py:18: warning: unterminated string
./pages/admin/forms.py:20: warning: unterminated string
./pages/admin/forms.py:21: warning: unterminated string
./pages/admin/forms.py:33: warning: unterminated string
./pages/admin/forms.py:34: warning: unterminated string
./pages/admin/forms.py:32: internationalized messages should not contain the \r' escape sequence ./pages/admin/forms.py:19: internationalized messages should not contain the\r' escape sequence
./pages/admin/forms.py:16: internationalized messages should not contain the \r' escape sequence ./pages/admin/forms.py:14: internationalized messages should not contain the\r' escape sequence

Template tag get_page does not properly handle its page argument.

Here is something I would like to be able to do in a template:

{% placeholder right as rightmenu with TextInput %}

[and later on]

{% get_page rightmenu as some_page %}

{% pages_submenu some_page %}

So far:

{% get_page variable_id ... %}

fails because variable_id is interpreted as a literal string, not a variable.

{% get_page "my_page_slug" ... %}

fails because quotes surrounding the string argument are not stripped. Thus a page with the slug '"my_page_slug"', not 'my_page_slug' is looked for. This is what your last commit fixes (5eb6fe3)

But {% get_page 9999 ... %} where 9999 is a page ID, works fine.

Tried to fix this by myself and I think what you did in you last commit is not completely right. Each case: "string", variable_id, 9999 must be handled seperatly in the do_get_page() function.

For example I managed to fixed the same issue as you, just by stripping the quotes as suggested in django manual. What I don't understant is why you use FilterExpression objects instead of Variable ones, which as far as I understand, are intended for that purpose. I tried to use Variable instance for the page argument in do_get_page() in the case where that argument is neither a quoted string or a int. Yet I did not manage to get the resolve() method on my Variabnle instance to actually resolve the variable. As a matter of fact something goes wrong in the PlaceholderNode instanciation: the call to get_content_from_context(context) at the first line of the render method returns nothing. Here follows the code:

def do_get_page(parser, token):
    """Retrieve a page and insert into the template's context.

    Example::

        {% get_page "news" as news_page %}

    :param page: the page object, slug or id
    :param name: name of the context variable to store the page in
    """
    bits = token.split_contents()
    if 4 != len(bits):
         raise TemplateSyntaxError('%r expects 4 arguments' % bits[0])
    if bits[-2] != 'as':
        raise TemplateSyntaxError(
            '%r expects "as" as the second argument' % bits[0])
    if bits[1][0] == bits[1][-1] and bits[1][0] in ("'", '"'):
        page = bits[1][1:-1]
    elif bits[1].isdigit():
        page = bits[1]
    else:
        page = template.Variable(bits[1])

    varname = bits[-1]
    return GetPageNode(page, varname)
do_get_page = register.tag('get_page', do_get_page)

Which also requires to add support for variables in get_page_from_string_or_id():

def get_page_from_string_or_id(page_string, context, lang=None):
    """Return a Page object from a slug or an id."""
    if type(page_string) == int:
        return Page.objects.get(pk=int(page_string))
    # if we have a string coming from some templates templates
    elif ( isinstance(page_string, SafeUnicode) or
           isinstance(page_string, unicode) ):
        if page_string.isdigit():
            return Page.objects.get(pk=int(page_string))
        else:
             return Page.objects.from_path(page_string, lang)
    elif isinstance(page_string, template.Variable):
        return page_string.resolve(context) ## This fails
    else:
        # in any other case we return the input becasue it's probably
        # a Page object.
        return page_string

Still digging...

Also wanted to add the following test cases (in test_unit.py), but I cannot manage to run them ! How should I proceed ?

def test_get_page_template_tag_with_page_arg_as_id(self):
    """Test get_page template tag with page argument given as a page id"""
    context = Context({})
    pl1 = """{% load pages_tags %}{% get_page 1 as toto %}{{ toto }}"""
    template = get_template_from_string(pl1)
    self.assertEqual(template.render(context), u'None')
    page = self.new_page({'id': 1, 'slug': 'get-page-slug'})
    self.assertEqual(template.render(context), u'get-page-slug')

def test_get_page_template_tag_with_page_arg_as_variable_containing_page_id(self):
    """Test get_page template tag with page argument given as a page id"""
    context = Context({})
    pl1 = """{% load pages_tags %}{% placeholder areftosomepage as somepage %}{% get_page somepage as toto %}{{ toto }}"""
    template = get_template_from_string(pl1)
    self.assertEqual(template.render(context), u'None')
    page = self.new_page( { 'id': 1, 'slug': 'get-page-slug'},
                          contents={ 'areftosomepage': '1',
                                     'title': 'test-page' } )
    self.assertEqual(template.render(context), u'get-page-slug')

def test_get_page_template_tag_with_page_arg_as_variable_containing_page_slug(self):
    """Test get_page template tag with page argument given as a page id"""
    context = Context({})
    pl1 = """{% load pages_tags %}{% placeholder areftosomepage as somepage %}{% get_page somepage as toto %}{{ toto }}"""
    template = get_template_from_string(pl1)
    self.assertEqual(template.render(context), u'None')
    page = self.new_page( {'id': 1, 'slug': 'get-page-slug'},
                          contents={ 'title': 'test-title',
                                     'areftosomepage': "get-page-slug" } )
    self.assertEqual(template.render(context), u'get-page-slug')

Thanks,
Nicolas.

Edit: Fixed test cases so they are more likely to run but still haven't managed to actually run them. Tryed:
./manage test (just runs django tests)
./manage pages
Got lots of output but the result was: ran 0 tests.
./manage pages.tests.test_unit.UnitTestCase
Got a ValueError: label shoud be of the form app.TestCase or app.TestCase.test_method. Tryed such form, no more luck.

Spurius http request for undefined.gif in admin page

Presumably this is the origin of http://code.google.com/p/django-page-cms/issues/detail?id=199 (btw, it is not clear which issue tracker I should be using)

There is a bug in pages_form.js which causes the browser to attempt to load undefined.gif

I'm not set up to produce a patch file, but here's the fix, starting on line 23:

    // Set the publication status
    var select = $('#id_status');
    var opt = ({ 0: 'draft', 1: 'published', 2: 'expired', 3: 'hidden' })[select.val()];
    if (typeof(opt) != "undefined")
    {
        var img = $('<img src="'+page_media_url+'images/icons/'+opt+'.gif" alt="'+opt+'" />').insertAfter(select);
        // disable ajax post if page not already created (add view)
        var change_status = (typeof(add_form) !== 'undefined' && add_form) ? 0 : 1;

        select.change(function(e) {
            pages.update_published_icon('', select, img, change_status);
        });
    }

BTW, the url had an extra slash in it, which I removed. It worked for me, since page_media_url apparently already has a slash at the end, but if that's not guaranteed, you probably want to add something like page_media_url.replace(/\/?$/,'/')

Bug with RealTimePageIndex haystack search

When saving a page as draft while using RealTimePageIndex, it is added to/updated within the search index. This is incorrect and also fails as the publication_date field is NULL.

This presumably also happens for any draft pages that exist when real time indexing is not used but update_index is called.

A possible fix is to add:

    def should_update(self, instance, **kwargs):
        if instance.status == Page.PUBLISHED:
            return True
        return False

to the PageIndex and RealTimePageIndex classes within search_indexes.py (this only updates the index with the current instance if it has been published). It may also be worth attempting removal of the instance in case it was added previously as a published page and now changed to draft.

Thanks.

django 1.3

csrf protection does not work with move page ajax calls

Page delegation implementation

Hello. Thank you for the perfect product.

I think that Page CMS' delegation mechanism needs to be improved.
As pages/views.py, line 88 says:
result = resolve('/', urlconf)

  • at the moment the custom urlconf may hold just one path in urlpatterns - the root one.

That's a problem because the evident use case is to delegate a whole site section (with the sub-paths) to a Django application.

The possible solution is:

  1. To rewrite Page default manager's from_path() method. It should find base page of a path, not just precise match. I just replaced line 115 of pages/managers.py with this:
    if complete_path.startswith(page.get_complete_slug(lang)):
  2. To pass the rest of the path (from the base page to the end) instead of "/" to resolve() in pages/views.py, line 88:
    result = resolve(u'/'+path[len(current_page.get_complete_slug(lang))+1:], urlconf)

I'm not sure that my solution is good but I hope you will consider it.

Admin - Child pages layout looks broken

Hi Batiste,

When I create child page and then click on '+' icon in admin it seems that something goes wrong:

screenshot from 2013-10-22 01 28 29

I checked Console in Chrome Inspector and there is no JS errors. Bug disappears if I reload page.

I use Django 1.5.4 and the latest page-cms version 1.5.2.

Thanks

Cannot install on Windows using zip/tarball 1.4.3, 1.4.4, and 1.4.5

(windysurf) C:\Users\coderam\workspace\windysurf\src>pip install http://pypi.python.org/packages/source/d/django-page-cms/django-page-cms-1.4.3.tar.gz#md5=d6d284ba7f4144d4b2869ccc068c51d4
Downloading/unpacking http://pypi.python.org/packages/source/d/django-page-cms/django-page-cms-1.4.3.tar.gz
  Downloading django-page-cms-1.4.3.tar.gz (2.0Mb): 2.0Mb downloaded
  Running setup.py egg_info for package from http://pypi.python.org/packages/source/d/django-page-cms/django-page-cms-1.4.3.tar.gz

    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "c:\users\coderam\appdata\local\temp\pip-w2xdja-build\setup.py", line 63, in <module>
        'Topic :: Internet :: WWW/HTTP :: Site Management',
      File "C:\Python27\Lib\distutils\core.py", line 152, in setup
        dist.run_commands()
      File "C:\Python27\Lib\distutils\dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "<string>", line 12, in replacement_run
      File "C:\Users\coderam\Envs\windysurf\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\egg_info.py", line 252, in find_sources
      File "C:\Users\coderam\Envs\windysurf\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\egg_info.py", line 308, in run
      File "C:\Users\coderam\Envs\windysurf\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\sdist.py", line 162, in read_template
      File "C:\Python27\Lib\distutils\text_file.py", line 128, in close
        self.file.close ()
    AttributeError: 'NoneType' object has no attribute 'close'
    Complete output from command python setup.py egg_info:
    running egg_info

creating pip-egg-info\django_page_cms.egg-info

writing requirements to pip-egg-info\django_page_cms.egg-info\requires.txt

writing pip-egg-info\django_page_cms.egg-info\PKG-INFO

writing top-level names to pip-egg-info\django_page_cms.egg-info\top_level.txt

writing dependency_links to pip-egg-info\django_page_cms.egg-info\dependency_links.txt

writing manifest file 'pip-egg-info\django_page_cms.egg-info\SOURCES.txt'

warning: manifest_maker: standard file '-c' not found



reading manifest file 'pip-egg-info\django_page_cms.egg-info\SOURCES.txt'

reading manifest template 'MANIFEST.in'

Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "c:\users\coderam\appdata\local\temp\pip-w2xdja-build\setup.py", line 63, in <module>

    'Topic :: Internet :: WWW/HTTP :: Site Management',

  File "C:\Python27\Lib\distutils\core.py", line 152, in setup

    dist.run_commands()

  File "C:\Python27\Lib\distutils\dist.py", line 953, in run_commands

    self.run_command(cmd)

  File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command

    cmd_obj.run()

  File "<string>", line 12, in replacement_run

  File "C:\Users\coderam\Envs\windysurf\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\egg_info.py", line 252, in find_sources

  File "C:\Users\coderam\Envs\windysurf\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\egg_info.py", line 308, in run

  File "C:\Users\coderam\Envs\windysurf\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\sdist.py", line 162, in read_template

  File "C:\Python27\Lib\distutils\text_file.py", line 128, in close

    self.file.close ()

AttributeError: 'NoneType' object has no attribute 'close'

question about image uploads

does anyone know why "'FileSystemStorage' object has no attribute 'rindex'" is thrown every time I attempt a photo upload using the django-page-cms? I use Django 1.3 and also reproduced this error with uploads on Django 1.4.

In-memory per-instance cache, scalability problem

models.py Page._content_dict in-memory caches content items per page instance. While this is OK if you have 10-30 pages, it becomes a problem if there are +500 pages.

Problem. Every content-item ever fetched stays in that dict until Page class is unloaded (forked process dies). That means if Google starts indexing your content, then you will end-up with the whole DB fetched and stored in-memory.

Solution: use weak references.
Better solution: don't use per-instance cache! There are locmem and memcached already. memcached allows dedicated High-RAM/Low-CPU/Low-HDD server to be used (cheap) for caching. RAM in application servers is too precious to waste it for caching.

P.S. guys, placeholder idea is brilliant, but the overall implementation is... less than ideal)

auto_render deprecation warnings

Every time I run my unit tests or my (dev)server I get a warning about deprecation of the auto_render decorator.
This is because the decorator is still used in pages/admin/views.py

errors in example

when following the directions here:
http://packages.python.org/django-page-cms/installation.html

and after dependencies are installed running manage.py syncdb raises the following error:

File "../pages/testproj/documents/models.py", line 3, in <module>
    from pages.models import Page
File "../pages/models.py", line 17, in <module>
    from mptt.models import MPTTModel
ImportError: cannot import name MPTTModel

Version I'm trying is django-page-cms Release 1.4.0

Untranslated placeholders in admin

Hi there,

Please correct me if I'm wrong, but I have found that when I'm specifying my custom placeholder
as untranslated then in admin its still being looked up for language specific content.

I have several languages in a project and also need to be able to specify some content which should be same in all languages.

I've found that there is no check if placeholder shouldn't be translated in admin/init.py when admin form is being created:

232:for placeholder in get_placeholders(template):
233: name = placeholder.name
234: if obj:
235: initial = Content.objects.get_content(obj, language, name)
236: else:
237: initial = None
238: form.base_fields[name] = placeholder.get_field(obj,
239: language, initial=initial)
240:
241: return form

Thanks,

Alexey

Media must be flexable

I create folder where I store only static-files and create in settings.py parametr as: STATIC_URL and STATIC_ROOT.
But when I want to use TinyMCE that i get this(in develop_server):
"
[12/May/2010 00:10:51] "GET /static/django_page_cms/pages/javascript/pages_form.js HTTP/1.1" 200 4611
[12/May/2010 00:10:51] "GET /media/js/tiny_mce/tiny_mce.js HTTP/1.1" 404 1791
[12/May/2010 00:10:52] "GET /tinymce/filebrowser/ HTTP/1.1" 200 574
[12/May/2010 00:10:52] "GET /debug/m/js/toolbar.min.js HTTP/1.1" 200 3655
[12/May/2010 00:10:52] "GET /media/js/tiny_mce/tiny_mce.js HTTP/1.1" 404 1791
"
I think that it must get more flexable configuration where store my static-media.
What you see about it that fix it?

Thanks.

markItUpRest

I see REST making up in admin but in database of pages I get not converted to html texts. Where I can start docutils handler for such converting?

View on site in admin change_form is empty link

... thus redirecting to same page.

I'm working with Django 1.4.

Possibly this workaround will help (won't work with PAGE_USE_LANGUAGE_PREFIX=True I presume):

diff --git a/pages/models.py b/pages/models.py
index a90802f..2a393eb 100644
--- a/pages/models.py
+++ b/pages/models.py
@@ -262,7 +262,7 @@ class Page(MPTTModel):
    return reverse('pages-details-by-path',
        args=[language, url])
else:
-            return reverse('pages-details-by-path', args=[url])
+            return reverse('pages-details-by-path', args=[url]) + "?language=%s" % language

def get_absolute_url(self, language=None):
    """Alias for `get_url_path`.
    diff --git a/pages/templates/admin/pages/page/change_form.html b/pages/templates/admin/pages/page/change_form.html
    index 7c55310..01053f2 100644
    --- a/pages/templates/admin/pages/page/change_form.html
    +++ b/pages/templates/admin/pages/page/change_form.html
    @@ -15,7 +15,7 @@
         {% block object-tools %}
             {% if change and not is_popup %}
                 <ul class="object-tools">
    -                {% if has_absolute_url %}<li><a href="{% show_absolute_url page %}" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif %}
    +                {% if has_absolute_url %}<li><a href="{% show_absolute_url original request.GET.language %}" class="viewsitelink">{% trans "View on site" %}<
                 </ul>
             {% endif %}
         {% endblock %}

How to include/import custom placeholder?

Having created a custom placeholder, how does it get loaded?

I tried making an "app" and adding that to the settings.py file, but that didn't work.

I tried "loading" the file directly in the template, but that didn't work.

How/where should I load or import this file?

Thanks!

interest to participate

Hello,
I am Prateek Gupta,a student of 1st year undergraduate course pursuing Bachelors in engineering in computer science from BITS Pilani Goa in India.I am interested to participate in Google summer of code 2012 and seem to find django-page-cms as an interesting project.I currently have fairly good knowledge of JAVA,C and is currently learning Python because of it being a good language and an open source.I am interested to participate and become an active member in open source community and working with django would help me to contribute whatever little i am able to.

Being a beginner hope people can guide me for further step.Hope to get a reply soon.

with regards,
Prateek gupta

Problem in settings.py line 222

Hi Batiste.
I have found the following code at line 222 of settings.py of current committed code:

PAGE_REAL_TIME_SEARCH = getattr(settings, 'PAGE_REAL_TIME_SEARCH', False):

The : breaks the software. Removing it, Django Page CMS works again!

The correct code is:

PAGE_REAL_TIME_SEARCH = getattr(settings, 'PAGE_REAL_TIME_SEARCH', False)

I hope it helps!
Francesco

PagePermissions?

Why is there a "pages_pagepermissions" table created in the south initial migration file?

There's no other reference to this as far as I can see and it's breaking tests as the model is not in the models.py file so causing this error..

Error: Database test_muchbetter couldn't be flushed. Possible reasons:

  • The database isn't running or isn't configured correctly.
  • At least one of the expected database tables doesn't exist.
  • The SQL was invalid.
    Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
    The full error: cannot truncate a table referenced in a foreign key constraint
    DETAIL: Table "pages_pagepermission" references "pages_page".
    HINT: Truncate table "pages_pagepermission" at the same time, or use TRUNCATE ... CASCADE.

Please tag stable releases

This would help us out a lot.

We're using page-cms quite a bit and it would be handy to be able to pull down a consistent, working version when deploying without worrying about any changes made since the last time we pulled.

Using semantic versioning would be awesome: http://semver.org/

Multingual - Menu Generates 100s of Queries

I've implemented a limited number of multilingual pages and activated all the standard django language selection stuff. As soon as the multilingual aspect was activated, the site slowed down drastically. The django debug toolbar shows 216 queries generated, one for each piece of content for each page in each language - they all stem from the navigation tags.

Is there a way to avoid this, or a fix that can prevent individual queries being sent for every language variation?

Categories?

Hi!

I couldn't find this in the code so I can only assume there are no categories here?

The use case is having two sets of pages, which need links under different headings.

A nice way to deal with that is have a category and tie the pages to that.

The ugly-yet-hackish way would be to make the topmost node an empty page and render only its title, not a link, with some kind of if check in the template

Is that the way to go or did I miss something? Is category support on a roadmap?

Thanks!

issue with get_complete_slug and multiple languages

Hello,

I think there is a bug in get_comple_slug.
When I'm trying to get a URL for a page for a different languages (see example below)
I am getting same URL for all languages:
Lets say I have such a piece of template

{% load pages_tags %}
{% for l in LANGUAGES %}
    {% show_absolute_url current_page l.0 %} 
    {# Here I would expect to get different URLs to the same page #}
    {# depending on a language #}
{% endfor %}

And here is the piece of get_complete_slug which would cause the issue:

def get_complete_slug(self, language=None):
    """Return the complete slug of this page by concatenating
    all parent's slugs.

    :param language: the wanted slug language."""
    if self._complete_slug:
        return self._complete_slug
    self._complete_slug = cache.get(self.PAGE_URL_KEY %
        (self.id, language))
    ...

The self._complete_slug does not depend on a language specified,
it would hold a slug for a first queried language and would return it for all other languages.

I would like to know your thoughts on this.

Thanks,

Alexey

Parsed placeholders

I have met such an issue:
I have a lot of static pages, filled in using the placeholders, by different conent.
Content contains links to other pages. Links are hard-coded. The better solution is to use dynamic links, e.g. {% show_absolute_url current_page %}.

  1. Placeholder does not load the pages_tags, but i am sure, should.
  2. I don't how do other widgets behave, but ckeditor escapes text, inserted in it, so
    i will fail to {% show_absolute_url "my-page" %} (quotes become ").

This is a big problem to me. I'll try to explore other editor, maybe somewhere, when i input raw html (not visually), it does not escape quotes.

  • I suggest you to load at least(!) pages_tags when rendering the placeholder

Dynamic tree menu when multiple roots

If I have multiple roots in a pages tree, the pages_dynamic_tree_menu template tag is also expanding other roots when I display any subpage (as each root has its own mptt numbering).

I found that I can avoid this if I add a supplementary test in the function:

-        if page.lft <= current_page.lft and page.rght >= current_page.rght:
+        if page.tree_id == current_page.tree_id and page.lft <= current_page.lft and page.rght >= current_page.rght:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.