Initial commit

This commit is contained in:
2024-08-27 20:33:44 +02:00
commit 1f1832267d
14794 changed files with 1599592 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
import taggit.managers
from django.conf import settings
from django.db import migrations, models
import wagtail.images.models
import wagtail.search.index
class Migration(migrations.Migration):
dependencies = [
("taggit", "0001_initial"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="Filter",
fields=[
(
"id",
models.AutoField(
primary_key=True,
serialize=False,
auto_created=True,
verbose_name="ID",
),
),
("spec", models.CharField(db_index=True, max_length=255)),
],
options={},
bases=(models.Model,),
),
migrations.CreateModel(
name="Image",
fields=[
(
"id",
models.AutoField(
primary_key=True,
serialize=False,
auto_created=True,
verbose_name="ID",
),
),
("title", models.CharField(verbose_name="Title", max_length=255)),
(
"file",
models.ImageField(
width_field="width",
upload_to=wagtail.images.models.get_upload_to,
verbose_name="File",
height_field="height",
),
),
("width", models.IntegerField(editable=False)),
("height", models.IntegerField(editable=False)),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"focal_point_x",
models.PositiveIntegerField(editable=False, null=True),
),
(
"focal_point_y",
models.PositiveIntegerField(editable=False, null=True),
),
(
"focal_point_width",
models.PositiveIntegerField(editable=False, null=True),
),
(
"focal_point_height",
models.PositiveIntegerField(editable=False, null=True),
),
(
"tags",
taggit.managers.TaggableManager(
verbose_name="Tags",
blank=True,
help_text=None,
to="taggit.Tag",
through="taggit.TaggedItem",
),
),
(
"uploaded_by_user",
models.ForeignKey(
on_delete=models.CASCADE,
editable=False,
blank=True,
null=True,
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"abstract": False,
},
bases=(models.Model, wagtail.search.index.Indexed),
),
migrations.CreateModel(
name="Rendition",
fields=[
(
"id",
models.AutoField(
primary_key=True,
serialize=False,
auto_created=True,
verbose_name="ID",
),
),
(
"file",
models.ImageField(
width_field="width", upload_to="images", height_field="height"
),
),
("width", models.IntegerField(editable=False)),
("height", models.IntegerField(editable=False)),
(
"focal_point_key",
models.CharField(editable=False, max_length=18, null=True),
),
(
"filter",
models.ForeignKey(
on_delete=models.CASCADE,
related_name="+",
to="wagtailimages.Filter",
),
),
(
"image",
models.ForeignKey(
on_delete=models.CASCADE,
related_name="renditions",
to="wagtailimages.Image",
),
),
],
options={},
bases=(models.Model,),
),
migrations.AlterUniqueTogether(
name="rendition",
unique_together={("image", "filter", "focal_point_key")},
),
]

View File

@@ -0,0 +1,269 @@
# Generated by Django 2.1.3 on 2018-11-20 22:22
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import taggit.managers
import wagtail.models
import wagtail.images.models
import wagtail.search.index
# Functions from wagtail.images.migrations.0002_initial_data
def add_image_permissions_to_admin_groups(apps, schema_editor):
ContentType = apps.get_model("contenttypes.ContentType")
Permission = apps.get_model("auth.Permission")
Group = apps.get_model("auth.Group")
# Get image permissions
image_content_type, _created = ContentType.objects.get_or_create(
model="image", app_label="wagtailimages"
)
add_image_permission, _created = Permission.objects.get_or_create(
content_type=image_content_type,
codename="add_image",
defaults={"name": "Can add image"},
)
change_image_permission, _created = Permission.objects.get_or_create(
content_type=image_content_type,
codename="change_image",
defaults={"name": "Can change image"},
)
delete_image_permission, _created = Permission.objects.get_or_create(
content_type=image_content_type,
codename="delete_image",
defaults={"name": "Can delete image"},
)
# Assign it to Editors and Moderators groups
for group in Group.objects.filter(name__in=["Editors", "Moderators"]):
group.permissions.add(
add_image_permission, change_image_permission, delete_image_permission
)
def remove_image_permissions(apps, schema_editor):
"""Reverse the above additions of permissions."""
ContentType = apps.get_model("contenttypes.ContentType")
Permission = apps.get_model("auth.Permission")
image_content_type = ContentType.objects.get(
model="image",
app_label="wagtailimages",
)
# This cascades to Group
Permission.objects.filter(
content_type=image_content_type,
codename__in=("add_image", "change_image", "delete_image"),
).delete()
# Functions from wagtail.images.migrations.0012_copy_image_permissions_to_collections
def get_image_permissions(apps):
# return a queryset of the 'add_image' and 'change_image' permissions
Permission = apps.get_model("auth.Permission")
ContentType = apps.get_model("contenttypes.ContentType")
image_content_type, _created = ContentType.objects.get_or_create(
model="image",
app_label="wagtailimages",
)
return Permission.objects.filter(
content_type=image_content_type, codename__in=["add_image", "change_image"]
)
def copy_image_permissions_to_collections(apps, schema_editor):
Collection = apps.get_model("wagtailcore.Collection")
Group = apps.get_model("auth.Group")
GroupCollectionPermission = apps.get_model("wagtailcore.GroupCollectionPermission")
root_collection = Collection.objects.get(depth=1)
for permission in get_image_permissions(apps):
for group in Group.objects.filter(permissions=permission):
GroupCollectionPermission.objects.create(
group=group, collection=root_collection, permission=permission
)
def remove_image_permissions_from_collections(apps, schema_editor):
GroupCollectionPermission = apps.get_model("wagtailcore.GroupCollectionPermission")
image_permissions = get_image_permissions(apps)
GroupCollectionPermission.objects.filter(permission__in=image_permissions).delete()
class Migration(migrations.Migration):
replaces = [
("wagtailimages", "0001_initial"),
("wagtailimages", "0002_initial_data"),
("wagtailimages", "0003_fix_focal_point_fields"),
("wagtailimages", "0004_make_focal_point_key_not_nullable"),
("wagtailimages", "0005_make_filter_spec_unique"),
("wagtailimages", "0006_add_verbose_names"),
("wagtailimages", "0007_image_file_size"),
("wagtailimages", "0008_image_created_at_index"),
("wagtailimages", "0009_capitalizeverbose"),
("wagtailimages", "0010_change_on_delete_behaviour"),
("wagtailimages", "0011_image_collection"),
("wagtailimages", "0012_copy_image_permissions_to_collections"),
("wagtailimages", "0013_make_rendition_upload_callable"),
("wagtailimages", "0014_add_filter_spec_field"),
("wagtailimages", "0015_fill_filter_spec_field"),
("wagtailimages", "0016_deprecate_rendition_filter_relation"),
("wagtailimages", "0017_reduce_focal_point_key_max_length"),
("wagtailimages", "0018_remove_rendition_filter"),
("wagtailimages", "0019_delete_filter"),
("wagtailimages", "0020_add-verbose-name"),
("wagtailimages", "0021_image_file_hash"),
]
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("wagtailcore", "0002_initial_data"),
("taggit", "0001_initial"),
("wagtailcore", "0026_group_collection_permission"),
]
operations = [
migrations.CreateModel(
name="Image",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("title", models.CharField(max_length=255, verbose_name="title")),
(
"file",
models.ImageField(
height_field="height",
upload_to=wagtail.images.models.get_upload_to,
verbose_name="file",
width_field="width",
),
),
("width", models.IntegerField(editable=False, verbose_name="width")),
("height", models.IntegerField(editable=False, verbose_name="height")),
(
"created_at",
models.DateTimeField(
auto_now_add=True, db_index=True, verbose_name="created at"
),
),
("focal_point_x", models.PositiveIntegerField(blank=True, null=True)),
("focal_point_y", models.PositiveIntegerField(blank=True, null=True)),
(
"focal_point_width",
models.PositiveIntegerField(blank=True, null=True),
),
(
"focal_point_height",
models.PositiveIntegerField(blank=True, null=True),
),
(
"tags",
taggit.managers.TaggableManager(
blank=True,
help_text=None,
through="taggit.TaggedItem",
to="taggit.Tag",
verbose_name="tags",
),
),
(
"uploaded_by_user",
models.ForeignKey(
blank=True,
editable=False,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
verbose_name="uploaded by user",
),
),
("file_size", models.PositiveIntegerField(editable=False, null=True)),
(
"collection",
models.ForeignKey(
default=wagtail.models.get_root_collection_id,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="wagtailcore.Collection",
verbose_name="collection",
),
),
(
"file_hash",
models.CharField(blank=True, editable=False, max_length=40),
),
],
options={
"abstract": False,
"verbose_name": "image",
"verbose_name_plural": "images",
},
bases=(models.Model, wagtail.search.index.Indexed),
),
migrations.CreateModel(
name="Rendition",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"file",
models.ImageField(
height_field="height",
upload_to=wagtail.images.models.get_rendition_upload_to,
width_field="width",
),
),
("width", models.IntegerField(editable=False)),
("height", models.IntegerField(editable=False)),
(
"focal_point_key",
models.CharField(
blank=True, default="", editable=False, max_length=16
),
),
("filter_spec", models.CharField(db_index=True, max_length=255)),
(
"image",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="renditions",
to="wagtailimages.Image",
),
),
],
),
migrations.AlterUniqueTogether(
name="rendition",
unique_together={("image", "filter_spec", "focal_point_key")},
),
migrations.RunPython(
add_image_permissions_to_admin_groups, remove_image_permissions
),
migrations.RunPython(
copy_image_permissions_to_collections,
remove_image_permissions_from_collections,
),
]

View File

@@ -0,0 +1,64 @@
from django.db import migrations
def add_image_permissions_to_admin_groups(apps, schema_editor):
ContentType = apps.get_model("contenttypes.ContentType")
Permission = apps.get_model("auth.Permission")
Group = apps.get_model("auth.Group")
# Get image permissions
image_content_type, _created = ContentType.objects.get_or_create(
model="image", app_label="wagtailimages"
)
add_image_permission, _created = Permission.objects.get_or_create(
content_type=image_content_type,
codename="add_image",
defaults={"name": "Can add image"},
)
change_image_permission, _created = Permission.objects.get_or_create(
content_type=image_content_type,
codename="change_image",
defaults={"name": "Can change image"},
)
delete_image_permission, _created = Permission.objects.get_or_create(
content_type=image_content_type,
codename="delete_image",
defaults={"name": "Can delete image"},
)
# Assign it to Editors and Moderators groups
for group in Group.objects.filter(name__in=["Editors", "Moderators"]):
group.permissions.add(
add_image_permission, change_image_permission, delete_image_permission
)
def remove_image_permissions(apps, schema_editor):
"""Reverse the above additions of permissions."""
ContentType = apps.get_model("contenttypes.ContentType")
Permission = apps.get_model("auth.Permission")
image_content_type = ContentType.objects.get(
model="image",
app_label="wagtailimages",
)
# This cascades to Group
Permission.objects.filter(
content_type=image_content_type,
codename__in=("add_image", "change_image", "delete_image"),
).delete()
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0001_initial"),
# Need to run wagtailcores initial data migration to make sure the groups are created
("wagtailcore", "0002_initial_data"),
]
operations = [
migrations.RunPython(
add_image_permissions_to_admin_groups, remove_image_permissions
),
]

View File

@@ -0,0 +1,37 @@
from django.db import migrations, models
class Migration(migrations.Migration):
"""
When the initial migration was created, the focal point fields on image
did not have blank=True set.
This migration fixes this.
"""
dependencies = [
("wagtailimages", "0002_initial_data"),
]
operations = [
migrations.AlterField(
model_name="image",
name="focal_point_height",
field=models.PositiveIntegerField(null=True, blank=True),
),
migrations.AlterField(
model_name="image",
name="focal_point_width",
field=models.PositiveIntegerField(null=True, blank=True),
),
migrations.AlterField(
model_name="image",
name="focal_point_x",
field=models.PositiveIntegerField(null=True, blank=True),
),
migrations.AlterField(
model_name="image",
name="focal_point_y",
field=models.PositiveIntegerField(null=True, blank=True),
),
]

View File

@@ -0,0 +1,47 @@
from django.db import migrations, models
def remove_duplicate_renditions(apps, schema_editor):
Rendition = apps.get_model("wagtailimages.Rendition")
# Find all filter_id / image_id pairings that appear multiple times in the renditions table
# with focal_point_key = NULL
duplicates = (
Rendition.objects.filter(focal_point_key__isnull=True)
.values("image_id", "filter_id")
.annotate(count_id=models.Count("id"), min_id=models.Min("id"))
.filter(count_id__gt=1)
)
# Delete all occurrences of those pairings, except for the one with the lowest ID
for duplicate in duplicates:
Rendition.objects.filter(
focal_point_key__isnull=True,
image=duplicate["image_id"],
filter=duplicate["filter_id"],
).exclude(id=duplicate["min_id"]).delete()
def reverse_remove_duplicate_renditions(*args, **kwargs):
"""This is a no-op. The migration removes duplicates, we cannot recreate those duplicates."""
pass
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0003_fix_focal_point_fields"),
]
operations = [
migrations.RunPython(
remove_duplicate_renditions, reverse_remove_duplicate_renditions
),
migrations.AlterField(
model_name="rendition",
name="focal_point_key",
field=models.CharField(
blank=True, default="", max_length=18, editable=False
),
),
]

View File

@@ -0,0 +1,17 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0004_make_focal_point_key_not_nullable"),
]
operations = [
migrations.AlterField(
model_name="filter",
name="spec",
field=models.CharField(unique=True, max_length=255),
preserve_default=True,
),
]

View File

@@ -0,0 +1,39 @@
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0005_make_filter_spec_unique"),
]
operations = [
migrations.AlterField(
model_name="image",
name="created_at",
field=models.DateTimeField(auto_now_add=True, verbose_name="Created at"),
),
migrations.AlterField(
model_name="image",
name="height",
field=models.IntegerField(verbose_name="Height", editable=False),
),
migrations.AlterField(
model_name="image",
name="uploaded_by_user",
field=models.ForeignKey(
on_delete=models.CASCADE,
blank=True,
editable=False,
to=settings.AUTH_USER_MODEL,
null=True,
verbose_name="Uploaded by user",
),
),
migrations.AlterField(
model_name="image",
name="width",
field=models.IntegerField(verbose_name="Width", editable=False),
),
]

View File

@@ -0,0 +1,16 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0006_add_verbose_names"),
]
operations = [
migrations.AddField(
model_name="image",
name="file_size",
field=models.PositiveIntegerField(editable=False, null=True),
),
]

View File

@@ -0,0 +1,18 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0007_image_file_size"),
]
operations = [
migrations.AlterField(
model_name="image",
name="created_at",
field=models.DateTimeField(
db_index=True, verbose_name="Created at", auto_now_add=True
),
),
]

View File

@@ -0,0 +1,70 @@
import taggit.managers
from django.conf import settings
from django.db import migrations, models
import wagtail.images.models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0008_image_created_at_index"),
]
operations = [
migrations.AlterField(
model_name="image",
name="created_at",
field=models.DateTimeField(
auto_now_add=True, db_index=True, verbose_name="created at"
),
),
migrations.AlterField(
model_name="image",
name="file",
field=models.ImageField(
upload_to=wagtail.images.models.get_upload_to,
height_field="height",
width_field="width",
verbose_name="file",
),
),
migrations.AlterField(
model_name="image",
name="height",
field=models.IntegerField(editable=False, verbose_name="height"),
),
migrations.AlterField(
model_name="image",
name="tags",
field=taggit.managers.TaggableManager(
through="taggit.TaggedItem",
verbose_name="tags",
blank=True,
help_text=None,
to="taggit.Tag",
),
),
migrations.AlterField(
model_name="image",
name="title",
field=models.CharField(max_length=255, verbose_name="title"),
),
migrations.AlterField(
model_name="image",
name="uploaded_by_user",
field=models.ForeignKey(
on_delete=models.CASCADE,
blank=True,
null=True,
to=settings.AUTH_USER_MODEL,
editable=False,
verbose_name="uploaded by user",
),
),
migrations.AlterField(
model_name="image",
name="width",
field=models.IntegerField(editable=False, verbose_name="width"),
),
]

View File

@@ -0,0 +1,25 @@
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0009_capitalizeverbose"),
]
operations = [
migrations.AlterField(
model_name="image",
name="uploaded_by_user",
field=models.ForeignKey(
on_delete=django.db.models.deletion.SET_NULL,
blank=True,
editable=False,
to=settings.AUTH_USER_MODEL,
null=True,
verbose_name="uploaded by user",
),
),
]

View File

@@ -0,0 +1,25 @@
from django.db import migrations, models
import wagtail.models
class Migration(migrations.Migration):
dependencies = [
("wagtailcore", "0026_group_collection_permission"),
("wagtailimages", "0010_change_on_delete_behaviour"),
]
operations = [
migrations.AddField(
model_name="image",
name="collection",
field=models.ForeignKey(
to="wagtailcore.Collection",
verbose_name="collection",
default=wagtail.models.get_root_collection_id,
related_name="+",
on_delete=models.CASCADE,
),
),
]

View File

@@ -0,0 +1,51 @@
from django.db import migrations
def get_image_permissions(apps):
# return a queryset of the 'add_image' and 'change_image' permissions
Permission = apps.get_model("auth.Permission")
ContentType = apps.get_model("contenttypes.ContentType")
image_content_type, _created = ContentType.objects.get_or_create(
model="image",
app_label="wagtailimages",
)
return Permission.objects.filter(
content_type=image_content_type, codename__in=["add_image", "change_image"]
)
def copy_image_permissions_to_collections(apps, schema_editor):
Collection = apps.get_model("wagtailcore.Collection")
Group = apps.get_model("auth.Group")
GroupCollectionPermission = apps.get_model("wagtailcore.GroupCollectionPermission")
root_collection = Collection.objects.get(depth=1)
for permission in get_image_permissions(apps):
for group in Group.objects.filter(permissions=permission):
GroupCollectionPermission.objects.create(
group=group, collection=root_collection, permission=permission
)
def remove_image_permissions_from_collections(apps, schema_editor):
GroupCollectionPermission = apps.get_model("wagtailcore.GroupCollectionPermission")
image_permissions = get_image_permissions(apps)
GroupCollectionPermission.objects.filter(permission__in=image_permissions).delete()
class Migration(migrations.Migration):
dependencies = [
("wagtailcore", "0026_group_collection_permission"),
("wagtailimages", "0011_image_collection"),
]
operations = [
migrations.RunPython(
copy_image_permissions_to_collections,
remove_image_permissions_from_collections,
),
]

View File

@@ -0,0 +1,21 @@
from django.db import models, migrations
import wagtail.images.models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0012_copy_image_permissions_to_collections"),
]
operations = [
migrations.AlterField(
model_name="rendition",
name="file",
field=models.ImageField(
upload_to=wagtail.images.models.get_rendition_upload_to,
width_field="width",
height_field="height",
),
),
]

View File

@@ -0,0 +1,31 @@
# Generated by Django 1.10 on 2016-08-11 12:03
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0013_make_rendition_upload_callable"),
]
operations = [
migrations.AddField(
model_name="rendition",
name="filter_spec",
field=models.CharField(
blank=True, db_index=True, default="", max_length=255
),
),
migrations.AlterField(
model_name="rendition",
name="filter",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="wagtailimages.Filter",
),
),
]

View File

@@ -0,0 +1,16 @@
# Generated by Django 1.10 on 2016-08-11 13:25
from django.db import migrations
from wagtail.images.utils import get_fill_filter_spec_migrations
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0014_add_filter_spec_field"),
]
forward, reverse = get_fill_filter_spec_migrations("wagtailimages", "Rendition")
operations = [
migrations.RunPython(forward, reverse),
]

View File

@@ -0,0 +1,54 @@
# Generated by Django 1.9.11 on 2016-11-11 17:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0015_fill_filter_spec_field"),
]
operations = [
migrations.AlterField(
model_name="rendition",
name="filter_spec",
field=models.CharField(db_index=True, max_length=255),
),
# New step introduced in Wagtail 1.8.1:
#
# Reduce max_length of rendition.focal_point_key to 16, from the previous value of 255
# which existed on Wagtail <= 1.8. MySQL has a limit of 767 (on InnoDB) or 1000 (on MyISAM)
# bytes; depending on the character encoding used, this limit may be reached by the
# original index on ['image', 'filter', 'focal_point_key'] (= 1 varchar and two FKs)
# or the new index on ['image', 'filter_spec', 'focal_point_key'] (= 2 varchars and one FK).
#
# To mitigate this, we reduce focal_point_key in the following places:
# * Retrospectively in the original migration, so that configurations that previously
# failed on wagtailimages/0001_initial can now run (see #2925 / #2953);
# * Here, so that previously-working Wagtail <=1.7 installations that failed on the
# AlterUniqueTogether below when upgrading to 1.8 can now succeed;
# * In the newly-added migration wagtailimages/0017, so that existing Wagtail 1.8 installations
# that successfully applied the old 1.8 version of this migration are consistent with
# other setups.
#
# Since Django will optimise away any AlterField operations that appear to match
# the current state (according to earlier migrations) - which would cause them to be
# skipped on installations that ran the earlier (max_length=255) versions of the
# migrations - we need to make them superficially different; we do this by stepping
# max_length down from 18 to 17 then 16.
#
# Projects with a custom image model don't have to worry about this - they'll have an existing
# migration with the max_length=255, and will get a new migration reducing it to max_length=16
# the next time they run makemigrations.
migrations.AlterField(
model_name="rendition",
name="focal_point_key",
field=models.CharField(
blank=True, default="", max_length=17, editable=False
),
),
migrations.AlterUniqueTogether(
name="rendition",
unique_together={("image", "filter_spec", "focal_point_key")},
),
]

View File

@@ -0,0 +1,23 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0016_deprecate_rendition_filter_relation"),
]
operations = [
# The Wagtail 1.8 version of migration wagtailimages/0016 did not include the
# step to reduce focal_point_key's max_length to 16, necessary to make it work
# on some MySQL configurations. This migration (added in 1.8.1) ensures that
# installations that were already successfully running 1.8 receive this change
# on upgrading to 1.8.1 or later.
migrations.AlterField(
model_name="rendition",
name="focal_point_key",
field=models.CharField(
blank=True, default="", max_length=16, editable=False
),
),
]

View File

@@ -0,0 +1,16 @@
# Generated by Django 1.10.4 on 2016-12-16 17:15
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0017_reduce_focal_point_key_max_length"),
]
operations = [
migrations.RemoveField(
model_name="rendition",
name="filter",
),
]

View File

@@ -0,0 +1,15 @@
# Generated by Django 1.10.5 on 2017-02-08 23:51
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0018_remove_rendition_filter"),
]
operations = [
migrations.DeleteModel(
name="Filter",
),
]

View File

@@ -0,0 +1,17 @@
# Generated by Django 2.0.3 on 2018-03-17 17:29
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0019_delete_filter"),
]
operations = [
migrations.AlterModelOptions(
name="image",
options={"verbose_name": "image", "verbose_name_plural": "images"},
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 2.0.4 on 2018-05-04 15:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0020_add-verbose-name"),
]
operations = [
migrations.AddField(
model_name="image",
name="file_hash",
field=models.CharField(blank=True, editable=False, max_length=40),
),
]

View File

@@ -0,0 +1,45 @@
# Generated by Django 2.2 on 2019-04-30 10:09
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("wagtailimages", "0001_squashed_0021"),
]
operations = [
migrations.CreateModel(
name="UploadedImage",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"file",
models.ImageField(max_length=200, upload_to="uploaded_images"),
),
(
"uploaded_by_user",
models.ForeignKey(
blank=True,
editable=False,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
verbose_name="uploaded by user",
),
),
],
),
]

View File

@@ -0,0 +1,101 @@
# Generated by Django 3.1.2 on 2020-10-13 22:43
from django.db import migrations
def add_choose_permission_to_admin_groups(apps, _schema_editor):
ContentType = apps.get_model("contenttypes.ContentType")
Permission = apps.get_model("auth.Permission")
Group = apps.get_model("auth.Group")
# Get image content type
image_content_type, _created = ContentType.objects.get_or_create(
model="image", app_label="wagtailimages"
)
# Create the Choose permission (if it doesn't already exist)
choose_image_permission, _created = Permission.objects.get_or_create(
content_type=image_content_type,
codename="choose_image",
defaults={"name": "Can choose image"},
)
# Assign it to all groups which have "Access the Wagtail admin" permission.
# This emulates the previous behaviour, where everyone could choose any image in any Collection
# because choosing wasn't permissioned.
for group in Group.objects.filter(permissions__codename="access_admin"):
group.permissions.add(choose_image_permission)
def remove_choose_permission(apps, _schema_editor):
"""Reverse the above additions of permissions."""
ContentType = apps.get_model("contenttypes.ContentType")
Permission = apps.get_model("auth.Permission")
image_content_type = ContentType.objects.get(
model="image",
app_label="wagtailimages",
)
# This cascades to Group
Permission.objects.filter(
content_type=image_content_type, codename="choose_image"
).delete()
def get_choose_permission(apps):
Permission = apps.get_model("auth.Permission")
ContentType = apps.get_model("contenttypes.ContentType")
image_content_type, _created = ContentType.objects.get_or_create(
model="image",
app_label="wagtailimages",
)
return Permission.objects.filter(
content_type=image_content_type, codename__in=["choose_image"]
).first()
def copy_choose_permission_to_collections(apps, _schema_editor):
Collection = apps.get_model("wagtailcore.Collection")
Group = apps.get_model("auth.Group")
GroupCollectionPermission = apps.get_model("wagtailcore.GroupCollectionPermission")
root_collection = Collection.objects.get(depth=1)
permission = get_choose_permission(apps)
if permission:
for group in Group.objects.filter(permissions=permission):
GroupCollectionPermission.objects.create(
group=group, collection=root_collection, permission=permission
)
def remove_choose_permission_from_collections(apps, _schema_editor):
GroupCollectionPermission = apps.get_model("wagtailcore.GroupCollectionPermission")
choose_permission = get_choose_permission(apps)
if choose_permission:
GroupCollectionPermission.objects.filter(permission=choose_permission).delete()
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0022_uploadedimage"),
]
operations = [
migrations.AlterModelOptions(
name="image",
options={
"permissions": [("choose_image", "Can choose image")],
"verbose_name": "image",
"verbose_name_plural": "images",
},
),
migrations.RunPython(
add_choose_permission_to_admin_groups, remove_choose_permission
),
migrations.RunPython(
copy_choose_permission_to_collections,
remove_choose_permission_from_collections,
),
]

View File

@@ -0,0 +1,20 @@
# Generated by Django 4.0.3 on 2022-04-06 15:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0023_add_choose_permissions"),
]
operations = [
migrations.AlterField(
model_name="image",
name="file_hash",
field=models.CharField(
blank=True, db_index=True, editable=False, max_length=40
),
),
]

View File

@@ -0,0 +1,43 @@
# Generated by Django 4.0.7 on 2022-08-10 16:26
from django import VERSION as DJANGO_VERSION
from django.db import migrations
import wagtail.images.models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0024_index_image_file_hash"),
]
rendition_file_options = {
"height_field": "height",
"upload_to": wagtail.images.models.get_rendition_upload_to,
"width_field": "width",
}
# See https://code.djangoproject.com/ticket/34192 - prior to Django 4.2, a callable storage
# argument that returns default_storage would be incorrectly omitted from the deconstructed
# field. We need to match that behaviour and include/omit it accordingly to prevent
# makemigrations from seeing a difference and generating a spurious migration in
# wagtail.images.
if DJANGO_VERSION >= (4, 2):
rendition_file_options["storage"] = wagtail.images.models.get_rendition_storage
operations = [
migrations.AlterField(
model_name="image",
name="file",
field=wagtail.images.models.WagtailImageField(
height_field="height",
upload_to=wagtail.images.models.get_upload_to,
verbose_name="file",
width_field="width",
),
),
migrations.AlterField(
model_name="rendition",
name="file",
field=wagtail.images.models.WagtailImageField(**rendition_file_options),
),
]

View File

@@ -0,0 +1,16 @@
# Generated by Django 5.0.1 on 2024-01-30 18:19
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('wagtailimages', '0025_alter_image_file_alter_rendition_file'),
]
operations = [
migrations.DeleteModel(
name='UploadedImage',
),
]