def on_updated(self, updates, original): added, removed = self._get_added_removed_agendas(updates, original) session_id = get_auth().get(config.ID_FIELD) push_notification('planning:updated', item=str(original[config.ID_FIELD]), user=str(updates.get('version_creator', '')), added_agendas=added, removed_agendas=removed, session=session_id) doc = deepcopy(original) doc.update(updates) self.__generate_related_assignments([doc]) updates['coverages'] = doc.get('coverages') or [] update_post_item(updates, original) # update planning_featured record if schedule has changed if original.get('featured'): removed_schedules = [] for schdl in original.get('_planning_schedule', []): other_schedules_on_day = [ s for s in updates.get('_planning_schedule', []) if schdl.get('scheduled').date() == s.get('scheduled').date() ] if len(other_schedules_on_day) == 0 and schdl.get( 'scheduled') not in removed_schedules: removed_schedules.append(schdl.get('scheduled')) planning_featured_service = get_resource_service( 'planning_featured') for removed_date in removed_schedules: # get the planning_featured record for that day planning_featured_service.remove_planning_item_for_date( removed_date, original)
def on_updated(self, updates, original): lock_action = original.get('lock_action') allowed_actions = [ ITEM_ACTIONS.EDIT, ITEM_ACTIONS.PLANNING_CANCEL, ITEM_ACTIONS.CANCEL_ALL_COVERAGE ] if request.view_args.get('event_cancellation') or lock_action in allowed_actions or \ self.is_related_event_completed(updates, original): update_post_item(updates, original)
def on_updated(self, updates, original): lock_action = original.get('lock_action') if lock_action in [ ITEM_ACTIONS.EDIT, ITEM_ACTIONS.PLANNING_CANCEL, ITEM_ACTIONS.CANCEL_ALL_COVERAGE ]: update_post_item(updates, original) planning_featured_service = get_resource_service('planning_featured') planning_featured_service.remove_planning_item(original)
def on_updated(self, updates, original): # If this Event was converted to a recurring series # Then update all associated Planning items with the recurrence_id if updates.get('recurrence_id') and not original.get('recurrence_id'): get_resource_service('planning').on_event_converted_to_recurring( updates, original) if not updates.get('duplicate_to'): posted = update_post_item(updates, original) if posted: new_event = get_resource_service('events').find_one( req=None, _id=original.get(config.ID_FIELD)) updates['_etag'] = new_event['_etag'] updates['state_reason'] = new_event.get('state_reason') if original.get( 'lock_user' ) and 'lock_user' in updates and updates.get('lock_user') is None: # when the event is unlocked by the patch. push_notification('events:unlock', item=str(original.get(config.ID_FIELD)), user=str(get_user_id()), lock_session=str(get_auth().get('_id')), etag=updates['_etag'], recurrence_id=original.get('recurrence_id') or None) self.delete_event_files(updates, original) if 'location' not in updates and original.get('location'): updates['location'] = original['location'] self._enhance_event_item(updates)
def on_updated(self, updates, original): # Because we require the original item being actioned against to be locked # then we can check the lock information of original and updates to check if this # event was the original event. if self.is_original_event(original): # Send a notification if the LOCK has been removed as a result of the update if original.get( 'lock_user' ) and 'lock_user' in updates and updates.get('lock_user') is None: push_notification('events:unlock', item=str(original.get(config.ID_FIELD)), user=str(get_user_id()), lock_session=str(get_auth().get('_id')), etag=updates.get('_etag'), recurrence_id=original.get('recurrence_id') or None) self.push_notification(self.ACTION, updates, original) update_post_item(updates, original)