Skip to content

Commit

Permalink
copy subject field when creating embedded planning items (#2011)
Browse files Browse the repository at this point in the history
SDBELGA-821
  • Loading branch information
petrjasek authored Jul 3, 2024
1 parent 37ffa4a commit 29df354
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
11 changes: 9 additions & 2 deletions server/features/event_embedded_planning.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Feature: Event Embedded Planning

@auth
@vocabulary
Scenario: Can create and update associated Planning with an Event
Expand All @@ -19,7 +20,10 @@ Feature: Event Embedded Planning
"news_coverage_status": "ncostat:int",
"scheduled": "2029-11-21T15:00:00.000Z"
}]
}]
}],
"subject": [
{"name": "Test", "qcode": "test", "scheme": "test"}
]
}]
"""
Then we get OK response
Expand Down Expand Up @@ -57,7 +61,10 @@ Feature: Event Embedded Planning
"g2_content_type": "text",
"scheduled": "2029-11-21T15:00:00+0000"
}
}]
}],
"subject": [
{"name": "Test", "qcode": "test", "scheme": "test"}
]
}]}
"""
And we store "PLAN1" with first item
Expand Down
6 changes: 2 additions & 4 deletions server/planning/assignments/assignments_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@ def get_item_from_assignment(assignment, template=None):
content_profile_id = template["data"].get("profile", desk.get("default_content_profile", None))
content_profile = None
if content_profile_id:
content_profiles = get_resource_service("content_types").find({"_id": content_profile_id})
# Pop those items not in the content_profile
if content_profiles.count() > 0:
content_profile = content_profiles.next()
content_profile = get_resource_service("content_types").find_one(req=None, _id=content_profile_id)
if content_profile is not None:
for key in content_profile.get("schema").keys():
if content_profile["schema"][key] is None:
item.pop(key, None)
Expand Down
4 changes: 3 additions & 1 deletion server/planning/events/events_sync/embedded_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ def create_new_plannings_from_embedded_planning(
"internal_note",
"name",
"place",
"subject",
"anpa_category",
"ednote",
"language",
"priority",
]
if field in profiles.planning.enabled_fields
)

planning_fields.add("subject")

multilingual_enabled = profiles.events.is_multilingual and profiles.planning.is_multilingual
translations: List[StringFieldTranslation] = []
if multilingual_enabled and "language" in planning_fields and len(event.get("translations") or []):
Expand Down

0 comments on commit 29df354

Please sign in to comment.