本文整理汇总了Python中opengever.task.task.ITask类的典型用法代码示例。如果您正苦于以下问题:Python ITask类的具体用法?Python ITask怎么用?Python ITask使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ITask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_subtask_response
def create_subtask_response(context, event):
"""When adding a new task object within a task(subtask),
it adds a response to the maintask.
"""
# the event is fired multiple times when the task was transported, so we
# need to verify that the request was not called by another client.
request = context.REQUEST
if request.get_header('X-OGDS-AC', None) or \
request.get_header('X-OGDS-AUID', None) or \
request.get('X-CREATING-SUCCESSOR', None):
return
parent = aq_parent(aq_inner(context))
if ITask.providedBy(parent):
if ITask.providedBy(context):
transition = 'transition-add-subtask'
# If the the added object is a subtask we have to make sure
# that the subtask is already synced to the globalindex
if not context.get_sql_object():
TaskSqlSyncer(context, event).sync()
elif IBaseDocument.providedBy(context):
transition = 'transition-add-document'
# add a response with a link to the object
add_simple_response(parent, added_object=context,
transition=transition)
示例2: assign_forwarding_to_dossier
def assign_forwarding_to_dossier(
context, forwarding_oguid, dossier, response_text):
forwarding = Task.query.by_oguid(forwarding_oguid)
forwarding_obj = context.unrestrictedTraverse(
forwarding.physical_path.encode('utf-8'))
# we need all task field values from the forwarding
fielddata = {}
for fieldname in ITask.names():
value = ITask.get(fieldname).get(forwarding_obj)
fielddata[fieldname] = value
# Reset issuer to the current inbox
fielddata['issuer'] = get_current_org_unit().inbox().id()
# Predefine the task_type to avoid tasks with an invalid task_type
fielddata['task_type'] = FORWARDING_SUCCESSOR_TYPE
# lets create a new task - the successor task
task = createContentInContainer(
dossier, 'opengever.task.task', **fielddata)
successor_tc_task = ISuccessorTaskController(task)
# Add issuer and responsible to the watchers of the newly created task
center = notification_center()
center.add_task_responsible(task, task.responsible)
center.add_task_issuer(task, task.issuer)
# copy documents and map the intids
intids_mapping = _copy_documents_from_forwarding(forwarding_obj, task)
# copy the responses
response_transporter = IResponseTransporter(task)
response_transporter.get_responses(
get_current_admin_unit().id(),
'/'.join(forwarding_obj.getPhysicalPath()),
intids_mapping=intids_mapping)
# close and store the forwarding in yearfolder
change_task_workflow_state(
forwarding_obj,
'forwarding-transition-assign-to-dossier',
text=response_text,
successor_oguid=successor_tc_task.get_oguid())
IYearfolderStorer(forwarding_obj).store_in_yearfolder()
# successor
successor_tc_task.set_predecessor(forwarding_oguid)
return task
示例3: get_containing_task
def get_containing_task(self):
""" Get the parent-tasks if we have one
"""
parent = aq_parent(aq_inner(self.context))
if ITask.providedBy(parent):
return [parent]
return []
示例4: get_added_objects
def get_added_objects(self):
""" Returns two lists of docs, subtasks
"""
try:
self.added_object
except AttributeError:
return [], []
# .. and sometimes it may be empty.
if not self.added_object:
return [], []
# Support for multiple added objects
if hasattr(self.added_object, '__iter__'):
relations = self.added_object
else:
relations = [self.added_object]
docs = []
subtasks = []
for rel in relations:
obj = rel.to_object
if ITask.providedBy(obj):
subtasks.append(obj)
else:
docs.append(obj)
return docs, subtasks
示例5: render
def render(self):
parent = aq_inner(aq_parent(self.context))
if ITask.providedBy(parent):
redirect_to = '%s#overview' % parent.absolute_url()
else:
redirect_to = '%s#tasks' % parent.absolute_url()
return self.request.RESPONSE.redirect(redirect_to)
示例6: assign_forwarding_to_dossier
def assign_forwarding_to_dossier(
context, forwarding_oguid, dossier, response_text):
forwarding = getUtility(ITaskQuery).get_task_by_oguid(forwarding_oguid)
forwarding_obj = context.unrestrictedTraverse(
forwarding.physical_path.encode('utf-8'))
# we need all task field values from the forwarding
fielddata = {}
for fieldname in ITask.names():
value = ITask.get(fieldname).get(forwarding_obj)
fielddata[fieldname] = value
# lets create a new task - the successor task
task = createContentInContainer(
dossier, 'opengever.task.task', **fielddata)
successor_tc_task = ISuccessorTaskController(task)
# copy documents and map the intids
intids_mapping = _copy_documents_from_forwarding(forwarding_obj, task)
# copy the responses
response_transporter = IResponseTransporter(task)
response_transporter.get_responses(
get_client_id(),
'/'.join(forwarding_obj.getPhysicalPath()),
intids_mapping=intids_mapping)
# close and store the forwarding in yearfolder
change_task_workflow_state(
forwarding_obj,
'forwarding-transition-assign-to-dossier',
text=response_text,
successor_oguid=successor_tc_task.get_oguid())
inbox = aq_parent(aq_inner(forwarding_obj))
yearfolder = _get_yearfolder(inbox)
clipboard = inbox.manage_cutObjects((forwarding_obj.getId(),))
yearfolder.manage_pasteObjects(clipboard)
# successor
successor_tc_task.set_predecessor(forwarding_oguid)
return task
示例7: reindex_dossier_and_children
def reindex_dossier_and_children(self, dossier):
children = self.catalog(path='/'.join(dossier.getPhysicalPath()))
for child in children:
obj = child.getObject()
obj.reindexObject(idxs=['reference'])
if ITask.providedBy(obj):
obj.get_sql_object().sync_with(obj)
示例8: reindex_containing_dossier_for_contained_objects
def reindex_containing_dossier_for_contained_objects(dossier, event):
"""Reindex the containging_dossier index for all the contained obects.
"""
for brain in dossier.portal_catalog(path='/'.join(dossier.getPhysicalPath())):
obj = brain.getObject()
obj.reindexObject(idxs=['containing_dossier'])
if ITask.providedBy(obj):
sync_task(brain.getObject(), event)
示例9: get_type
def get_type(self, item):
"""differ the object typ and return the type as string
"""
if not item:
return None
elif isinstance(item, dict):
return "dict"
elif isinstance(item, Task) or ITask.providedBy(item):
return "task"
else:
return "obj"
示例10: update_deadline
def update_deadline(task, event):
"""Update the parents deadline, when a subtask deadline has changed."""
for descr in event.descriptions:
for attr in descr.attributes:
if attr == 'deadline':
parent = aq_parent(aq_inner(task))
if ITask.providedBy(parent):
temp = task.deadline + timedelta(MAIN_TASK_DEADLINE_DELTA)
if parent.deadline < temp:
parent.deadline = temp
parent.reindexObject()
示例11: _task_state_wrapper
def _task_state_wrapper(self, item, text):
""" Wrap a span-tag around the text with the status-css class
"""
if isinstance(item, Task):
# Its a sql-task-object
state = item.review_state
elif ITask.providedBy(item):
# Its a task-object
state = getToolByName(self.context, "portal_workflow").getInfoFor(item, "review_state")
else:
return ""
return '<span class="wf-%s">%s</span>' % (state, text)
示例12: set_initial_state
def set_initial_state(task, event):
"""When adding a subtask to a sequential task process, the new task should
be in the planned state.
"""
if IDuringTaskTemplateFolderTriggering.providedBy(getRequest()):
return
parent = aq_parent(aq_inner(task))
if ITask.providedBy(parent) \
and IFromSequentialTasktemplate.providedBy(parent):
task.set_to_planned_state()
示例13: _get_task_css_class
def _get_task_css_class(task):
"""A task helper function for `get_css_class`, providing some metadata
of a task. The task may be a brain, a dexterity object or a sql alchemy
globalindex object.
"""
if ICatalogBrain.providedBy(task) or ISolrDocument.providedBy(task):
task = Task.query.by_brain(task)
if ITask.providedBy(task):
task = task.get_sql_object()
return task.get_css_class()
示例14: render_task
def render_task(self, item):
""" Render the taskobject
"""
if isinstance(item, Task):
# Its a task stored in sql
return self._sqlalchemy_task_link(item)
elif ITask.providedBy(item):
# Its a normal task object
return self._object_task_link(item)
else:
return None
示例15: update_deadline
def update_deadline(task, event):
"""Update the parents deadline, when a subtask deadline has changed."""
for descr in event.descriptions:
for attr in descr.attributes:
if attr == 'deadline':
parent = aq_parent(aq_inner(task))
if ITask.providedBy(parent):
offset = api.portal.get_registry_record(
'deadline_timedelta', interface=ITaskSettings)
temp = task.deadline + timedelta(offset)
if parent.deadline < temp:
parent.deadline = temp
parent.reindexObject()