summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei MIHAI <smihai@entrouvert.com>2014-02-05 11:06:41 (GMT)
committerSerghei MIHAI <smihai@entrouvert.com>2014-02-05 11:08:05 (GMT)
commitb82b131f7c0d167e3cae5f20a5299e0193b73c19 (patch)
tree61c1a26b7789e81300d24b0d60c53e553945aa7b
parent58fafef0871be3e492a7c1a0e03dbd156f61e956 (diff)
downloadcms-ajax-text-plugin-b82b131f7c0d167e3cae5f20a5299e0193b73c19.zip
cms-ajax-text-plugin-b82b131f7c0d167e3cae5f20a5299e0193b73c19.tar.gz
cms-ajax-text-plugin-b82b131f7c0d167e3cae5f20a5299e0193b73c19.tar.bz2
extra GET parameters could be sent to included plugins
-rw-r--r--cms_ajax_text_plugin/cms_plugins.py4
-rw-r--r--cms_ajax_text_plugin/forms.py7
-rw-r--r--cms_ajax_text_plugin/migrations/0001_initial.py60
-rw-r--r--cms_ajax_text_plugin/migrations/__init__.py0
-rw-r--r--cms_ajax_text_plugin/models.py12
-rw-r--r--cms_ajax_text_plugin/templates/plugin/ajax_text.html2
6 files changed, 84 insertions, 1 deletions
diff --git a/cms_ajax_text_plugin/cms_plugins.py b/cms_ajax_text_plugin/cms_plugins.py
index 024dd78..cd73a1f 100644
--- a/cms_ajax_text_plugin/cms_plugins.py
+++ b/cms_ajax_text_plugin/cms_plugins.py
@@ -3,10 +3,14 @@ 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):
diff --git a/cms_ajax_text_plugin/forms.py b/cms_ajax_text_plugin/forms.py
new file mode 100644
index 0000000..b32ec63
--- /dev/null
+++ b/cms_ajax_text_plugin/forms.py
@@ -0,0 +1,7 @@
+from .models import TextWithExtraArgs
+from cmsplugin_text_wrapper.forms import TextForm
+
+class TextWithExtraArgsForm(TextForm):
+
+ class Meta:
+ model = TextWithExtraArgs
diff --git a/cms_ajax_text_plugin/migrations/0001_initial.py b/cms_ajax_text_plugin/migrations/0001_initial.py
new file mode 100644
index 0000000..533f858
--- /dev/null
+++ b/cms_ajax_text_plugin/migrations/0001_initial.py
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+from south.utils import datetime_utils as datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding model 'TextWithExtraArgs'
+ db.create_table(u'cmsplugin_textwithextraargs', (
+ (u'textwrapper_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cmsplugin_text_wrapper.TextWrapper'], unique=True, primary_key=True)),
+ ('args', self.gf('django.db.models.fields.CharField')(max_length=256, null=True, blank=True)),
+ ))
+ db.send_create_signal(u'cms_ajax_text_plugin', ['TextWithExtraArgs'])
+
+
+ def backwards(self, orm):
+ # Deleting model 'TextWithExtraArgs'
+ db.delete_table(u'cmsplugin_textwithextraargs')
+
+
+ models = {
+ 'cms.cmsplugin': {
+ 'Meta': {'object_name': 'CMSPlugin'},
+ 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
+ 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
+ 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
+ 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
+ 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+ },
+ 'cms.placeholder': {
+ 'Meta': {'object_name': 'Placeholder'},
+ 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ },
+ u'cms_ajax_text_plugin.textwithextraargs': {
+ 'Meta': {'object_name': 'TextWithExtraArgs', 'db_table': "u'cmsplugin_textwithextraargs'", '_ormbases': [u'cmsplugin_text_wrapper.TextWrapper']},
+ 'args': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}),
+ u'textwrapper_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['cmsplugin_text_wrapper.TextWrapper']", 'unique': 'True', 'primary_key': 'True'})
+ },
+ u'cmsplugin_text_wrapper.textwrapper': {
+ 'Meta': {'object_name': 'TextWrapper', 'db_table': "'cmsplugin_text'"},
+ 'body': ('django.db.models.fields.TextField', [], {}),
+ 'classes': ('cmsplugin_text_wrapper.fields.MultiSelectField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
+ u'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'wrapper': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+ }
+ }
+
+ complete_apps = ['cms_ajax_text_plugin'] \ No newline at end of file
diff --git a/cms_ajax_text_plugin/migrations/__init__.py b/cms_ajax_text_plugin/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cms_ajax_text_plugin/migrations/__init__.py
diff --git a/cms_ajax_text_plugin/models.py b/cms_ajax_text_plugin/models.py
new file mode 100644
index 0000000..5d17e0b
--- /dev/null
+++ b/cms_ajax_text_plugin/models.py
@@ -0,0 +1,12 @@
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+
+from cmsplugin_text_wrapper.models import TextWrapper
+
+class TextWithExtraArgs(TextWrapper):
+ """
+ Model for Text with args
+ """
+ args = models.CharField(max_length=256,
+ help_text=_(u'extra GET arguments to pass to included plugins'),
+ blank = True, null = True)
diff --git a/cms_ajax_text_plugin/templates/plugin/ajax_text.html b/cms_ajax_text_plugin/templates/plugin/ajax_text.html
index 4f98780..e78f9af 100644
--- a/cms_ajax_text_plugin/templates/plugin/ajax_text.html
+++ b/cms_ajax_text_plugin/templates/plugin/ajax_text.html
@@ -6,7 +6,7 @@
{% addtoblock "js" %}
<script type="text/javascript">
$(document).ready(function(){
- $("#plugin-{{ object.id }}").load('{% url 'ajax_render' object.id %}');
+ $("#plugin-{{ object.id }}").load('{% url 'ajax_render' object.id %}?{{ object.args|safe }}');
});
</script>
{% endaddtoblock %}