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

[STTNHUB-312] Add planning_ingested signal #1899

Merged
merged 3 commits into from
Jan 18, 2024
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
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"scripts": {
"cypress-ui": "cypress open",
"cypress-ci": "cypress run",
"cypress-ci": "cypress run --browser chrome",
"clean": "grunt clean",
"build": "npx @superdesk/build-tools build-root-repo ./",
"serve": "node --max-old-space-size=8192 ./node_modules/.bin/grunt server"
Expand Down
1 change: 1 addition & 0 deletions server/features/events_postpone.feature
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ Feature: Events Postpone

@auth
@notification
@planning_cvs
Scenario: Published event gets updated after postpone
Given we have sessions "/sessions"
Given "desks"
Expand Down
3 changes: 1 addition & 2 deletions server/features/planning_duplicate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ Feature: Duplicate Planning
},
"assigned_to": {
"desk": "#desks._id#",
"user": "#CONTEXT_USER_ID#",
"assignment_id": "aaaaaaaaaaaaaaaaaaaaaaaa"
"user": "#CONTEXT_USER_ID#"
}
}],
"expired": true
Expand Down
13 changes: 10 additions & 3 deletions server/planning/planning/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
from superdesk import Resource
from lxml import etree
from io import BytesIO
from planning.signals import planning_created
from planning.signals import planning_created, planning_ingested

logger = logging.getLogger(__name__)

Expand All @@ -85,6 +85,8 @@ def post_in_mongo(self, docs, **kwargs):
resolve_document_etag(docs, self.datasource)
ids = self.backend.create_in_mongo(self.datasource, docs, **kwargs)
self.on_created(docs)
for doc in docs:
planning_ingested.send(self, item=doc)
return ids

def patch_in_mongo(self, id, document, original):
Expand All @@ -93,6 +95,7 @@ def patch_in_mongo(self, id, document, original):
update_ingest_on_patch(document, original)
response = self.backend.update_in_mongo(self.datasource, id, document, original)
self.on_updated(document, original, from_ingest=True)
planning_ingested.send(self, item=document, original=original)
return response

def is_new_version(self, new_item, old_item):
Expand Down Expand Up @@ -523,13 +526,17 @@ def remove_coverage_entity(self, coverage_entity, original_planning, entity_type

def add_coverages(self, updates, original):
planning_date = original.get("planning_date") or updates.get("planning_date")
original_coverage_ids = [
coverage["coverage_id"] for coverage in original.get("coverages") or [] if coverage.get("coverage_id")
]
for coverage in updates.get("coverages") or []:
coverage_id = coverage.get("coverage_id", "")
if not coverage_id or TEMP_ID_PREFIX in coverage_id:
if not coverage_id or TEMP_ID_PREFIX in coverage_id or coverage_id not in original_coverage_ids:
if "duplicate" in coverage_id:
self.duplicate_xmp_file(coverage)
# coverage to be created
coverage["coverage_id"] = generate_guid(type=GUID_NEWSML)
if not coverage_id or TEMP_ID_PREFIX in coverage_id:
coverage["coverage_id"] = generate_guid(type=GUID_NEWSML)
coverage["firstcreated"] = utcnow()

# Make sure the coverage has a ``scheduled`` date
Expand Down
2 changes: 2 additions & 0 deletions server/planning/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

__all__ = [
"planning_created",
"planning_ingested",
]

signals = blinker.Namespace()

planning_created = signals.signal("planning:created")
planning_ingested = signals.signal("planning:ingested")
Loading