Skip to content

Commit

Permalink
change field name from src to image
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacrymology committed Oct 6, 2011
1 parent c09db64 commit 3f551f2
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 2 deletions.
65 changes: 65 additions & 0 deletions cmsplugin_s3slider/migrations/0006_auto__add_field_image_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 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 field 'Image.image'
db.add_column('cmsplugin_s3slider_image', 'image', self.gf('django.db.models.fields.files.ImageField')(default=0, max_length=100), keep_default=False)


def backwards(self, orm):

# Deleting field 'Image.image'
db.delete_column('cmsplugin_s3slider_image', 'image')


models = {
'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.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_s3slider.galleryplugin': {
'Meta': {'object_name': 'GalleryPlugin', 'db_table': "'cmsplugin_galleryplugin'", '_ormbases': ['cms.CMSPlugin']},
'alignment': ('django.db.models.fields.CharField', [], {'default': "'left'", 'max_length': '8'}),
'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
'template': ('django.db.models.fields.CharField', [], {'default': "'cmsplugin_s3slider/gallery.html'", 'max_length': '255'}),
'timeout': ('django.db.models.fields.IntegerField', [], {'default': '3000'})
},
'cmsplugin_s3slider.image': {
'Meta': {'ordering': "('inline_ordering_position',)", 'object_name': 'Image'},
'alt': ('django.db.models.fields.CharField', [], {'max_length': '127', 'blank': 'True'}),
'gallery': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cmsplugin_s3slider.GalleryPlugin']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
'inline_ordering_position': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'src': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
'src_height': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'src_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'text': ('django.db.models.fields.CharField', [], {'max_length': '2047', 'blank': 'True'}),
'textPosition': ('django.db.models.fields.CharField', [], {'default': "'bottom'", 'max_length': '6'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
}
}

complete_apps = ['cmsplugin_s3slider']
66 changes: 66 additions & 0 deletions cmsplugin_s3slider/migrations/0007_copy_src_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models

class Migration(DataMigration):

def forwards(self, orm):
"Write your forwards methods here."
for image in orm.Image.objects.all():
image.image = image.src
image.save()


def backwards(self, orm):
"Write your backwards methods here."
for image in orm.Image.objects.all():
image.src = image.image
image.save()

models = {
'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.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_s3slider.galleryplugin': {
'Meta': {'object_name': 'GalleryPlugin', 'db_table': "'cmsplugin_galleryplugin'", '_ormbases': ['cms.CMSPlugin']},
'alignment': ('django.db.models.fields.CharField', [], {'default': "'left'", 'max_length': '8'}),
'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
'template': ('django.db.models.fields.CharField', [], {'default': "'cmsplugin_s3slider/gallery.html'", 'max_length': '255'}),
'timeout': ('django.db.models.fields.IntegerField', [], {'default': '3000'})
},
'cmsplugin_s3slider.image': {
'Meta': {'ordering': "('inline_ordering_position',)", 'object_name': 'Image'},
'alt': ('django.db.models.fields.CharField', [], {'max_length': '127', 'blank': 'True'}),
'gallery': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cmsplugin_s3slider.GalleryPlugin']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
'inline_ordering_position': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'src': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
'src_height': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'src_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'text': ('django.db.models.fields.CharField', [], {'max_length': '2047', 'blank': 'True'}),
'textPosition': ('django.db.models.fields.CharField', [], {'default': "'bottom'", 'max_length': '6'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
}
}

complete_apps = ['cmsplugin_s3slider']
64 changes: 64 additions & 0 deletions cmsplugin_s3slider/migrations/0008_auto__del_field_image_src.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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):

# Deleting field 'Image.src'
db.delete_column('cmsplugin_s3slider_image', 'src')


def backwards(self, orm):

# Adding field 'Image.src'
db.add_column('cmsplugin_s3slider_image', 'src', self.gf('django.db.models.fields.files.ImageField')(default=0, max_length=100), keep_default=False)


models = {
'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.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_s3slider.galleryplugin': {
'Meta': {'object_name': 'GalleryPlugin', 'db_table': "'cmsplugin_galleryplugin'", '_ormbases': ['cms.CMSPlugin']},
'alignment': ('django.db.models.fields.CharField', [], {'default': "'left'", 'max_length': '8'}),
'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
'template': ('django.db.models.fields.CharField', [], {'default': "'cmsplugin_s3slider/gallery.html'", 'max_length': '255'}),
'timeout': ('django.db.models.fields.IntegerField', [], {'default': '3000'})
},
'cmsplugin_s3slider.image': {
'Meta': {'ordering': "('inline_ordering_position',)", 'object_name': 'Image'},
'alt': ('django.db.models.fields.CharField', [], {'max_length': '127', 'blank': 'True'}),
'gallery': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cmsplugin_s3slider.GalleryPlugin']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
'inline_ordering_position': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'src_height': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'src_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'text': ('django.db.models.fields.CharField', [], {'max_length': '2047', 'blank': 'True'}),
'textPosition': ('django.db.models.fields.CharField', [], {'default': "'bottom'", 'max_length': '6'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
}
}

complete_apps = ['cmsplugin_s3slider']
3 changes: 2 additions & 1 deletion cmsplugin_s3slider/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ def get_media_path(self, filename):
return pages[0].get_media_path(filename)

gallery = models.ForeignKey(GalleryPlugin)
src = models.ImageField(upload_to=get_media_path,
image = models.ImageField(upload_to=get_media_path,
height_field='src_height',
width_field='src_width')

src_height = models.PositiveSmallIntegerField(editable=False, null=True)
src_width = models.PositiveSmallIntegerField(editable=False, null=True)
alt = models.CharField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<ul id="{{ slider_id }}Content">
{% for image in images %}
<li class="{{ slider_id }}Image">
<a href=""><img src="{{ image.src.url }}" alt="1" /></a>
<a href=""><img src="{{ image.image.url }}" alt="1" /></a>
<span class="{{ image.textPosition }}">
<strong>{{ image.title }}</strong><br />
{{ image.text }}
Expand Down

0 comments on commit 3f551f2

Please sign in to comment.