Skip to content

Commit

Permalink
reingest onclusive event on location change
Browse files Browse the repository at this point in the history
SDCP-866
  • Loading branch information
petrjasek committed Dec 20, 2024
1 parent cebd5db commit a88668c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion server/planning/events/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 11 additions & 1 deletion server/planning/events/events_tests.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit a88668c

Please sign in to comment.