'updatecache' parameter passed explicitely to the plugins when present in GET
This commit is contained in:
parent
6338801048
commit
a32c1fa9c8
|
@ -3,14 +3,10 @@ from django.template import loader
|
|||
|
||||
from cmsplugin_text_wrapper.cms_plugins import TextPlugin
|
||||
from cms.plugin_pool import plugin_pool
|
||||
from .models import TextWithExtraArgs
|
||||
from .forms import TextWithExtraArgsForm
|
||||
|
||||
class AjaxTextPlugin(TextPlugin):
|
||||
name = _(u'Text (asynchronous loading)')
|
||||
ajax_render_template = 'plugin/ajax_text.html'
|
||||
model = TextWithExtraArgs
|
||||
form = TextWithExtraArgsForm
|
||||
text_enabled = True
|
||||
|
||||
def get_ajax_body(self, instance, context):
|
||||
|
@ -19,9 +15,11 @@ class AjaxTextPlugin(TextPlugin):
|
|||
|
||||
def render(self, context, instance, placeholder):
|
||||
request = context.get('request')
|
||||
if 'updatecache' in request.GET:
|
||||
instance.args = '?updatecache'
|
||||
context['object'] = instance
|
||||
edit_mode = request and 'edit' in request.GET
|
||||
is_ajax = request and request.is_ajax()
|
||||
context['object'] = instance
|
||||
if edit_mode or is_ajax:
|
||||
context = super(AjaxTextPlugin, self).render(context, instance, placeholder)
|
||||
return context
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
{% addtoblock "js" %}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$("#plugin-{{ object.id }}").load('{% url 'ajax_render' object.id %}?{{ object.args|safe }}');
|
||||
$("#plugin-{{ object.id }}").load('{% url 'ajax_render' object.id %}{{ object.args|safe }}');
|
||||
});
|
||||
</script>
|
||||
{% endaddtoblock %}
|
||||
|
||||
<div id="plugin-{{ object.id }}">
|
||||
<div class="loading">
|
||||
<div id="plugin-{{ object.id }}" class='cms-ajax-text-plugin'>
|
||||
<div class='cms-ajax-text-plugin-loading'>
|
||||
{% trans "loading..." %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Reference in New Issue