-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update wagtail 6.3 #1161
Merged
Merged
Update wagtail 6.3 #1161
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
563e0d0
Updates Wagtail to 6.3.1
SaptakS 68607f4
Uploads devdata images from local fixtures
SaptakS 76769b8
Fixes tests related to image createdevdata
SaptakS cbcbbcb
Cleanup and remove copy view from ScanResultAdmin
SaptakS aea063d
Updates wagtail to 6.3.2
SaptakS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"model": "wagtailcore.collection", "pk": 1, "fields": {"path": "0001", "depth": 1, "numchild": 1, "name": "Root"}}, {"model": "wagtailcore.collection", "pk": 2, "fields": {"path": "00010001", "depth": 2, "numchild": 0, "name": "Animals"}}, {"model": "auth.user", "pk": 1, "fields": {"password": "pbkdf2_sha256$600000$kx8DzpGJkP0nEG6wVed3y7$I969toMhIV/959lCM2Gf3PvmJ1cgj5YqqbEtOq+v/Z8=", "last_login": "2024-07-25T21:02:32.035Z", "is_superuser": true, "username": "test", "first_name": "", "last_name": "", "email": "[email protected]", "is_staff": true, "is_active": true, "date_joined": "2024-07-25T21:02:16.045Z", "groups": [], "user_permissions": []}}, {"model": "common.customimage", "pk": 1, "fields": {"collection": 2, "title": "Bat", "file": "original_images/Bat.jpg", "width": 1920, "height": 2880, "created_at": "2024-07-25T21:04:26.730Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 694750, "file_hash": "77611f00f02085cd0d72344fd487c1fee8698dd8"}}, {"model": "common.customimage", "pk": 2, "fields": {"collection": 2, "title": "Bee", "file": "original_images/Bee.jpg", "width": 1920, "height": 2763, "created_at": "2024-07-25T21:04:27.015Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 506073, "file_hash": "8c30ce2d47fd9278348175057c20c5a684ea6d44"}}, {"model": "common.customimage", "pk": 3, "fields": {"collection": 2, "title": "Orange and white butterfly", "file": "original_images/Butterfly1.jpg", "width": 1920, "height": 1202, "created_at": "2024-07-25T21:04:27.254Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 395401, "file_hash": "918bd1a5405ae19f77c904682a7840227a8707a7"}}, {"model": "common.customimage", "pk": 4, "fields": {"collection": 2, "title": "Tiger swallowtail butterfly", "file": "original_images/Butterfly2.jpg", "width": 1920, "height": 1920, "created_at": "2024-07-25T21:04:27.593Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 987922, "file_hash": "2f15f86f39c15065bb6e0b35d81465fe4bd4ef34"}}, {"model": "common.customimage", "pk": 5, "fields": {"collection": 2, "title": "Cat 1", "file": "original_images/Cat1.jpg", "width": 1920, "height": 1280, "created_at": "2024-07-25T21:04:27.743Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 266960, "file_hash": "2b14c7df6f5a254cb36afa304a248f748c2b47b4"}}, {"model": "common.customimage", "pk": 6, "fields": {"collection": 2, "title": "Cows", "file": "original_images/Cows.jpg", "width": 1920, "height": 1280, "created_at": "2024-07-25T21:04:27.878Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 211828, "file_hash": "6739faaed6a412045eaf19fd1b2ec135f66b622d"}}, {"model": "common.customimage", "pk": 7, "fields": {"collection": 2, "title": "Dog 1", "file": "original_images/Dog1.jpg", "width": 1920, "height": 1280, "created_at": "2024-07-25T21:04:28.048Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 430534, "file_hash": "7e854d6d408a5e7ab74b4702febf21e618ab790a"}}, {"model": "common.customimage", "pk": 8, "fields": {"collection": 2, "title": "Hedgehog", "file": "original_images/Hedgehog.jpg", "width": 1920, "height": 2880, "created_at": "2024-07-25T21:04:28.401Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 733684, "file_hash": "bb8e0bab06cd777acfb741284823e91ab877bc4c"}}, {"model": "common.customimage", "pk": 9, "fields": {"collection": 2, "title": "Jellyfish", "file": "original_images/Jellyfish.jpg", "width": 1920, "height": 2621, "created_at": "2024-07-25T21:04:28.692Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 662525, "file_hash": "f2cf9f88aa80c8f284b9c455636d60c7f06475d9"}}, {"model": "common.customimage", "pk": 10, "fields": {"collection": 2, "title": "Pig 1", "file": "original_images/Pig1.jpg", "width": 1920, "height": 2560, "created_at": "2024-07-25T21:04:29.027Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 1020197, "file_hash": "aee3b8bcc5378d4ad651c8e56556769675088bc0"}}, {"model": "common.customimage", "pk": 11, "fields": {"collection": 2, "title": "Red Panda", "file": "original_images/RedPanda.jpg", "width": 1920, "height": 1280, "created_at": "2024-07-25T21:04:29.207Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 423331, "file_hash": "e1e653999ac9eeb722f2071f5dd1d7a6e6441bcf"}}, {"model": "common.customimage", "pk": 12, "fields": {"collection": 2, "title": "Squirrel", "file": "original_images/Squirrel.jpg", "width": 1920, "height": 1280, "created_at": "2024-07-25T21:04:29.388Z", "uploaded_by_user": ["test"], "focal_point_x": null, "focal_point_y": null, "focal_point_width": null, "focal_point_height": null, "file_size": 560578, "file_hash": "e4f0f622b4ece26744873f0d3ec056632fb609cb"}}] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
import requests | ||
import time | ||
import os | ||
|
||
from wagtail.models import Page, Site | ||
from django.core.exceptions import ObjectDoesNotExist | ||
from django.contrib.auth.models import User | ||
from django.core.files.base import ContentFile | ||
from django.core.files.storage import FileSystemStorage, default_storage | ||
from django.core.management import call_command | ||
from django.core.files.images import ImageFile | ||
from django.core.management.base import BaseCommand | ||
from django.db import transaction | ||
from django.core import management | ||
import factory | ||
import wagtail_factories | ||
|
||
from common.models import SocialSharingSEOSettings, CustomImage | ||
from common.factories import CustomImageFactory | ||
from home.models import HomePage | ||
from home.tests.factories import HomePageFactory | ||
|
||
|
@@ -22,12 +19,6 @@ class Command(BaseCommand): | |
help = 'Creates data appropriate for development' | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
'--no-download', | ||
action='store_false', | ||
dest='download_images', | ||
help='Download external images', | ||
) | ||
parser.add_argument( | ||
'--delete', | ||
action='store_true', | ||
|
@@ -36,21 +27,18 @@ def add_arguments(self, parser): | |
help='Delete homepage and child pages before creating new data.', | ||
) | ||
|
||
def fetch_image(self, width, height, collection, category): | ||
url = f'https://source.unsplash.com/{width}x{height}?{category}' | ||
response = requests.get(url, timeout=5) | ||
if response and response.content: | ||
CustomImageFactory( | ||
file__from_file=ContentFile(response.content), | ||
file_size=len(response.content), | ||
width=width, | ||
height=height, | ||
collection=collection, | ||
) | ||
else: | ||
return False | ||
time.sleep(0.2) | ||
return True | ||
def _copy_files(self, local_storage, path): | ||
""" | ||
Recursively copy files from local_storage to default_storage. | ||
""" | ||
directories, file_names = local_storage.listdir(path) | ||
print(directories) | ||
print(file_names) | ||
for directory in directories: | ||
self._copy_files(local_storage, path + directory + "/") | ||
for file_name in file_names: | ||
with local_storage.open(path + file_name) as file_: | ||
default_storage.save(path + file_name, file_) | ||
|
||
@transaction.atomic | ||
def handle(self, *args, **options): | ||
|
@@ -93,28 +81,13 @@ def handle(self, *args, **options): | |
site.save() | ||
|
||
# IMAGES | ||
icon_collection = wagtail_factories.CollectionFactory(name='Icons') | ||
|
||
if options.get('download_images', True): | ||
self.stdout.write('Fetching images') | ||
self.stdout.flush() | ||
image_fail = False | ||
for i in range(15): | ||
if not self.fetch_image(500, 500, icon_collection, 'animals'): | ||
image_fail = True | ||
if image_fail: | ||
self.stdout.write(self.style.NOTICE('NOTICE: Some images failed to save')) | ||
else: | ||
self.stdout.write(self.style.SUCCESS('OK')) | ||
else: | ||
faker = factory.faker.Faker._get_faker(locale='en-US') | ||
for i in range(20): | ||
CustomImageFactory.create( | ||
file__width=500, | ||
file__height=500, | ||
file__color=faker.safe_color_name(), | ||
collection=icon_collection, | ||
) | ||
fixtures_dir = os.path.join("common", "fixtures") | ||
fixture_file = os.path.join(fixtures_dir, "devdata.json") | ||
self.stdout.write("Copying media files...") | ||
local_storage = FileSystemStorage(os.path.join(fixtures_dir, "media")) | ||
self._copy_files(local_storage, "") | ||
call_command("loaddata", fixture_file, verbosity=4) | ||
print(CustomImage.objects.all()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleanup: print call can be removed. |
||
|
||
management.call_command('createblogdata', '10') | ||
management.call_command('createdirectory', '10') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2.17 on 2024-12-27 13:13 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('common', '0009_alter_customimage_file_alter_customrendition_file'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='customimage', | ||
name='description', | ||
field=models.CharField(blank=True, default='', max_length=255, verbose_name='description'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup: print calls can be removed.