本文整理汇总了Python中superdesk.workflow_state函数的典型用法代码示例。如果您正苦于以下问题:Python workflow_state函数的具体用法?Python workflow_state怎么用?Python workflow_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了workflow_state函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_expiry
updates["expiry"] = get_expiry(desk_id=desk_id)
return updates
def on_update(self, updates, original):
updates[ITEM_OPERATION] = ITEM_UNSPIKE
def update(self, id, updates, original):
original_state = original[config.CONTENT_STATE]
if not is_workflow_state_transition_valid("unspike", original_state):
raise InvalidStateTransitionError()
user = get_user(required=True)
item = get_resource_service(ARCHIVE).find_one(req=None, _id=id)
updates.update(self.get_unspike_updates(item))
self.backend.update(self.datasource, id, updates, original)
item = get_resource_service(ARCHIVE).find_one(req=None, _id=id)
push_notification("item:unspike", item=str(id), user=str(user))
return item
superdesk.workflow_state("spiked")
superdesk.workflow_action(
name="spike", exclude_states=["spiked", "published", "scheduled", "killed"], privileges=["spike"]
)
superdesk.workflow_action(name="unspike", include_states=["spiked"], privileges=["unspike"])
开发者ID:oxcarh,项目名称:superdesk,代码行数:29,代码来源:archive_spike.py
示例2: is_valid_type
from superdesk.metadata.item import GUID_NEWSML, GUID_FIELD, FAMILY_ID, ITEM_TYPE, CONTENT_TYPE
from superdesk.metadata.utils import generate_guid
from superdesk.celery_task_utils import mark_task_as_not_running, is_task_running
UPDATE_SCHEDULE_DEFAULT = {'minutes': 5}
LAST_UPDATED = 'last_updated'
LAST_ITEM_UPDATE = 'last_item_update'
STATE_INGESTED = 'ingested'
IDLE_TIME_DEFAULT = {'hours': 0, 'minutes': 0}
logger = logging.getLogger(__name__)
superdesk.workflow_state(STATE_INGESTED)
superdesk.workflow_action(
name='ingest'
)
def is_valid_type(provider, provider_type_filter=None):
"""Test if given provider has valid type and should be updated.
:param provider: provider to be updated
:param provider_type_filter: active provider type filter
"""
provider_type = provider.get('type')
if provider_type not in providers:
return False
开发者ID:verifiedpixel,项目名称:superdesk-core,代码行数:31,代码来源:update_ingest.py
示例3: ArchiveSaveService
resource_methods = ['POST']
item_methods = ['GET', 'PUT', 'PATCH']
resource_title = endpoint_name
privileges = {'POST': 'archive', 'PATCH': 'archive', 'PUT': 'archive'}
class ArchiveSaveService(BaseService):
def create(self, docs, **kwargs):
if not docs:
raise SuperdeskApiError.notFoundError('Content is missing')
req = parse_request(self.datasource)
try:
get_component(ItemAutosave).autosave(docs[0]['_id'], docs[0], get_user(required=True), req.if_match)
except InvalidEtag:
raise SuperdeskApiError.preconditionFailedError('Client and server etags don\'t match')
return [docs[0]['_id']]
superdesk.workflow_state('in_progress')
superdesk.workflow_action(
name='save',
include_states=['draft', 'fetched', 'routed', 'submitted'],
privileges=['archive']
)
superdesk.workflow_state('submitted')
superdesk.workflow_action(
name='move',
exclude_states=['ingested', 'spiked', 'on-hold', 'published', 'killed'],
privileges=['archive']
)
开发者ID:marwoodandrew,项目名称:superdesk-server,代码行数:30,代码来源:archive.py
示例4: get_crop
def get_crop(rendition):
fields = ('CropLeft', 'CropTop', 'CropRight', 'CropBottom')
return {field: rendition[field] for field in fields if field in rendition}
@celery.task
def publish_images(images, original, item):
orig_file = get_file(original, item)
for image in images:
content_type = original['mimetype']
ok, output = crop_image(orig_file, image['file_name'], image['crop'], image['spec'])
if ok:
app.media.put(output, image['file_name'], content_type, _id=image['media'])
superdesk.workflow_state('published')
superdesk.workflow_action(
name='publish',
include_states=['fetched', 'routed', 'submitted', 'in_progress', 'scheduled'],
privileges=['publish']
)
superdesk.workflow_state('scheduled')
superdesk.workflow_action(
name='schedule',
include_states=['fetched', 'routed', 'submitted', 'in_progress'],
privileges=['schedule']
)
superdesk.workflow_action(
name='deschedule',
开发者ID:akintolga,项目名称:superdesk-core,代码行数:31,代码来源:common.py
示例5: UserContentService
schema = ArchiveResource.schema
datasource = {'source': 'archive', 'aggregations': aggregations}
resource_methods = ['GET', 'POST']
item_methods = ['GET', 'PATCH', 'DELETE']
resource_title = endpoint_name
class UserContentService(BaseService):
custom_hateoas = {'self': {'title': 'Archive', 'href': '/archive/{_id}'}}
def get(self, req, lookup):
docs = super().get(req, lookup)
for doc in docs:
build_custom_hateoas(self.custom_hateoas, doc)
return docs
superdesk.workflow_state('draft')
superdesk.workflow_action(
name='fetch_from_content',
include_states=['fetched', 'routed', 'submitted', 'in-progress'],
privileges=['archive']
)
superdesk.workflow_action(
name='fetch_as_from_content',
include_states=['fetched', 'routed', 'submitted', 'in-progress'],
privileges=['archive']
)
开发者ID:vied12,项目名称:superdesk-server,代码行数:30,代码来源:user_content.py
示例6: on_deleted
if doc.get('last_item_update'):
raise SuperdeskApiError.forbiddenError("Deleting an Ingest Source after receiving items is prohibited.")
def on_deleted(self, doc):
"""
Overriding to send notification and record activity about channel deletion.
"""
notify_and_add_activity(ACTIVITY_DELETE, 'Deleted Ingest Channel {{name}}',
self.datasource, item=None,
user_list=self.user_service.get_users_by_user_type('administrator'),
name=doc.get('name'), provider_id=doc.get(config.ID_FIELD))
push_notification('ingest_provider:delete', provider_id=str(doc.get(config.ID_FIELD)))
get_resource_service('sequences').delete(lookup={
'key': 'ingest_providers_{_id}'.format(_id=doc[config.ID_FIELD])
})
logger.info("Deleted Ingest Channel. Data:{}".format(doc))
def _test_config(self, updates, original=None):
provider = original.copy() if original else {}
provider.update(updates)
try:
service = registered_feeding_services[provider['feeding_service']].__class__()
except KeyError:
return
service.config_test(provider)
superdesk.workflow_state(CONTENT_STATE.INGESTED)
superdesk.workflow_action(name='ingest')
开发者ID:nistormihai,项目名称:superdesk-core,代码行数:30,代码来源:ingest_provider_model.py
示例7: update
def update(self, id, updates, original):
original_state = original[ITEM_STATE]
if not is_workflow_state_transition_valid('unspike', original_state):
raise InvalidStateTransitionError()
user = get_user(required=True)
item = get_resource_service(ARCHIVE).find_one(req=None, _id=id)
updates.update(self.get_unspike_updates(item))
self.backend.update(self.datasource, id, updates, original)
item = get_resource_service(ARCHIVE).find_one(req=None, _id=id)
push_notification('item:unspike', item=str(id), user=str(user.get(config.ID_FIELD)))
return item
superdesk.workflow_state('spiked')
superdesk.workflow_action(
name='spike',
exclude_states=['spiked', 'published', 'scheduled', 'corrected', 'killed'],
privileges=['spike']
)
superdesk.workflow_action(
name='unspike',
include_states=['spiked'],
privileges=['unspike']
)
开发者ID:MiczFlor,项目名称:superdesk-core,代码行数:29,代码来源:archive_spike.py
示例8: insert_into_versions
links.append({PACKAGE: doc.get(PACKAGE)})
dest_doc[LINKED_IN_PACKAGES] = links
superdesk.get_resource_service(ARCHIVE).post([dest_doc])
insert_into_versions(dest_doc.get("guid"))
desk = doc.get("desk")
refs = [
{"guid": ref.get("residRef"), "desk": desk, PACKAGE: dest_doc.get("_id")}
for group in dest_doc.get("groups", [])
for ref in group.get("refs", [])
if "residRef" in ref
]
if refs:
self.create(refs)
else:
if doc.get(PACKAGE):
links = archived_doc.get(LINKED_IN_PACKAGES, [])
links.append({PACKAGE: doc.get(PACKAGE)})
superdesk.get_resource_service(ARCHIVE).patch(archived_doc.get("_id"), {LINKED_IN_PACKAGES: links})
return [doc.get("guid") for doc in docs]
superdesk.workflow_state(STATE_FETCHED)
superdesk.workflow_action(
name="fetch_as_from_ingest", include_states=["ingested"], privileges=["archive", "ingest_move"]
)
superdesk.workflow_state("routed")
superdesk.workflow_action(name="route", include_states=["ingested"])
开发者ID:liveblog,项目名称:superdesk-server,代码行数:30,代码来源:archive_ingest.py
示例9: __fetch_items_in_package
return id_of_fetched_items
def __fetch_items_in_package(self, dest_doc, desk, stage, state):
# Note: macro and target information is not user for package publishing.
# Needs to looked later when package ingest requirements is clear.
for ref in [ref for group in dest_doc.get(GROUPS, []) for ref in group.get(REFS, []) if ref.get(RESIDREF)]:
ref["location"] = ARCHIVE
refs = [
{config.ID_FIELD: ref.get(RESIDREF), "desk": desk, "stage": stage, ITEM_STATE: state}
for group in dest_doc.get(GROUPS, [])
for ref in group.get(REFS, [])
if ref.get(RESIDREF)
]
if refs:
new_ref_guids = self.fetch(refs, id=None, notify=False)
count = 0
for ref in [ref for group in dest_doc.get(GROUPS, []) for ref in group.get(REFS, []) if ref.get(RESIDREF)]:
ref[RESIDREF] = ref[GUID_FIELD] = new_ref_guids[count]
count += 1
superdesk.workflow_state(CONTENT_STATE.FETCHED)
superdesk.workflow_action(
name="fetch_from_ingest", include_states=["ingested"], privileges=["ingest", "archive", "fetch"]
)
superdesk.workflow_state("routed")
superdesk.workflow_action(name="route", include_states=["ingested"])
开发者ID:hlmnrmr,项目名称:superdesk-core,代码行数:30,代码来源:archive_fetch.py
示例10: test_status_registry
def test_status_registry(self):
superdesk.workflow_state(name='test')
self.assertIn({'name': 'test'}, superdesk.get_workflow_states())
self.assertIn('test', superdesk.allowed_workflow_states)
开发者ID:vied12,项目名称:superdesk-server,代码行数:4,代码来源:workflow_test.py
示例11:
for ref in [ref for group in dest_doc.get('groups', [])
for ref in group.get('refs', []) if 'residRef' in ref]:
ref['location'] = ARCHIVE
refs = [{'_id': ref.get('residRef'), 'desk': desk,
'stage': stage, 'state': state, 'destination_groups': destination_groups}
for group in dest_doc.get('groups', [])
for ref in group.get('refs', []) if 'residRef' in ref]
if refs:
new_ref_guids = self.fetch(refs, id=None, notify=False)
count = 0
for ref in [ref for group in dest_doc.get('groups', [])
for ref in group.get('refs', []) if 'residRef' in ref]:
ref['residRef'] = ref['guid'] = new_ref_guids[count]
count += 1
superdesk.workflow_state(STATE_FETCHED)
superdesk.workflow_action(
name='fetch_from_ingest',
include_states=['ingested'],
privileges=['ingest', 'archive', 'fetch']
)
superdesk.workflow_state('routed')
superdesk.workflow_action(
name='route',
include_states=['ingested']
)
开发者ID:ahilles107,项目名称:superdesk-1,代码行数:30,代码来源:archive_fetch.py
示例12: ArchiveHoldService
class ArchiveHoldService(BaseService):
def create(self, docs, **kwargs):
user = get_user(required=True)
auth = get_auth()
item_id = request.view_args['item_id']
item = get_component(ItemHold).hold({'_id': item_id}, user['_id'], auth['_id'])
build_custom_hateoas(custom_hateoas, item)
return [item['_id']]
def delete(self, lookup):
user = get_user(required=True)
item_id = request.view_args['item_id']
get_component(ItemHold).restore({'_id': item_id}, user['_id'])
superdesk.workflow_state('on_hold')
superdesk.workflow_action(
name='hold',
exclude_states=['ingested', 'draft', 'spiked', 'published', 'killed'],
privileges=['hold']
)
superdesk.workflow_action(
name='restore',
include_states=['on_hold'],
privileges=['restore']
)
开发者ID:ahilles107,项目名称:superdesk-1,代码行数:29,代码来源:archive_hold.py
示例13: item_schema
schema = item_schema({"_id": {"type": "string"}})
resource_methods = ["POST"]
item_methods = ["GET", "PUT", "PATCH"]
resource_title = endpoint_name
privileges = {"POST": "archive", "PATCH": "archive", "PUT": "archive"}
class ArchiveSaveService(BaseService):
def create(self, docs, **kwargs):
if not docs:
raise SuperdeskApiError.notFoundError("Content is missing")
req = parse_request(self.datasource)
try:
get_component(ItemAutosave).autosave(docs[0]["_id"], docs[0], get_user(required=True), req.if_match)
except InvalidEtag:
raise SuperdeskApiError.preconditionFailedError("Client and server etags don't match")
return [docs[0]["_id"]]
superdesk.workflow_state("in_progress")
superdesk.workflow_action(
name="save", include_states=["draft", "fetched", "routed", "submitted", "scheduled"], privileges=["archive"]
)
superdesk.workflow_state("submitted")
superdesk.workflow_action(
name="move",
exclude_states=["ingested", "spiked", "on-hold", "published", "scheduled", "killed"],
privileges=["archive"],
)
开发者ID:Flowdeeps,项目名称:superdesk-1,代码行数:30,代码来源:archive.py
示例14: UserContentResource
from .common import CUSTOM_HATEOAS
from superdesk.metadata.utils import aggregations
from .archive import ArchiveResource
import superdesk
class UserContentResource(Resource):
endpoint_name = "user_content"
item_url = ArchiveResource.item_url
url = 'users/<regex("[a-f0-9]{24}"):original_creator>/content'
schema = ArchiveResource.schema
datasource = {
"source": "archive",
"aggregations": aggregations,
"elastic_filter": {"and": [{"not": {"exists": {"field": "task.desk"}}}, {"not": {"term": {"version": 0}}}]},
}
resource_methods = ["GET", "POST"]
item_methods = ["GET", "PATCH", "DELETE"]
resource_title = endpoint_name
class UserContentService(BaseService):
def get(self, req, lookup):
docs = super().get(req, lookup)
for doc in docs:
build_custom_hateoas(CUSTOM_HATEOAS, doc)
return docs
superdesk.workflow_state("draft")
开发者ID:actionless,项目名称:superdesk,代码行数:30,代码来源:user_content.py
示例15: get_resource_service
if doc.get(EMBARGO):
validation_errors.append("Package cannot have Items with Embargo")
# don't validate items that already have published
if doc[ITEM_STATE] not in [CONTENT_STATE.PUBLISHED, CONTENT_STATE.CORRECTED]:
validate_item = {"act": self.publish_type, "type": doc[ITEM_TYPE], "validate": doc}
errors = get_resource_service("validate").post([validate_item], headline=True)
if errors[0]:
validation_errors.extend(errors[0])
# check the locks on the items
if doc.get("lock_session", None) and package["lock_session"] != doc["lock_session"]:
validation_errors.extend(["{}: packaged item cannot be locked".format(doc["headline"])])
superdesk.workflow_state("published")
superdesk.workflow_action(
name="publish",
include_states=["fetched", "routed", "submitted", "in_progress", "scheduled"],
privileges=["publish"],
)
superdesk.workflow_state("scheduled")
superdesk.workflow_action(
name="schedule", include_states=["fetched", "routed", "submitted", "in_progress"], privileges=["schedule"]
)
superdesk.workflow_action(name="deschedule", include_states=["scheduled"], privileges=["deschedule"])
superdesk.workflow_state("killed")
superdesk.workflow_action(name="kill", include_states=["published", "scheduled", "corrected"], privileges=["kill"])
开发者ID:will-in-wi,项目名称:superdesk,代码行数:31,代码来源:common.py
注:本文中的superdesk.workflow_state函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论