From 18273da8ad946d60397800b5efc0c6f5a98848cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Ja=C5=A1ek?= Date: Wed, 10 Apr 2024 13:16:25 +0200 Subject: [PATCH] fix events autosave with related items (#1960) SDBELGA-792 --- server/features/events.feature | 91 ++++++++++++++++++++++++ server/planning/events/event_autosave.py | 6 +- 2 files changed, 92 insertions(+), 5 deletions(-) diff --git a/server/features/events.feature b/server/features/events.feature index 13f7ea0f5..874d3a9fd 100644 --- a/server/features/events.feature +++ b/server/features/events.feature @@ -1492,4 +1492,95 @@ Feature: Events ] } """ + Then we get OK response + + @auth + Scenario: Autosave events with related items and coverages + Given we have sessions "/sessions" + When we post to "/event_autosave" + """ + { + "type": "event", + "occur_status": { + "qcode": "eocstat:eos5", + "name": "Planned, occurs certainly", + "label": "Planned, occurs certainly" + }, + "dates": { + "start": "2050-01-01T00:00:00+0000", + "end": "2050-01-02T00:00:00+0000", + "tz": "Europe/Sofia" + }, + "calendars": [], + "state": "draft", + "language": "en", + "languages": [ + "en" + ], + "place": [], + "files": [], + "associated_plannings": [ + { + "_id": "tempId-1712223365066uledqfmsv", + "type": "planning", + "planning_date": null, + "agendas": [], + "state": "draft", + "item_class": "plinat:newscoverage", + "language": "en", + "languages": [ + "en" + ], + "place": [], + "flags": { + "marked_for_not_publication": false, + "overide_auto_assign_to_workflow": false + }, + "coverages": [ + { + "coverage_id": "tempId-1712223368199odugn", + "planning": { + "scheduled": "2024-04-04T13:36:08+03:00", + "g2_content_type": "text", + "language": "en", + "_scheduledTime": "2024-04-04T13:36:08+03:00" + }, + "news_coverage_status": { + "qcode": "ncostat:int", + "name": "coverage intended", + "label": "Planned" + }, + "workflow_status": "draft", + "assigned_to": {} + } + ], + "event_item": "tempId-1712220681040btveuuz" + } + ], + "related_items": [ + { + "type": "picture", + "pubstatus": "usable", + "versioncreated": "2024-02-20T08:37:53+0000", + "guid": "0be5e148-2cd5-4a8b-bf76-a19fe21b2cb7", + "state": "in_progress", + "source": "ANSA", + "language": "it", + "search_provider": "660e6a002c73e11f433f0210" + }, + { + "type": "picture", + "pubstatus": "usable", + "versioncreated": "2024-02-20T08:37:07+0000", + "guid": "941f41db-4444-4aaf-94d9-cd48cd091a59", + "state": "in_progress", + "source": "ANSA", + "language": "it", + "search_provider": "660e6a002c73e11f433f0210" + } + ], + "lock_user": "#CONTEXT_USER_ID#", + "lock_session": "#SESSION_ID#" + } + """ Then we get OK response \ No newline at end of file diff --git a/server/planning/events/event_autosave.py b/server/planning/events/event_autosave.py index 28e6f7cbf..c62638f8d 100644 --- a/server/planning/events/event_autosave.py +++ b/server/planning/events/event_autosave.py @@ -25,11 +25,7 @@ class EventAutosaveResource(Resource): item_methods = ["GET", "PUT", "PATCH", "DELETE"] schema = deepcopy(events_schema) - schema["associated_plannings"] = { - "type": "list", - "required": False, - "schema": {"type": "dict", "allow_unknown": True}, - } + datasource = { "source": "event_autosave", }