Permalink
Browse files

somehow working

  • Loading branch information...
1 parent 7d4089a commit 4402fe20e027160e594cfe01dcf881d721279112 @digi604 committed Oct 8, 2012
@@ -14,7 +14,7 @@ def toolbar_plugin_processor(instance, placeholder, rendered_content, original_c
'rendered_content': rendered_content
}
original_context.update(data)
- output = render_to_string('cms/toolbar/placeholder_wrapper.html', original_context)
+ output = render_to_string(instance.get_plugin_class().frontend_edit_template, original_context)
original_context.pop()
return output
View
@@ -82,12 +82,15 @@ class CMSPluginBase(admin.ModelAdmin):
form = None
change_form_template = "admin/cms/page/plugin_change_form.html"
+ frontend_edit_template = 'cms/toolbar/placeholder_wrapper.html'
# Should the plugin be rendered in the admin?
admin_preview = True
render_template = None
+
# Should the plugin be rendered at all, or doesn't it have any output?
- render_plugin = True
+ render_plugin = True
+
model = CMSPlugin
text_enabled = False
page_only = False
@@ -1,20 +1,26 @@
from cms.plugin_pool import plugin_pool
from cms.plugin_base import CMSPluginBase
-from cms.plugins.column.models import Column
+from cms.plugins.column.models import Column, ColumnPlaceholder
+from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
+class PlaceholderInline(admin.TabularInline):
+ model = ColumnPlaceholder
+
+
class ColumnPlugin(CMSPluginBase):
model = Column
name = _("Columns")
- render_template = "cms/columns/columns.html"
+ render_template = "cms/plugins/column.html"
+ inlines = [PlaceholderInline]
+ frontend_edit_template = "cms/plugins/column_frontend_edit.html"
def render(self, context, instance, placeholder):
- placeholders = instance.placeholders.all()
+ placeholders = instance.placeholder_inlines.all()
context.update({
'placeholders': placeholders,
'instance': instance,
})
return context
-
plugin_pool.register_plugin(ColumnPlugin)
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+import 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 'Column'
+ db.create_table('cmsplugin_column', (
+ ('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
+ ('num_columns', self.gf('django.db.models.fields.PositiveSmallIntegerField')(default=2)),
+ ))
+ db.send_create_signal('column', ['Column'])
+
+ # Adding model 'Placeholder'
+ db.create_table('column_placeholder', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('column', self.gf('django.db.models.fields.related.ForeignKey')(related_name='placeholder_inlines', to=orm['column.Column'])),
+ ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
+ ('width', self.gf('django.db.models.fields.CharField')(max_length=255)),
+ ('placeholder', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cms.Placeholder'])),
+ ))
+ db.send_create_signal('column', ['Placeholder'])
+
+
+ def backwards(self, orm):
+ # Deleting model 'Column'
+ db.delete_table('cmsplugin_column')
+
+ # Deleting model 'Placeholder'
+ db.delete_table('column_placeholder')
+
+
+ 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'}),
+ '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'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ },
+ 'column.column': {
+ 'Meta': {'object_name': 'Column', 'db_table': "'cmsplugin_column'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'num_columns': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '2'})
+ },
+ 'column.placeholder': {
+ 'Meta': {'object_name': 'Placeholder'},
+ 'column': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'placeholder_inlines'", 'to': "orm['column.Column']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']"}),
+ 'width': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['column']
@@ -0,0 +1,85 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Deleting field 'Placeholder.name'
+ db.delete_column('column_placeholder', 'name')
+
+ # Deleting field 'Placeholder.width'
+ db.delete_column('column_placeholder', 'width')
+
+ # Adding field 'Placeholder.slot'
+ db.add_column('column_placeholder', 'slot',
+ self.gf('django.db.models.fields.CharField')(default='name', max_length=50, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Placeholder.default_width'
+ db.add_column('column_placeholder', 'default_width',
+ self.gf('django.db.models.fields.PositiveSmallIntegerField')(null=True),
+ keep_default=False)
+
+
+ # Changing field 'Placeholder.placeholder'
+ db.alter_column('column_placeholder', 'placeholder_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cms.Placeholder'], null=True))
+
+ def backwards(self, orm):
+
+ # User chose to not deal with backwards NULL issues for 'Placeholder.name'
+ raise RuntimeError("Cannot reverse this migration. 'Placeholder.name' and its values cannot be restored.")
+
+ # User chose to not deal with backwards NULL issues for 'Placeholder.width'
+ raise RuntimeError("Cannot reverse this migration. 'Placeholder.width' and its values cannot be restored.")
+ # Deleting field 'Placeholder.slot'
+ db.delete_column('column_placeholder', 'slot')
+
+ # Deleting field 'Placeholder.default_width'
+ db.delete_column('column_placeholder', 'default_width')
+
+
+ # User chose to not deal with backwards NULL issues for 'Placeholder.placeholder'
+ raise RuntimeError("Cannot reverse this migration. 'Placeholder.placeholder' and its values cannot be restored.")
+
+ 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'}),
+ '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'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ },
+ 'column.column': {
+ 'Meta': {'object_name': 'Column', 'db_table': "'cmsplugin_column'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'num_columns': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '2'})
+ },
+ 'column.placeholder': {
+ 'Meta': {'object_name': 'Placeholder'},
+ 'column': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'placeholder_inlines'", 'to': "orm['column.Column']"}),
+ 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ }
+ }
+
+ complete_apps = ['column']
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Deleting field 'Column.num_columns'
+ db.delete_column('cmsplugin_column', 'num_columns')
+
+ # Adding field 'Column.name'
+ db.add_column('cmsplugin_column', 'name',
+ self.gf('django.db.models.fields.CharField')(default='name', max_length=100),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Adding field 'Column.num_columns'
+ db.add_column('cmsplugin_column', 'num_columns',
+ self.gf('django.db.models.fields.PositiveSmallIntegerField')(default=2),
+ keep_default=False)
+
+ # Deleting field 'Column.name'
+ db.delete_column('cmsplugin_column', 'name')
+
+
+ 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'}),
+ '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'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ },
+ 'column.column': {
+ 'Meta': {'object_name': 'Column', 'db_table': "'cmsplugin_column'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'column.placeholder': {
+ 'Meta': {'object_name': 'Placeholder'},
+ 'column': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'placeholder_inlines'", 'to': "orm['column.Column']"}),
+ 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ }
+ }
+
+ complete_apps = ['column']
@@ -0,0 +1,77 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Deleting model 'Placeholder'
+ db.delete_table('column_placeholder')
+
+ # Adding model 'ColumnPlaceholder'
+ db.create_table('column_columnplaceholder', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('column', self.gf('django.db.models.fields.related.ForeignKey')(related_name='placeholder_inlines', to=orm['column.Column'])),
+ ('slot', self.gf('django.db.models.fields.CharField')(max_length=50, db_index=True)),
+ ('default_width', self.gf('django.db.models.fields.PositiveSmallIntegerField')(null=True, blank=True)),
+ ('placeholder', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cms.Placeholder'], null=True)),
+ ))
+ db.send_create_signal('column', ['ColumnPlaceholder'])
+
+
+ def backwards(self, orm):
+ # Adding model 'Placeholder'
+ db.create_table('column_placeholder', (
+ ('slot', self.gf('django.db.models.fields.CharField')(max_length=50, db_index=True)),
+ ('column', self.gf('django.db.models.fields.related.ForeignKey')(related_name='placeholder_inlines', to=orm['column.Column'])),
+ ('default_width', self.gf('django.db.models.fields.PositiveSmallIntegerField')(null=True, blank=True)),
+ ('placeholder', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cms.Placeholder'], null=True)),
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ))
+ db.send_create_signal('column', ['Placeholder'])
+
+ # Deleting model 'ColumnPlaceholder'
+ db.delete_table('column_columnplaceholder')
+
+
+ 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'}),
+ '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'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ },
+ 'column.column': {
+ 'Meta': {'object_name': 'Column', 'db_table': "'cmsplugin_column'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'column.columnplaceholder': {
+ 'Meta': {'object_name': 'ColumnPlaceholder'},
+ 'column': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'placeholder_inlines'", 'to': "orm['column.Column']"}),
+ 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ }
+ }
+
+ complete_apps = ['column']
No changes.
Oops, something went wrong.

0 comments on commit 4402fe2

Please sign in to comment.