Skip to content

Commit

Permalink
SDAAP-83 Update to a story published with Crops not matching the image (
Browse files Browse the repository at this point in the history
  • Loading branch information
marwoodandrew authored Aug 13, 2023
1 parent 6784c03 commit 5bb69b7
Show file tree
Hide file tree
Showing 2 changed files with 260 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/archive/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,13 @@ def _handle_media_updates(self, updates, original, user):

item_id = item_obj[config.ID_FIELD]
media_item = self.find_one(req=None, _id=item_id)
if app.settings.get("COPY_METADATA_FROM_PARENT") and item_obj.get(ITEM_TYPE) in MEDIA_TYPES:
stored_item = (original.get(ASSOCIATIONS) or {}).get(item_name) or item_obj
parent = (original.get(ASSOCIATIONS) or {}).get(item_name) or item_obj
if (
app.settings.get("COPY_METADATA_FROM_PARENT")
and item_obj.get(ITEM_TYPE) in MEDIA_TYPES
and item_id == parent.get(config.ID_FIELD)
):
stored_item = parent
else:
stored_item = media_item
if not stored_item:
Expand Down
253 changes: 253 additions & 0 deletions features/archive.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1285,3 +1285,256 @@ Feature: News Items Archive
}
}
"""

@auth
@vocabulary
Scenario: Update feature media with different item and copy metadata flag
Given "archive"
"""
[
{
"guid": "tag:example.com,0000:newsml_BRE9A605",
"associations": {
"featuremedia": {
"_id": "urn:newsml:localhost:5000:2018-12-14T11:31:26.088056:5c45850b-2985-42b3-9ae3-a42ad3c3bc28",
"media": "5c13867efe985edfc9223480",
"type": "picture",
"format": "HTML",
"renditions": {
"original": {
"href": "http://localhost:5000/api/upload-raw/orig.jpg",
"media": "orig",
"mimetype": "image/jpeg",
"width": 4032,
"height": 3024,
"poi": {
"x": 3024,
"y": 756
}
},
"baseImage": {
"href": "http://localhost:5000/api/upload-raw/baseImage.jpg",
"media": "baseImage",
"mimetype": "image/jpeg",
"width": 1400,
"height": 1050,
"poi": {
"x": 1050,
"y": 262
}
},
"thumbnail": {
"href": "http://localhost:5000/api/upload-raw/thumbnail.jpg",
"media": "thumbnail",
"mimetype": "image/jpeg",
"width": 160,
"height": 120,
"poi": {
"x": 120,
"y": 30
}
},
"viewImage": {
"href": "http://localhost:5000/api/upload-raw/viewImage.jpg",
"media": "viewImage",
"mimetype": "image/jpeg",
"width": 640,
"height": 480,
"poi": {
"x": 480,
"y": 120
}
},
"4-3": {
"poi": {
"x": 3012,
"y": 759
},
"CropLeft": 12,
"CropRight": 4032,
"CropTop": -3,
"CropBottom": 3024,
"width": 800,
"height": 600,
"href": "http://localhost:5000/api/upload-raw/600x800.jpg",
"media": "600x800",
"mimetype": "image/jpeg"
}
}
}
}
},
{
"_id": "urn:newsml:localhost:5000:2018-12-14T11:31:26.088056:5c45850b-2985-42b3-9ae3-new",
"type": "picture",
"format": "HTML",
"renditions": {
"original": {
"href": "http://localhost:5000/api/upload-raw/orig_new.jpg",
"media": "orig",
"mimetype": "image/jpeg",
"width": 4032,
"height": 3024,
"poi": {
"x": 3024,
"y": 756
}
},
"baseImage": {
"href": "http://localhost:5000/api/upload-raw/baseImage_new.jpg",
"media": "baseImage",
"mimetype": "image/jpeg",
"width": 1400,
"height": 1050,
"poi": {
"x": 1050,
"y": 262
}
},
"thumbnail": {
"href": "http://localhost:5000/api/upload-raw/thumbnail_new.jpg",
"media": "thumbnail",
"mimetype": "image/jpeg",
"width": 160,
"height": 120,
"poi": {
"x": 120,
"y": 30
}
},
"viewImage": {
"href": "http://localhost:5000/api/upload-raw/viewImage_new.jpg",
"media": "viewImage",
"mimetype": "image/jpeg",
"width": 640,
"height": 480,
"poi": {
"x": 480,
"y": 120
}
}
}
}
]
"""
Then we set copy metadata from parent flag
When we patch given
"""
{
"associations": {
"featuremedia": {
"_id": "urn:newsml:localhost:5000:2018-12-14T11:31:26.088056:5c45850b-2985-42b3-9ae3-new",
"media": "5c13867efe985edfc9223480",
"type": "picture",
"format": "HTML",
"renditions": {
"original": {
"href": "http://localhost:5000/api/upload-raw/orig_new.jpg",
"media": "orig_new",
"mimetype": "image/jpeg",
"width": 4032,
"height": 3024,
"poi": {
"x": 3024,
"y": 756
}
},
"baseImage": {
"href": "http://localhost:5000/api/upload-raw/baseImage_new.jpg",
"media": "baseImage_new",
"mimetype": "image/jpeg",
"width": 1400,
"height": 1050,
"poi": {
"x": 1050,
"y": 262
}
},
"thumbnail": {
"href": "http://localhost:5000/api/upload-raw/thumbnail_new.jpg",
"media": "thumbnail_new",
"mimetype": "image/jpeg",
"width": 160,
"height": 120,
"poi": {
"x": 120,
"y": 30
}
},
"viewImage": {
"href": "http://localhost:5000/api/upload-raw/viewImage_new.jpg",
"media": "viewImage_new",
"mimetype": "image/jpeg",
"width": 640,
"height": 480,
"poi": {
"x": 480,
"y": 120
}
}
}
}
}
}
"""
When we get "/archive/tag:example.com,0000:newsml_BRE9A605"
Then we get existing resource
"""
{
"associations": {
"featuremedia": {
"_id": "urn:newsml:localhost:5000:2018-12-14T11:31:26.088056:5c45850b-2985-42b3-9ae3-new",
"media": "5c13867efe985edfc9223480",
"type": "picture",
"format": "HTML",
"renditions": {
"original": {
"href": "http://localhost:5000/api/upload-raw/orig_new.jpg",
"media": "orig_new",
"mimetype": "image/jpeg",
"width": 4032,
"height": 3024,
"poi": {
"x": 3024,
"y": 756
}
},
"baseImage": {
"href": "http://localhost:5000/api/upload-raw/baseImage_new.jpg",
"media": "baseImage_new",
"mimetype": "image/jpeg",
"width": 1400,
"height": 1050,
"poi": {
"x": 1050,
"y": 262
}
},
"thumbnail": {
"href": "http://localhost:5000/api/upload-raw/thumbnail_new.jpg",
"media": "thumbnail_new",
"mimetype": "image/jpeg",
"width": 160,
"height": 120,
"poi": {
"x": 120,
"y": 30
}
},
"viewImage": {
"href": "http://localhost:5000/api/upload-raw/viewImage_new.jpg",
"media": "viewImage_new",
"mimetype": "image/jpeg",
"width": 640,
"height": 480,
"poi": {
"x": 480,
"y": 120
}
},
"4-3": "__none__"
}
}
}
}
"""

0 comments on commit 5bb69b7

Please sign in to comment.