def update(self, id, updates, original): """ Handles workflow of each Publish, Corrected, Killed and TakeDown. """ try: user = get_user() auto_publish = updates.get("auto_publish", False) # unlock the item set_unlock_updates(updates) if original[ITEM_TYPE] == CONTENT_TYPE.COMPOSITE: self._publish_package_items(original, updates) self._update_archive(original, updates, should_insert_into_versions=auto_publish) else: self._publish_associated_items(original, updates) updated = deepcopy(original) updated.update(deepcopy(updates)) if updates.get(ASSOCIATIONS): self._refresh_associated_items(updated, skip_related=True) # updates got lost with update if updated.get(ASSOCIATIONS): self._fix_related_references(updated, updates) signals.item_publish.send(self, item=updated) self._update_archive(original, updates, should_insert_into_versions=auto_publish) self.update_published_collection(published_item_id=original[config.ID_FIELD], updated=updated) from apps.publish.enqueue import enqueue_published enqueue_published.apply_async() push_notification( "item:publish", item=str(id), unique_name=original["unique_name"], desk=str(original.get("task", {}).get("desk", "")), user=str(user.get(config.ID_FIELD, "")), ) if updates.get("previous_marked_user") and not updates.get("marked_for_user"): # send notification so that marked for me list can be updated get_resource_service("archive").handle_mark_user_notifications(updates, original, False) except SuperdeskApiError: raise except KeyError as e: logger.exception(e) raise SuperdeskApiError.badRequestError( message=_("Key is missing on article to be published: {exception}").format(exception=str(e)) ) except Exception as e: logger.exception(e) raise SuperdeskApiError.internalError( message=_("Failed to publish the item: {id}").format(id=str(id)), exception=e )
def update(self, id, updates, original): """ Handles workflow of each Publish, Corrected and Killed. """ try: user = get_user() auto_publish = updates.get('auto_publish', False) if original[ITEM_TYPE] == CONTENT_TYPE.COMPOSITE: self._publish_package_items(original, updates) self._update_archive(original, updates, should_insert_into_versions=auto_publish) else: self._refresh_associated_items(original) updated = deepcopy(original) updated.update(deepcopy(updates)) if updates.get(ASSOCIATIONS): self._refresh_associated_items( updated) # updates got lost with update # process takes package for published or corrected items # if no_takes is true but takes package exists then process takes package. if self.published_state != CONTENT_STATE.KILLED and \ (not app.config.get('NO_TAKES', False) or self.takes_package_service.get_take_package_id(updated)): self._process_takes_package(original, updated, updates) self._update_archive(original, updates, should_insert_into_versions=auto_publish) self.update_published_collection( published_item_id=original[config.ID_FIELD], updated=updated) from apps.publish.enqueue import enqueue_published enqueue_published.apply_async() push_notification('item:publish', item=str(id), unique_name=original['unique_name'], desk=str( original.get('task', {}).get('desk', '')), user=str(user.get(config.ID_FIELD, ''))) except SuperdeskApiError as e: raise except KeyError as e: logger.exception(e) raise SuperdeskApiError.badRequestError( message="Key is missing on article to be published: {}".format( str(e))) except Exception as e: raise SuperdeskApiError.internalError( message="Failed to publish the item: {}".format(str(id)), exception=e)
def update(self, id, updates, original): """ Handles workflow of each Publish, Corrected and Killed. """ try: user = get_user() auto_publish = updates.pop('auto_publish', False) if original[ITEM_TYPE] == CONTENT_TYPE.COMPOSITE: self._publish_package_items(original, updates) self._update_archive(original, updates, should_insert_into_versions=auto_publish) else: self._refresh_associated_items(original) self._publish_associations(original, id) updated = deepcopy(original) updated.update(updates) if updates.get('associations'): self._refresh_associated_items( updated) # updates got lost with update if self.published_state != CONTENT_STATE.KILLED: self._process_takes_package(original, updated, updates) self._update_archive(original, updates, should_insert_into_versions=auto_publish) self.update_published_collection( published_item_id=original[config.ID_FIELD], updated=updated) from apps.publish.enqueue import enqueue_published enqueue_published.apply_async() push_notification('item:publish', item=str(id), unique_name=original['unique_name'], desk=str( original.get('task', {}).get('desk', '')), user=str(user.get(config.ID_FIELD, ''))) except SuperdeskApiError as e: raise e except KeyError as e: raise SuperdeskApiError.badRequestError( message="Key is missing on article to be published: {}".format( str(e))) except Exception as e: logger.exception( "Something bad happened while publishing %s".format(id)) raise SuperdeskApiError.internalError( message="Failed to publish the item: {}".format(str(e)))
def update(self, id, updates, original): """ Handles workflow of each Publish, Corrected, Killed and TakeDown. """ try: user = get_user() auto_publish = updates.get('auto_publish', False) if original[ITEM_TYPE] == CONTENT_TYPE.COMPOSITE: self._publish_package_items(original, updates) self._update_archive(original, updates, should_insert_into_versions=auto_publish) else: self._publish_associated_items(original, updates) updated = deepcopy(original) updated.update(deepcopy(updates)) if updates.get(ASSOCIATIONS): self._refresh_associated_items( updated, skip_related=True) # updates got lost with update signals.item_publish.send(self, item=updated) self._update_archive(original, updates, should_insert_into_versions=auto_publish) self.update_published_collection( published_item_id=original[config.ID_FIELD], updated=updated) from apps.publish.enqueue import enqueue_published enqueue_published.apply_async() push_notification('item:publish', item=str(id), unique_name=original['unique_name'], desk=str( original.get('task', {}).get('desk', '')), user=str(user.get(config.ID_FIELD, ''))) except SuperdeskApiError: raise except KeyError as e: logger.exception(e) raise SuperdeskApiError.badRequestError(message=_( "Key is missing on article to be published: {exception}"). format(exception=str(e))) except Exception as e: logger.exception(e) raise SuperdeskApiError.internalError( message=_("Failed to publish the item: {id}").format( id=str(id)), exception=e)
def update(self, id, updates, original): """ Handles workflow of each Publish, Corrected and Killed. """ try: user = get_user() auto_publish = updates.get('auto_publish', False) if original[ITEM_TYPE] == CONTENT_TYPE.COMPOSITE: self._publish_package_items(original, updates) self._update_archive(original, updates, should_insert_into_versions=auto_publish) else: self._refresh_associated_items(original) self._publish_associations(original, id) updated = deepcopy(original) updated.update(updates) if updates.get('associations'): self._refresh_associated_items(updated) # updates got lost with update if self.published_state != CONTENT_STATE.KILLED and not app.config.get('NO_TAKES', False): self._process_takes_package(original, updated, updates) self._update_archive(original, updates, should_insert_into_versions=auto_publish) self.update_published_collection(published_item_id=original[config.ID_FIELD], updated=updated) from apps.publish.enqueue import enqueue_published enqueue_published.apply_async() push_notification('item:publish', item=str(id), unique_name=original['unique_name'], desk=str(original.get('task', {}).get('desk', '')), user=str(user.get(config.ID_FIELD, ''))) except SuperdeskApiError as e: raise e except KeyError as e: raise SuperdeskApiError.badRequestError( message="Key is missing on article to be published: {}".format(str(e))) except Exception as e: logger.exception("Something bad happened while publishing %s".format(id)) raise SuperdeskApiError.internalError(message="Failed to publish the item: {}".format(str(e)))
def update(self, id, updates, original): """ Handles workflow of each Publish, Corrected, Killed and TakeDown. """ try: user = get_user() auto_publish = updates.get('auto_publish', False) if original[ITEM_TYPE] == CONTENT_TYPE.COMPOSITE: self._publish_package_items(original, updates) self._update_archive(original, updates, should_insert_into_versions=auto_publish) else: self._publish_associated_items(original, updates, publish=True) updated = deepcopy(original) updated.update(deepcopy(updates)) self._publish_associated_items(updated, updates) # updates got lost with update self._update_archive(original, updates, should_insert_into_versions=auto_publish) self.update_published_collection(published_item_id=original[config.ID_FIELD], updated=updated) from apps.publish.enqueue import enqueue_published enqueue_published.apply_async() push_notification('item:publish', item=str(id), unique_name=original['unique_name'], desk=str(original.get('task', {}).get('desk', '')), user=str(user.get(config.ID_FIELD, ''))) except SuperdeskApiError: raise except KeyError as e: logger.exception(e) raise SuperdeskApiError.badRequestError( message="Key is missing on article to be published: {}".format(str(e)) ) except Exception as e: raise SuperdeskApiError.internalError(message="Failed to publish the item: {}".format(str(id)), exception=e)
def step_impl_when_auth(context): enqueue_published.apply_async()