diff --git a/server/planning/events/events.py b/server/planning/events/events.py index b6f41bbc3..57e24f13e 100644 --- a/server/planning/events/events.py +++ b/server/planning/events/events.py @@ -119,7 +119,13 @@ def is_event_updated(new_item: Event, old_item: Event) -> bool: return True new_subject = set([get_subject_str(subject) for subject in new_item.get("subject", [])]) old_subject = set([get_subject_str(subject) for subject in old_item.get("subject", [])]) - return new_subject != old_subject + if new_subject != old_subject: + return True + old_location = old_item.get("location", []) + new_location = new_item.get("location", []) + if new_location != old_location: + return True + return False class EventsService(superdesk.Service): diff --git a/server/planning/events/events_tests.py b/server/planning/events/events_tests.py index d04fe0d8f..ff7baa2ac 100644 --- a/server/planning/events/events_tests.py +++ b/server/planning/events/events_tests.py @@ -1,5 +1,6 @@ -from datetime import datetime, timedelta import pytz + +from datetime import datetime, timedelta from copy import deepcopy from mock import Mock, patch from superdesk import get_resource_service @@ -10,6 +11,8 @@ from planning.events.events import generate_recurring_dates from werkzeug.exceptions import BadRequest +from .events import is_event_updated + class EventTestCase(TestCase): def test_recurring_dates_generation(self): @@ -698,3 +701,10 @@ def test_related_planning_item_fields_validation_on_post(self): planning_item = planning_service.find_one(req=None, _id=planning_id[0]) self.assertEqual(len([planning_item]), 1) self.assertEqual(planning_item.get("state"), "scheduled") + + +def test_is_event_updated(): + new_event = {"location": [{"name": "test"}]} + old_events = {"location": [{"name": "test", "state": "bar"}]} + assert is_event_updated(new_event, old_events) + assert not is_event_updated(new_event, new_event) \ No newline at end of file