Skip to content

Commit

Permalink
add new params and handle the case to prevent planning from publish
Browse files Browse the repository at this point in the history
  • Loading branch information
devketanpro committed Sep 8, 2023
1 parent f4d26bb commit a127146
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions client/api/editor/item_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ export function getEventsInstance(type: EDITOR_TYPE): IEditorAPI['item']['events
return;
}

if (updates && original?.version == original?.posted_version) {
original['version'] = original?.version ? original['version'] + 1 : 1;
}

plans[index] = {
...original,
...updates,
Expand Down
2 changes: 2 additions & 0 deletions client/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ export interface IPlanningItem extends IBaseRestApiResponse {
reason: string;
_time_to_be_confirmed: boolean;
_cancelAllCoverage: boolean;
version:number;
posted_version:number;

// Used when showing Associated Planning item for Events
_agendas: Array<IAgenda>;
Expand Down
3 changes: 2 additions & 1 deletion server/planning/events/events_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ def post_related_plannings(self, plannings, new_post_state):
"etag": planning.get("etag"),
"pubstatus": POST_STATE.USABLE,
}
for planning in plannings
for planning in plannings if planning.get("version") != planning.get("posted_version")
]
if len(docs) > 0:
planning_post_service.post(docs)
return
for planning in plannings:
Expand Down
3 changes: 3 additions & 0 deletions server/planning/planning/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,9 @@ def duplicate_xmp_file(self, coverage):
TO_BE_CONFIRMED_FIELD: TO_BE_CONFIRMED_FIELD_SCHEMA,
"_type": {"type": "string", "mapping": None},
"extra": metadata_schema["extra"],
# Added fields for post planning item with events
"posted_version" : {"type": "number", "nullable": False},
"version" : {"type": "number", "default": 1},
} # end planning_schema


Expand Down
1 change: 1 addition & 0 deletions server/planning/planning/planning_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def post_planning(self, plan, new_post_state, assignments_to_delete):
updates = {
"state": get_item_post_state(plan, new_post_state),
"pubstatus": new_post_state,
"posted_version": plan.get("version")
}
if updates["state"] in [WORKFLOW_STATE.SCHEDULED, WORKFLOW_STATE.KILLED]:
updates["state_reason"] = None
Expand Down

0 comments on commit a127146

Please sign in to comment.