Skip to content
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

Revise model fields and asset file check/download logic #19

Merged
merged 20 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4e3ea5a
Allow 'bynder_id' to be null (projects need to be able to use the ima…
ababic Apr 5, 2024
3ff846f
Remove 'metadata' field and related setter logic
ababic Apr 4, 2024
40a955d
Replace 'bynder_original_filename' with 'source_filename' and add 'or…
ababic Apr 4, 2024
2779200
Update file download/update logic:
ababic Apr 4, 2024
91049d6
Ensure 'filesize' and ‘file_hash’ fields are updated when an image or…
ababic Apr 4, 2024
59ee2f0
Replace download_document() and download_image() with a single downlo…
ababic Apr 4, 2024
c35efa7
Remove unused 'bynder_id_hash' field
ababic Apr 4, 2024
db6f611
Force inheritance of Meta from Wagtail models
ababic Apr 5, 2024
57d971d
Mark video model labels for translation
ababic Apr 5, 2024
8d66c32
Raise a custom exception when there is some kind of issue with Bynder…
ababic Apr 5, 2024
3c708c1
Add migrations
ababic Apr 5, 2024
bb6a495
Update get_test_asset_data() to provide more realistic representation…
ababic Apr 5, 2024
ed01be1
Add tests for model logic
ababic Apr 5, 2024
77e2a0a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 6, 2024
17489ba
Update derivative setting defaults to reflect advice in README and va…
ababic Apr 10, 2024
2ded683
Regenerate test migrations from scratch
ababic Apr 10, 2024
99da4e3
Placate ruff
ababic Apr 10, 2024
e6ffe16
Update changelog
ababic Apr 10, 2024
7051925
Fix taggit migration dependency issue
ababic Apr 10, 2024
84c56c5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Added

- Added `source_filename` and `original_filesize` fields to all base models, and updated `update_from_asset_data()` to set them accordingly.
- Added `original_height` and `original_width` fields to image and video base models, and updated `update_from_asset_data()` to set them accordingly.
- Added "What to ask of Bynder" section to `README.md`.
- Improved test coverage

### Removed

- Removed the `metadata` field from all base models, along with `directly_mapped_bynder_fields` attributes, and the `extract_relevant_metadata()` method used for setting the field value during an update.
- Removed the `bynder_original_filename` field from all base models. This has now been succeeded by `source_filename`, which stores a value more relevant to each type.
- Removed the `bynder_id_hash` field from all base models.
- Removed the `download_asset_file()` method from all base models. The responsibility for downloading assets now falls to the `update_file()` method (applies to image and document models only).

### Changed

- The `bynder_id` field on all base models now supports `null` values, allowing a mix of images/documents from different sources to be added to be saved.
- Fixed an issue with `file_hash` and `file_size` fields not being set correctly when a model instance is created or updated to reflect Bynder asset data.
- Updated `asset_file_has_changed()` implementations on all models to take into account values from new `source_filename`, `original_filesize`, `original_height` and `original_width` model fields.
- Consistently raise `wagtail_bynder.exceptions.BynderAssetDataError` (instead of `django.core.exceptions.ImproperlyConfigured` or `KeyError`) when API representations from Bynder do not contain data required for the integration to work properly.
- Changed the default `BYNDER_VIDEO_PRIMARY_DERIVATIVE_NAME` setting value from `"Web-Primary"` to `"WebPrimary"` to reflect new guidance in `README.md`.
- Changed the default `BYNDER_VIDEO_FALLBACK_DERIVATIVE_NAME` setting value from `"Web-Fallback"` to `"WebFallback"` to reflect new guidance in `README.md`.
- Changed the default `BYNDER_IMAGE_SOURCE_THUMBNAIL_NAME` setting value from `"webimage"` to `"WagtailSource"` to reflect new guidance in `README.md`.

## [0.2] - 2024-02-25

### Added
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ and only needs to have basic read permissions.

### `BYNDER_IMAGE_SOURCE_THUMBNAIL_NAME`

Example: `"WagtailSource"`

Default: `"webimage"`
Default: `"WagtailSource"`

The name of the automatically generated derivative that should be downloaded and used as the `file` value for the
representative Wagtail image (as it appears in `thumbnails` in the API representation).
Expand All @@ -263,11 +261,11 @@ Default: `None`

### `BYNDER_VIDEO_PRIMARY_DERIVATIVE_NAME`

Default: `"Web-Primary"`
Default: `"WebPrimary"`

### `BYNDER_VIDEO_FALLBACK_DERIVATIVE_NAME`

Default: `"Web-Fallback"`
Default: `"WebFallback"`

### `BYNDER_VIDEO_POSTER_IMAGE_DERIVATIVE_NAME`

Expand Down
5 changes: 5 additions & 0 deletions src/wagtail_bynder/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class BynderAssetDataError(Exception):
"""
Raised when values expected to be present in an asset API representation
from Bynder are missing.
"""
Loading