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

Coverages created via Event creation form should be directly posted alongside with the associated Planning item [SDESK-7051] #1849

Merged
merged 12 commits into from
Sep 11, 2023
2 changes: 2 additions & 0 deletions client/components/ContentProfiles/FieldTab/FieldEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class FieldEditor extends React.Component<IProps, IState> {
const fieldProps = {
'schema.required': {enabled: !(this.props.disableRequired || this.props.systemRequired)},
'schema.read_only': {enabled: this.props.item.name === 'related_plannings'},
'schema.planning_auto_publish': {enabled: this.props.item.name === 'related_plannings'},
'schema.field_type': {enabled: fieldType != null},
'schema.minlength': {enabled: !disableMinMax},
'schema.maxlength': {enabled: !disableMinMax},
Expand Down Expand Up @@ -187,6 +188,7 @@ export class FieldEditor extends React.Component<IProps, IState> {
'schema.multilingual': {enabled: true, index: 11},
'schema.languages': {enabled: true, index: 12},
'schema.default_language': {enabled: true, index: 13},
'schema.planning_auto_publish': {enabled: true, index: 14},
},
{
item: this.props.item,
Expand Down
11 changes: 11 additions & 0 deletions client/components/fields/resources/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ registerEditorField(
true
);

registerEditorField(
'schema.planning_auto_publish',
EditorFieldCheckbox,
() => ({
label: superdeskApi.localization.gettext('Planning Auto Publish'),
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
field: 'schema.planning_auto_publish',
}),
null,
true
);

registerEditorField(
'schema.format_options',
SelectEditor3FormattingOptions,
Expand Down
1 change: 1 addition & 0 deletions client/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ export interface IProfileSchemaTypeList extends IBaseProfileSchemaType<'list'> {
schema?: {[key: string]: any};
mandatory_in_list?: {[key: string]: any};
vocabularies?: Array<IVocabulary['_id']>;
planning_auto_publish?:boolean;
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
}

export interface IProfileSchemaTypeInteger extends IBaseProfileSchemaType<'integer'> {}
Expand Down
1 change: 1 addition & 0 deletions server/planning/content_profiles/profiles/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class EventSchema(BaseSchema):
custom_vocabularies = schema.ListField()
related_plannings = schema.ListField()
related_plannings.schema["read_only"] = False
related_plannings.schema["planning_auto_publish"] = False
registration_details = TextField(field_type="multi_line")
invitation_details = TextField(field_type="multi_line")
accreditation_info = TextField(field_type="single_line")
Expand Down
17 changes: 13 additions & 4 deletions server/planning/events/events_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,22 @@ def publish_event(self, event, version):
logger.error("Failed to save planning version for event item id {}".format(event["_id"]))

def post_related_plannings(self, plannings, new_post_state):
# Check to see if we are un-posting, we need to unpost it's planning item
if new_post_state != POST_STATE.CANCELLED:
return

planning_post_service = get_resource_service("planning_post")
planning_spike_service = get_resource_service("planning_spike")
event_profile_schema = get_resource_service("planning_types").find_one(req=None, name="event").get("schema", {})
docs = []
if new_post_state != POST_STATE.CANCELLED:
if event_profile_schema.get("related_plannings", {}).get("planning_auto_publish"):
docs = [
{
"planning": planning[config.ID_FIELD],
"etag": planning.get("etag"),
"pubstatus": POST_STATE.USABLE,
}
for planning in plannings
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
]
planning_post_service.post(docs)
return
for planning in plannings:
if not planning.get("pubstatus") and planning.get("state") in [
WORKFLOW_STATE.INGESTED,
Expand Down
6 changes: 6 additions & 0 deletions server/planning/validate/planning_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ def _validate_read_only(self, read_only, field, value):
# Ignore this profile as it's for the front-end editor
pass

def _validate_planning_auto_publish(self, planning_auto_publish, field, value):
"""
{'type': 'boolean', 'nullable': True}
"""
pass


class PlanningValidateResource(Resource):
endpoint_name = "planning_validator"
Expand Down
Loading