Reset migrations

This commit is contained in:
Alexandre Iooss 2022-01-30 11:15:41 +01:00
parent d865a6eb1f
commit 80085edeeb
23 changed files with 52 additions and 675 deletions

View file

@ -63,7 +63,6 @@ INSTALLED_APPS = [
'allauth_note_kfet', 'allauth_note_kfet',
'crispy_forms', 'crispy_forms',
'photologue', 'photologue',
'taggit',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -155,8 +154,6 @@ USE_L10N = True
USE_TZ = True USE_TZ = True
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Limit available languages to this subset # Limit available languages to this subset
LANGUAGES = [ LANGUAGES = [
('de', _('German')), ('de', _('German')),

View file

@ -1,158 +1,96 @@
# -*- coding: utf-8 -*- # Generated by Django 3.2.11 on 2022-01-30 10:14
from __future__ import unicode_literals
from django.conf import settings
import django.core.validators import django.core.validators
import django.utils.timezone
import sortedm2m.fields
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import photologue.models import photologue.models
class Migration(migrations.Migration): class Migration(migrations.Migration):
initial = True
dependencies = [ dependencies = [
('sites', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL),
] ]
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='Gallery', name='PhotoSize',
fields=[ fields=[
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date_added', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date published')), ('name', models.CharField(help_text='Photo size name should contain only letters, numbers and underscores. Examples: "thumbnail", "display", "small", "main_page_widget".', max_length=40, unique=True, validators=[django.core.validators.RegexValidator(message='Use only plain lowercase letters (ASCII), numbers and underscores.', regex='^[a-z0-9_]+$')], verbose_name='name')),
('title', models.CharField(max_length=50, verbose_name='title', unique=True)), ('width', models.PositiveIntegerField(default=0, help_text='If width is set to "0" the image will be scaled to the supplied height.', verbose_name='width')),
('slug', models.SlugField(help_text='A "slug" is a unique URL-friendly title for an object.', verbose_name='title slug', unique=True)), ('height', models.PositiveIntegerField(default=0, help_text='If height is set to "0" the image will be scaled to the supplied width', verbose_name='height')),
('description', models.TextField(blank=True, verbose_name='description')), ('quality', models.PositiveIntegerField(choices=[(30, 'Very Low'), (40, 'Low'), (50, 'Medium-Low'), (60, 'Medium'), (70, 'Medium-High'), (80, 'High'), (90, 'Very High')], default=70, help_text='JPEG image quality.', verbose_name='quality')),
('is_public', models.BooleanField(help_text='Public galleries will be displayed in the default views.', verbose_name='is public', default=True)), ('upscale', models.BooleanField(default=False, help_text='If selected the image will be scaled up if necessary to fit the supplied dimensions. Cropped sizes will be upscaled regardless of this setting.', verbose_name='upscale images?')),
('tags', photologue.models.TagField(max_length=255, help_text='Django-tagging was not found, tags will be treated as plain text.', blank=True, verbose_name='tags')), ('crop', models.BooleanField(default=False, help_text='If selected the image will be scaled and cropped to fit the supplied dimensions.', verbose_name='crop to fit?')),
('sites', models.ManyToManyField(blank=True, verbose_name='sites', null=True, to='sites.Site')), ('pre_cache', models.BooleanField(default=False, help_text='If selected this photo size will be pre-cached as photos are added.', verbose_name='pre-cache?')),
('increment_count', models.BooleanField(default=False, help_text='If selected the image\'s "view_count" will be incremented when this photo size is displayed.', verbose_name='increment view count?')),
], ],
options={ options={
'get_latest_by': 'date_added', 'verbose_name': 'photo size',
'verbose_name': 'gallery', 'verbose_name_plural': 'photo sizes',
'ordering': ['-date_added'], 'ordering': ['width', 'height'],
'verbose_name_plural': 'galleries',
}, },
bases=(models.Model,),
), ),
migrations.CreateModel( migrations.CreateModel(
name='GalleryUpload', name='Tag',
fields=[ fields=[
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('zip_file', models.FileField(help_text='Select a .zip file of images to upload into a new Gallery.', verbose_name='images file (.zip)', upload_to='photologue/temp')), ('name', models.CharField(max_length=250, unique=True, verbose_name='name')),
('title', models.CharField(max_length=50, help_text='All uploaded photos will be given a title made up of this title + a sequential number.', verbose_name='title')), ('slug', models.SlugField(help_text='A "slug" is a unique URL-friendly title for an object.', max_length=250, unique=True, verbose_name='slug')),
('caption', models.TextField(help_text='Caption will be added to all photos.', blank=True, verbose_name='caption')),
('description', models.TextField(help_text='A description of this Gallery.', blank=True, verbose_name='description')),
('is_public', models.BooleanField(help_text='Uncheck this to make the uploaded gallery and included photographs private.', verbose_name='is public', default=True)),
('tags', models.CharField(max_length=255, help_text='Django-tagging was not found, tags will be treated as plain text.', blank=True, verbose_name='tags')),
('gallery', models.ForeignKey(blank=True, verbose_name='gallery', null=True, help_text='Select a gallery to add these images to. Leave this empty to create a new gallery from the supplied title.', to='photologue.Gallery', on_delete=models.CASCADE)),
], ],
options={ options={
'verbose_name': 'gallery upload', 'verbose_name': 'tag',
'verbose_name_plural': 'gallery uploads', 'verbose_name_plural': 'tags',
'ordering': ['name'],
}, },
bases=(models.Model,),
), ),
migrations.CreateModel( migrations.CreateModel(
name='Photo', name='Photo',
fields=[ fields=[
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('image', models.ImageField(upload_to=photologue.models.get_storage_path, verbose_name='image')), ('image', models.ImageField(upload_to=photologue.models.get_storage_path, verbose_name='image')),
('date_taken', models.DateTimeField(verbose_name='date taken', blank=True, editable=False, null=True)), ('date_taken', models.DateTimeField(blank=True, help_text='Date image was taken; is obtained from the image EXIF data.', null=True, verbose_name='date taken')),
('view_count', models.PositiveIntegerField(verbose_name='view count', default=0, editable=False)), ('view_count', models.PositiveIntegerField(default=0, editable=False, verbose_name='view count')),
('crop_from', models.CharField(max_length=10, default='center', blank=True, verbose_name='crop from', choices=[('top', 'Top'), ('right', 'Right'), ('bottom', 'Bottom'), ('left', 'Left'), ('center', 'Center (Default)')])), ('crop_from', models.CharField(blank=True, choices=[('top', 'Top'), ('right', 'Right'), ('bottom', 'Bottom'), ('left', 'Left'), ('center', 'Center (Default)')], default='center', max_length=10, verbose_name='crop from')),
('title', models.CharField(max_length=50, verbose_name='title', unique=True)), ('title', models.CharField(max_length=250, unique=True, verbose_name='title')),
('slug', models.SlugField(help_text='A "slug" is a unique URL-friendly title for an object.', verbose_name='slug', unique=True)), ('slug', models.SlugField(help_text='A "slug" is a unique URL-friendly title for an object.', max_length=250, unique=True, verbose_name='slug')),
('caption', models.TextField(blank=True, verbose_name='caption')), ('caption', models.TextField(blank=True, verbose_name='caption')),
('date_added', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date added')), ('date_added', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date added')),
('is_public', models.BooleanField(help_text='Public photographs will be displayed in the default views.', verbose_name='is public', default=True)), ('license', models.CharField(blank=True, max_length=255, verbose_name='license')),
('tags', photologue.models.TagField(max_length=255, help_text='Django-tagging was not found, tags will be treated as plain text.', blank=True, verbose_name='tags')), ('is_public', models.BooleanField(default=True, help_text='Public photographs will be displayed in the default views.', verbose_name='is public')),
('sites', models.ManyToManyField(blank=True, verbose_name='sites', null=True, to='sites.Site')), ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='owner')),
], ],
options={ options={
'get_latest_by': 'date_added',
'verbose_name': 'photo', 'verbose_name': 'photo',
'ordering': ['-date_added'],
'verbose_name_plural': 'photos', 'verbose_name_plural': 'photos',
'ordering': ['-date_added'],
'get_latest_by': 'date_added',
}, },
bases=(models.Model,),
),
migrations.AddField(
model_name='gallery',
name='photos',
field=sortedm2m.fields.SortedManyToManyField(blank=True, verbose_name='photos', null=True, to='photologue.Photo'),
preserve_default=True,
), ),
migrations.CreateModel( migrations.CreateModel(
name='PhotoEffect', name='Gallery',
fields=[ fields=[
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30, verbose_name='name', unique=True)), ('date_added', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date published')),
('title', models.CharField(max_length=250, unique=True, verbose_name='title')),
('slug', models.SlugField(help_text='A "slug" is a unique URL-friendly title for an object.', max_length=250, unique=True, verbose_name='title slug')),
('date_start', models.DateField(default=django.utils.timezone.now, verbose_name='start date')),
('date_end', models.DateField(blank=True, null=True, verbose_name='end date')),
('description', models.TextField(blank=True, verbose_name='description')), ('description', models.TextField(blank=True, verbose_name='description')),
('transpose_method', models.CharField(max_length=15, blank=True, verbose_name='rotate or flip', choices=[('FLIP_LEFT_RIGHT', 'Flip left to right'), ('FLIP_TOP_BOTTOM', 'Flip top to bottom'), ('ROTATE_90', 'Rotate 90 degrees counter-clockwise'), ('ROTATE_270', 'Rotate 90 degrees clockwise'), ('ROTATE_180', 'Rotate 180 degrees')])), ('is_public', models.BooleanField(default=True, help_text='Public galleries will be displayed in the default views.', verbose_name='is public')),
('color', models.FloatField(help_text='A factor of 0.0 gives a black and white image, a factor of 1.0 gives the original image.', verbose_name='color', default=1.0)), ('photos', models.ManyToManyField(blank=True, related_name='galleries', to='photologue.Photo', verbose_name='photos')),
('brightness', models.FloatField(help_text='A factor of 0.0 gives a black image, a factor of 1.0 gives the original image.', verbose_name='brightness', default=1.0)), ('tags', models.ManyToManyField(blank=True, related_name='galleries', to='photologue.Tag', verbose_name='tags')),
('contrast', models.FloatField(help_text='A factor of 0.0 gives a solid grey image, a factor of 1.0 gives the original image.', verbose_name='contrast', default=1.0)),
('sharpness', models.FloatField(help_text='A factor of 0.0 gives a blurred image, a factor of 1.0 gives the original image.', verbose_name='sharpness', default=1.0)),
('filters', models.CharField(max_length=200, help_text='Chain multiple filters using the following pattern "FILTER_ONE->FILTER_TWO->FILTER_THREE". Image filters will be applied in order. The following filters are available: BLUR, CONTOUR, DETAIL, EDGE_ENHANCE, EDGE_ENHANCE_MORE, EMBOSS, FIND_EDGES, SHARPEN, SMOOTH, SMOOTH_MORE.', blank=True, verbose_name='filters')),
('reflection_size', models.FloatField(help_text='The height of the reflection as a percentage of the orignal image. A factor of 0.0 adds no reflection, a factor of 1.0 adds a reflection equal to the height of the orignal image.', verbose_name='size', default=0)),
('reflection_strength', models.FloatField(help_text='The initial opacity of the reflection gradient.', verbose_name='strength', default=0.6)),
('background_color', models.CharField(max_length=7, help_text='The background color of the reflection gradient. Set this to match the background color of your page.', verbose_name='color', default='#FFFFFF')),
], ],
options={ options={
'verbose_name': 'photo effect', 'verbose_name': 'gallery',
'verbose_name_plural': 'photo effects', 'verbose_name_plural': 'galleries',
'ordering': ['-date_added'],
'get_latest_by': 'date_added',
}, },
bases=(models.Model,),
),
migrations.AddField(
model_name='photo',
name='effect',
field=models.ForeignKey(blank=True, verbose_name='effect', null=True, to='photologue.PhotoEffect', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.CreateModel(
name='PhotoSize',
fields=[
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)),
('name', models.CharField(max_length=40, help_text='Photo size name should contain only letters, numbers and underscores. Examples: "thumbnail", "display", "small", "main_page_widget".', verbose_name='name', unique=True, validators=[django.core.validators.RegexValidator(regex='^[a-z0-9_]+$', message='Use only plain lowercase letters (ASCII), numbers and underscores.')])),
('width', models.PositiveIntegerField(help_text='If width is set to "0" the image will be scaled to the supplied height.', verbose_name='width', default=0)),
('height', models.PositiveIntegerField(help_text='If height is set to "0" the image will be scaled to the supplied width', verbose_name='height', default=0)),
('quality', models.PositiveIntegerField(help_text='JPEG image quality.', verbose_name='quality', choices=[(30, 'Very Low'), (40, 'Low'), (50, 'Medium-Low'), (60, 'Medium'), (70, 'Medium-High'), (80, 'High'), (90, 'Very High')], default=70)),
('upscale', models.BooleanField(help_text='If selected the image will be scaled up if necessary to fit the supplied dimensions. Cropped sizes will be upscaled regardless of this setting.', verbose_name='upscale images?', default=False)),
('crop', models.BooleanField(help_text='If selected the image will be scaled and cropped to fit the supplied dimensions.', verbose_name='crop to fit?', default=False)),
('pre_cache', models.BooleanField(help_text='If selected this photo size will be pre-cached as photos are added.', verbose_name='pre-cache?', default=False)),
('increment_count', models.BooleanField(help_text='If selected the image\'s "view_count" will be incremented when this photo size is displayed.', verbose_name='increment view count?', default=False)),
('effect', models.ForeignKey(blank=True, verbose_name='photo effect', null=True, to='photologue.PhotoEffect', on_delete=models.CASCADE)),
],
options={
'verbose_name': 'photo size',
'ordering': ['width', 'height'],
'verbose_name_plural': 'photo sizes',
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Watermark',
fields=[
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)),
('name', models.CharField(max_length=30, verbose_name='name', unique=True)),
('description', models.TextField(blank=True, verbose_name='description')),
('image', models.ImageField(upload_to='photologue/watermarks', verbose_name='image')),
('style', models.CharField(max_length=5, default='scale', verbose_name='style', choices=[('tile', 'Tile'), ('scale', 'Scale')])),
('opacity', models.FloatField(help_text='The opacity of the overlay.', verbose_name='opacity', default=1)),
],
options={
'verbose_name': 'watermark',
'verbose_name_plural': 'watermarks',
},
bases=(models.Model,),
),
migrations.AddField(
model_name='photosize',
name='watermark',
field=models.ForeignKey(blank=True, verbose_name='watermark image', null=True, to='photologue.Watermark', on_delete=models.CASCADE),
preserve_default=True,
), ),
] ]

View file

@ -1,43 +0,0 @@
# encoding: utf8
from __future__ import unicode_literals
from django.db import migrations, models
def initial_photosizes(apps, schema_editor):
PhotoSize = apps.get_model('photologue', 'PhotoSize')
# If there are already Photosizes, then we are upgrading an existing
# installation, we don't want to auto-create some PhotoSizes.
if PhotoSize.objects.all().count() > 0:
return
PhotoSize.objects.create(name='admin_thumbnail',
width=100,
height=75,
crop=True,
pre_cache=True,
increment_count=False)
PhotoSize.objects.create(name='thumbnail',
width=100,
height=75,
crop=True,
pre_cache=True,
increment_count=False)
PhotoSize.objects.create(name='display',
width=400,
crop=False,
pre_cache=True,
increment_count=True)
class Migration(migrations.Migration):
dependencies = [
('photologue', '0001_initial'),
('contenttypes', '0002_remove_content_type_name'),
]
operations = [
migrations.RunPython(initial_photosizes),
]

View file

@ -1,19 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue', '0002_photosize_data'),
]
operations = [
migrations.AlterField(
model_name='galleryupload',
name='title',
field=models.CharField(null=True, help_text='All uploaded photos will be given a title made up of this title + a sequential number.', max_length=50, verbose_name='title', blank=True),
),
]

View file

@ -1,35 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sortedm2m.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue', '0003_auto_20140822_1716'),
]
operations = [
migrations.AlterField(
model_name='gallery',
name='photos',
field=sortedm2m.fields.SortedManyToManyField(to='photologue.Photo', related_name='galleries', null=True, verbose_name='photos', blank=True, help_text=None),
),
migrations.AlterField(
model_name='photo',
name='effect',
field=models.ForeignKey(to='photologue.PhotoEffect', blank=True, related_name='photo_related', verbose_name='effect', null=True, on_delete=models.CASCADE),
),
migrations.AlterField(
model_name='photosize',
name='effect',
field=models.ForeignKey(to='photologue.PhotoEffect', blank=True, related_name='photo_sizes', verbose_name='photo effect', null=True, on_delete=models.CASCADE),
),
migrations.AlterField(
model_name='photosize',
name='watermark',
field=models.ForeignKey(to='photologue.Watermark', blank=True, related_name='photo_sizes', verbose_name='watermark image', null=True, on_delete=models.CASCADE),
),
]

View file

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue', '0004_auto_20140915_1259'),
]
operations = [
migrations.AlterField(
model_name='photo',
name='title',
field=models.CharField(unique=True, max_length=60, verbose_name='title'),
preserve_default=True,
),
]

View file

@ -1,21 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue', '0005_auto_20141027_1552'),
]
operations = [
migrations.RemoveField(
model_name='galleryupload',
name='gallery',
),
migrations.DeleteModel(
name='GalleryUpload',
),
]

View file

@ -1,30 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sortedm2m.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue', '0006_auto_20141028_2005'),
]
operations = [
migrations.AlterField(
model_name='gallery',
name='photos',
field=sortedm2m.fields.SortedManyToManyField(help_text=None, related_name='galleries', verbose_name='photos', to='photologue.Photo', blank=True),
),
migrations.AlterField(
model_name='gallery',
name='sites',
field=models.ManyToManyField(to='sites.Site', verbose_name='sites', blank=True),
),
migrations.AlterField(
model_name='photo',
name='sites',
field=models.ManyToManyField(to='sites.Site', verbose_name='sites', blank=True),
),
]

View file

@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue', '0007_auto_20150404_1737'),
]
operations = [
migrations.RemoveField(
model_name='gallery',
name='tags',
),
migrations.RemoveField(
model_name='photo',
name='tags',
),
]

View file

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-01-02 09:04
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue', '0008_auto_20150509_1557'),
]
operations = [
migrations.AlterField(
model_name='photo',
name='date_taken',
field=models.DateTimeField(blank=True, help_text='Date image was taken; is obtained from the image EXIF data.', null=True, verbose_name='date taken'),
),
]

View file

@ -1,35 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-01-05 13:07
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue', '0009_auto_20160102_0904'),
]
operations = [
migrations.AlterField(
model_name='gallery',
name='slug',
field=models.SlugField(help_text='A "slug" is a unique URL-friendly title for an object.', max_length=250, unique=True, verbose_name='title slug'),
),
migrations.AlterField(
model_name='gallery',
name='title',
field=models.CharField(max_length=250, unique=True, verbose_name='title'),
),
migrations.AlterField(
model_name='photo',
name='slug',
field=models.SlugField(help_text='A "slug" is a unique URL-friendly title for an object.', max_length=250, unique=True, verbose_name='slug'),
),
migrations.AlterField(
model_name='photo',
name='title',
field=models.CharField(max_length=250, unique=True, verbose_name='title'),
),
]

View file

@ -1,18 +0,0 @@
# Generated by Django 2.1.7 on 2019-02-23 21:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue', '0010_auto_20160105_1307'),
]
operations = [
migrations.AlterField(
model_name='photoeffect',
name='filters',
field=models.CharField(blank=True, help_text='Chain multiple filters using the following pattern "FILTER_ONE->FILTER_TWO->FILTER_THREE". Image filters will be applied in order. The following filters are available: BLUR, CONTOUR, DETAIL, EDGE_ENHANCE, EDGE_ENHANCE_MORE, EMBOSS, FIND_EDGES, Kernel, SHARPEN, SMOOTH, SMOOTH_MORE.', max_length=200, verbose_name='filters'),
),
]

View file

@ -1,39 +0,0 @@
# Generated by Django 3.2.11 on 2022-01-29 22:07
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('photologue', '0011_auto_20190223_2138'),
]
operations = [
migrations.RemoveField(
model_name='gallery',
name='sites',
),
migrations.RemoveField(
model_name='photo',
name='effect',
),
migrations.RemoveField(
model_name='photo',
name='sites',
),
migrations.RemoveField(
model_name='photosize',
name='effect',
),
migrations.RemoveField(
model_name='photosize',
name='watermark',
),
migrations.DeleteModel(
name='PhotoEffect',
),
migrations.DeleteModel(
name='Watermark',
),
]

View file

@ -1,18 +0,0 @@
# Generated by Django 3.2.11 on 2022-01-30 07:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue', '0012_auto_20220129_2207'),
]
operations = [
migrations.AlterField(
model_name='gallery',
name='photos',
field=models.ManyToManyField(blank=True, related_name='galleries', to='photologue.Photo', verbose_name='photos'),
),
]

View file

@ -1,96 +0,0 @@
# Generated by Django 3.2.11 on 2022-01-30 08:32
import django.db.models.deletion
import django.utils.timezone
import taggit.managers
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.db import migrations, models
from django.template.defaultfilters import slugify
numens = User.objects.get(username="Numens").id
def migrate_related(apps, schema_editor):
Gallery = apps.get_model('photologue', 'Gallery')
Tag = apps.get_model('photologue', 'Tag')
TaggedItems = apps.get_model('taggit', 'TaggedItem')
ct_ext = ContentType.objects.get(app_label="photologue_custom", model="galleryextended")
for gallery in Gallery.objects.all():
tagged_items = TaggedItems.objects.filter(
content_type_id=ct_ext.id,
object_id=gallery.extended.id
)
tags = [tag.tag for tag in tagged_items.all()]
gallery.date_start = gallery.extended.date_start
gallery.date_end = gallery.extended.date_end
gallery.save()
for tag in tags:
try:
new_tag, created = Tag.objects.get_or_create(
name=tag.name.capitalize(),
slug=slugify(tag.name),
)
if new_tag not in gallery.tags.all():
gallery.tags.add(new_tag)
new_tag.save()
gallery.save()
except Exception:
continue
Photo = apps.get_model('photologue', 'Photo')
for photo in Photo.objects.all():
photo.owner = photo.extended.owner
photo.license = photo.extended.license
photo.save()
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('photologue', '0013_alter_gallery_photos'),
]
operations = [
migrations.CreateModel(
name='Tag',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=250, unique=True, verbose_name='name')),
('slug', models.SlugField(help_text='A "slug" is a unique URL-friendly title for an object.', max_length=250, unique=True, verbose_name='slug')),
],
options={
'verbose_name': 'tag',
'verbose_name_plural': 'tags',
'ordering': ['name'],
},
),
migrations.AddField(
model_name='gallery',
name='date_end',
field=models.DateField(blank=True, null=True, verbose_name='end date'),
),
migrations.AddField(
model_name='gallery',
name='date_start',
field=models.DateField(default=django.utils.timezone.now, verbose_name='start date'),
),
migrations.AddField(
model_name='photo',
name='license',
field=models.CharField(blank=True, max_length=255, verbose_name='license'),
),
migrations.AddField(
model_name='photo',
name='owner',
field=models.ForeignKey(default=numens, on_delete=django.db.models.deletion.CASCADE, to='auth.user', verbose_name='owner'),
preserve_default=False,
),
migrations.AddField(
model_name='gallery',
name='tags',
field=models.ManyToManyField(blank=True, related_name='galleries', to='photologue.Tag', verbose_name='tags'),
),
migrations.RunPython(migrate_related),
]

View file

@ -1,6 +0,0 @@
from django.apps import AppConfig
class PhotologueCustomConfig(AppConfig):
default_auto_field = 'django.db.models.AutoField'
name = 'photologue_custom'

View file

@ -1,44 +0,0 @@
# Generated by Django 2.2.24 on 2021-10-11 19:12
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import taggit.managers
class Migration(migrations.Migration):
initial = True
dependencies = [
('photologue', '0011_auto_20190223_2138'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('taggit', '0002_auto_20150616_2121'),
]
operations = [
migrations.CreateModel(
name='PhotoExtended',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='owner')),
('photo', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='extented', to='photologue.Photo')),
],
options={
'verbose_name': 'Extra fields',
'verbose_name_plural': 'Extra fields',
},
),
migrations.CreateModel(
name='GalleryExtended',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('gallery', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='extended', to='photologue.Gallery')),
('tags', taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')),
],
options={
'verbose_name': 'Extra fields',
'verbose_name_plural': 'Extra fields',
},
),
]

View file

@ -1,23 +0,0 @@
# Generated by Django 2.2.24 on 2021-10-11 19:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue_custom', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='galleryextended',
name='date_end',
field=models.DateField(blank=True, null=True, verbose_name='end date'),
),
migrations.AddField(
model_name='galleryextended',
name='date_start',
field=models.DateField(blank=True, null=True, verbose_name='start date'),
),
]

View file

@ -1,24 +0,0 @@
# Generated by Django 2.2.24 on 2021-10-13 15:07
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('photologue_custom', '0002_auto_20211011_1956'),
]
operations = [
migrations.AlterField(
model_name='galleryextended',
name='gallery',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='extended', to='photologue.Gallery'),
),
migrations.AlterField(
model_name='photoextended',
name='photo',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='extended', to='photologue.Photo'),
),
]

View file

@ -1,18 +0,0 @@
# Generated by Django 2.2.24 on 2021-10-22 16:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photologue_custom', '0003_auto_20211013_1507'),
]
operations = [
migrations.AddField(
model_name='photoextended',
name='license',
field=models.CharField(blank=True, max_length=255, verbose_name='license'),
),
]

View file

@ -1,27 +0,0 @@
# Generated by Django 3.2.11 on 2022-01-30 09:53
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('photologue_custom', '0004_photoextended_license'),
]
operations = [
migrations.RemoveField(
model_name='photoextended',
name='owner',
),
migrations.RemoveField(
model_name='photoextended',
name='photo',
),
migrations.DeleteModel(
name='GalleryExtended',
),
migrations.DeleteModel(
name='PhotoExtended',
),
]