Made width and height focal point fields nullable

pull/487/head
Karl Hobley 2014-07-23 11:33:19 +01:00
rodzic c6e9123c9a
commit 90eed2c95b
2 zmienionych plików z 10 dodań i 7 usunięć

Wyświetl plik

@ -25,12 +25,12 @@ class Migration(SchemaMigration):
# Adding field 'Image.focal_point_width'
db.add_column('wagtailimages_image', 'focal_point_width',
self.gf('django.db.models.fields.PositiveIntegerField')(default=0),
self.gf('django.db.models.fields.PositiveIntegerField')(null=True),
keep_default=False)
# Adding field 'Image.focal_point_height'
db.add_column('wagtailimages_image', 'focal_point_height',
self.gf('django.db.models.fields.PositiveIntegerField')(default=0),
self.gf('django.db.models.fields.PositiveIntegerField')(null=True),
keep_default=False)
# Adding field 'Rendition.focal_point_key'
@ -111,8 +111,8 @@ class Migration(SchemaMigration):
'Meta': {'object_name': 'Image'},
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'file': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
'focal_point_height': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'focal_point_width': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'focal_point_height': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
'focal_point_width': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
'focal_point_x': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
'focal_point_y': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
'height': ('django.db.models.fields.IntegerField', [], {}),

Wyświetl plik

@ -53,8 +53,8 @@ class AbstractImage(models.Model, TagSearchable):
focal_point_x = models.PositiveIntegerField(null=True, editable=False)
focal_point_y = models.PositiveIntegerField(null=True, editable=False)
focal_point_width = models.PositiveIntegerField(default=0, editable=False)
focal_point_height = models.PositiveIntegerField(default=0, editable=False)
focal_point_width = models.PositiveIntegerField(null=True, editable=False)
focal_point_height = models.PositiveIntegerField(null=True, editable=False)
search_fields = TagSearchable.search_fields + (
indexed.FilterField('uploaded_by_user'),
@ -65,7 +65,10 @@ class AbstractImage(models.Model, TagSearchable):
@property
def focal_point(self):
if self.focal_point_x is not None and self.focal_point_y is not None:
if self.focal_point_x is not None and \
self.focal_point_y is not None and \
self.focal_point_width is not None and \
self.focal_point_height is not None:
return FocalPoint(
self.focal_point_x,
self.focal_point_y,