divio / aldryn-newsblog

A combined news/weblog application for Aldryn and django CMS – part of the Essential Addons.
https://marketplace.django-cms.org/en/addons/browse/aldryn-newsblog/
Other
67 stars 118 forks source link

Search data won`t be updated for specific plugins without context #500

Open DDshka opened 6 years ago

DDshka commented 6 years ago

Introduction: Aldryn_newsblog gets all plugins inside article content placeholder and renders them programatically. As they are rendered application clears content from html tags and adds it to field 'search_data' of Article model.

The problem: To render a plugin the application actually simulates circumstances to render it. So they need a request and its context. But aldryn_newsblog uses default context without any processing according to the users settings. In this case, all plugins which depend on users context processors, which add additional info to context, just cant be rendered. (e.g. sekizai tags)

To see the bug (using aldryn_newsblog v. 2.1.1):

  1. In application settings enable search data upadting with: ALDRYN_NEWSBLOG_UPDATE_SEARCH_DATA_ON_SAVE = True
  2. Create an article.
  3. Add Google maps plugin (it`s template using sekizai tags)
  4. Try to save.

Test project with the issue. (Check "readme")

One of the possible solutions is to simulate context processing like:

from django.utils.module_loading import import_string
    for processor in settings.TEMPLATES[0]['OPTIONS']['context_processors']:
        func = import_string(processor)
        context.update(func(request))

in /aldryn_newsblog/utils/utilities.py:115

But the solution is up to you.