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

reingest onclusive event on location change #2171

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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)
Loading