Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release/0.0.4'

* release/0.0.4:
  version bump to 0.0.4
  added LocalBanner (serving a local flash file instead of a google ad)
  • Loading branch information...
commit 37a6b155c187607e35c3ea5675a9b1318fd657af 2 parents 9935121 + 2599bc0
@stefanfoulis stefanfoulis authored
View
2  cmsplugin_banner/__init__.py
@@ -1 +1 @@
-__version__ = '0.0.3'
+__version__ = '0.0.4'
View
18 cmsplugin_banner/cms_plugins.py
@@ -1,6 +1,6 @@
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
-from models import Banner
+from models import Banner, LocalBanner
from django.utils.translation import ugettext as _
class BannerPlugin(CMSPluginBase):
@@ -14,4 +14,18 @@ def render(self, context, instance, placeholder):
'placeholder':placeholder})
return context
-plugin_pool.register_plugin(BannerPlugin)
+plugin_pool.register_plugin(BannerPlugin)
+
+class LocalBannerPlugin(CMSPluginBase):
+ model = LocalBanner
+ name = _("Local Flash Banner")
+ render_template = "cmsplugin_banner/local_banner.html"
+
+ def render(self, context, instance, placeholder):
+ context.update({
+ 'instance': instance,
+ 'placeholder':placeholder,
+ })
+ return context
+
+plugin_pool.register_plugin(LocalBannerPlugin)
View
176 cmsplugin_banner/migrations/0002_auto__add_localbanner.py
@@ -0,0 +1,176 @@
+# encoding: 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 'LocalBanner'
+ db.create_table('cmsplugin_localbanner', (
+ ('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
+ ('file', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['filer.File'])),
+ ('width', self.gf('django.db.models.fields.CharField')(max_length=6)),
+ ('height', self.gf('django.db.models.fields.CharField')(max_length=6)),
+ ('click_tag_free', self.gf('django.db.models.fields.CharField')(default='', max_length=255, blank=True)),
+ ('click_tag_page', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cms.Page'], null=True, blank=True)),
+ ('click_target', self.gf('django.db.models.fields.CharField')(max_length=32, null=True, blank=True)),
+ ('bgcolor', self.gf('django.db.models.fields.CharField')(default='#000000', max_length=7, blank=True)),
+ ))
+ db.send_create_signal('cmsplugin_banner', ['LocalBanner'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'LocalBanner'
+ db.delete_table('cmsplugin_localbanner')
+
+
+ models = {
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'cms.cmsplugin': {
+ 'Meta': {'object_name': 'CMSPlugin'},
+ '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.page': {
+ 'Meta': {'ordering': "('site', 'tree_id', 'lft')", 'object_name': 'Page'},
+ 'changed_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}),
+ 'created_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}),
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'in_navigation': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}),
+ 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'limit_visibility_in_menu': ('django.db.models.fields.SmallIntegerField', [], {'default': 'None', 'null': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'login_required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'moderator_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '1', 'blank': 'True'}),
+ 'navigation_extenders': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '80', 'null': 'True', 'blank': 'True'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['cms.Page']"}),
+ 'placeholders': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['cms.Placeholder']", 'symmetrical': 'False'}),
+ 'publication_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
+ 'publication_end_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
+ 'published': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'publisher_is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}),
+ 'publisher_public': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'publisher_draft'", 'unique': 'True', 'null': 'True', 'to': "orm['cms.Page']"}),
+ 'publisher_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '0', 'db_index': 'True'}),
+ 'reverse_id': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '40', 'null': 'True', 'blank': 'True'}),
+ 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['sites.Site']"}),
+ 'soft_root': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+ 'template': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ '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'})
+ },
+ 'cmsplugin_banner.banner': {
+ 'Meta': {'object_name': 'Banner', 'db_table': "'cmsplugin_banner'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'banners'", 'to': "orm['cmsplugin_banner.Slot']"}),
+ 'style': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'})
+ },
+ 'cmsplugin_banner.localbanner': {
+ 'Meta': {'object_name': 'LocalBanner', 'db_table': "'cmsplugin_localbanner'", '_ormbases': ['cms.CMSPlugin']},
+ 'bgcolor': ('django.db.models.fields.CharField', [], {'default': "'#000000'", 'max_length': '7', 'blank': 'True'}),
+ 'click_tag_free': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
+ 'click_tag_page': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Page']", 'null': 'True', 'blank': 'True'}),
+ 'click_target': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'file': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['filer.File']"}),
+ 'height': ('django.db.models.fields.CharField', [], {'max_length': '6'}),
+ 'width': ('django.db.models.fields.CharField', [], {'max_length': '6'})
+ },
+ 'cmsplugin_banner.slot': {
+ 'Meta': {'object_name': 'Slot'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'filer.file': {
+ 'Meta': {'object_name': 'File'},
+ '_file': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ '_file_size': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ '_file_type_plugin_name': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'folder': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'all_files'", 'null': 'True', 'to': "orm['filer.Folder']"}),
+ 'has_all_mandatory_data': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'modified_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'original_filename': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_files'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
+ },
+ 'filer.folder': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('parent', 'name'),)", 'object_name': 'Folder'},
+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'modified_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'filer_owned_folders'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['filer.Folder']"}),
+ 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
+ },
+ 'sites.site': {
+ 'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"},
+ 'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ }
+ }
+
+ complete_apps = ['cmsplugin_banner']
View
26 cmsplugin_banner/models.py
@@ -1,6 +1,8 @@
from django.db import models
from cms.models import CMSPlugin
+from cms.models.fields import PageField
from django.utils.translation import ugettext_lazy as _
+from filer.fields.file import FilerFileField
from cmsplugin_banner import conf
@@ -17,3 +19,27 @@ class Banner(CMSPlugin):
def __unicode__(self):
return u"%s" % (self.title or self.id, )
+
+CLICK_TARGET_CHOICES = (
+ ('_blank', _('open in new window')),
+ ('_self', _('open in same window')),
+)
+
+class LocalBanner(CMSPlugin):
+ file = FilerFileField(help_text=_('use swf file'))
+ width = models.CharField(_('width'), max_length=6)
+ height = models.CharField(_('height'), max_length=6)
+
+ click_tag_free = models.CharField(_('click tag'), max_length=255, blank=True, default='')
+ click_tag_page = PageField(null=True, blank=True)
+ click_target = models.CharField(_('click target'), choices=CLICK_TARGET_CHOICES, max_length=32, null=True, blank=True)
+
+ bgcolor = models.CharField(_('background color'), default="#000000", max_length=7, blank=True)
+
+ def click_tag(self):
+ if self.click_tag_free:
+ return self.click_tag_free
+ elif self.click_tag_page:
+ return self.click_tag_page.get_absolute_url()
+ else:
+ return ''
View
18 cmsplugin_banner/templates/cmsplugin_banner/local_banner.html
@@ -0,0 +1,18 @@
+{% load i18n %}
+<div class="banner" id="local_banner_plugin_{{ instance.id }}"></div>
+
+<script type="text/javascript">
+//<![CDATA[
+ var flashvars = {};
+ flashvars.clickTag = "{{ instance.click_tag }}";
+ flashvars.clickTarget = "{{ instance.click_target }}";
+
+ var params = {};
+ params.allowscriptaccess = "always";{% if instance.bgcolor %}
+ params.bgcolor = "{{ instance.bgcolor }}";{% endif %}
+ params.wmode = "opaque";
+
+ var attributes = {};
+ swfobject.embedSWF("{{ instance.file.url }}", "local_banner_plugin_{{ instance.id }}", "{{ instance.width }}", "{{ instance.height }}", "8.0.0", "", flashvars, params, attributes);
+//]]>
+</script>
View
1  setup.py
@@ -29,6 +29,7 @@
install_requires = [
'setuptools',
+ 'django-filer',
]
setup(
Please sign in to comment.
Something went wrong with that request. Please try again.