added migration

This commit is contained in:
Anatoly 2019-10-02 18:09:29 +03:00
parent 83ffb4dae1
commit 296a09165d
3 changed files with 27 additions and 25 deletions

View File

@ -1,20 +0,0 @@
# Generated by Django 2.2.4 on 2019-10-01 06:47
from django.db import migrations
import sorl.thumbnail.fields
import utils.methods
class Migration(migrations.Migration):
dependencies = [
('gallery', '0002_auto_20190930_0714'),
]
operations = [
migrations.AlterField(
model_name='image',
name='image',
field=sorl.thumbnail.fields.ImageField(upload_to=utils.methods.image_path, verbose_name='image file'),
),
]

View File

@ -0,0 +1,26 @@
# Generated by Django 2.2.4 on 2019-10-02 14:56
from django.db import migrations, models
import django.db.models.deletion
import sorl.thumbnail.fields
import utils.methods
class Migration(migrations.Migration):
dependencies = [
('gallery', '0002_auto_20190930_0714'),
]
operations = [
migrations.AlterField(
model_name='image',
name='image',
field=sorl.thumbnail.fields.ImageField(upload_to=utils.methods.image_path, verbose_name='image file'),
),
migrations.AlterField(
model_name='image',
name='parent',
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_DEFAULT, related_name='children', to='gallery.Image', verbose_name='parent image'),
),
]

View File

@ -30,7 +30,7 @@ class Image(ProjectBaseMixin, SORLImageMixin, PlatformMixin):
verbose_name=_('image file'))
parent = models.ForeignKey('self',
blank=True, null=True, default=None,
related_name='parent_image',
related_name='children',
on_delete=models.SET_DEFAULT,
verbose_name=_('parent image'))
orientation = models.PositiveSmallIntegerField(choices=ORIENTATIONS,
@ -55,7 +55,3 @@ class Image(ProjectBaseMixin, SORLImageMixin, PlatformMixin):
tasks.delete_image_from_remote_storage.delay(self.id, delete_original)
else:
tasks.delete_image_from_remote_storage(self.id, delete_original)
@property
def children(self):
return self.parent_image.filter(parent=self)