本文整理汇总了Python中bika.lims.browser.bika_listing.WorkflowAction._get_form_workflow_action方法的典型用法代码示例。如果您正苦于以下问题:Python WorkflowAction._get_form_workflow_action方法的具体用法?Python WorkflowAction._get_form_workflow_action怎么用?Python WorkflowAction._get_form_workflow_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bika.lims.browser.bika_listing.WorkflowAction
的用法示例。
在下文中一共展示了WorkflowAction._get_form_workflow_action方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def __call__(self):
form = self.request.form
plone.protect.CheckAuthenticator(form)
action, came_from = WorkflowAction._get_form_workflow_action(self)
if action == 'submit':
objects = WorkflowAction._get_selected_items(self)
if not objects:
message = self.context.translate(
_b("No analyses have been selected"))
self.context.plone_utils.addPortalMessage(message, 'info')
self.destination_url = self.context.absolute_url() + \
"/batchbook"
self.request.response.redirect(self.destination_url)
return
for ar_uid, ar in objects.items():
for analysis in ar.getAnalyses(full_objects=True):
kw = analysis.getKeyword()
values = form.get(kw)
analysis.setResult(values[0][ar_uid])
if values[0][ar_uid]:
doActionFor(analysis, 'submit')
message = self.context.translate(_p("Changes saved."))
self.context.plone_utils.addPortalMessage(message, 'info')
self.request.response.redirect(self.request.get('URL'))
return
else:
WorkflowAction.__call__(self)
示例2: __call__
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def __call__(self):
form = self.request.form
plone.protect.CheckAuthenticator(form)
workflow = getToolByName(self.context, 'portal_workflow')
rc = getToolByName(self.context, REFERENCE_CATALOG)
action, came_from = WorkflowAction._get_form_workflow_action(self)
if action == 'reassign':
selected_worksheets = WorkflowAction._get_selected_items(self)
selected_worksheet_uids = selected_worksheets.keys()
if selected_worksheets:
changes = False
for uid in selected_worksheet_uids:
worksheet = selected_worksheets[uid]
# Double-check the state first
if workflow.getInfoFor(worksheet, 'review_state') == 'open':
worksheet.setAnalyst(form['Analyst'][0][uid])
changes = True
if changes:
message = self.context.translate(PMF('Changes saved.'))
self.context.plone_utils.addPortalMessage(message, 'info')
self.destination_url = self.request.get_header("referer",
self.context.absolute_url())
self.request.response.redirect(self.destination_url)
else:
# default bika_listing.py/WorkflowAction for other transitions
WorkflowAction.__call__(self)
示例3: workflow_action_verify
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def workflow_action_verify(self):
# default bika_listing.py/WorkflowAction, but then go to view screen.
self.destination_url = self.context.absolute_url()
action, came_from = WorkflowAction._get_form_workflow_action(self)
if type(came_from) in (list, tuple):
came_from = came_from[0]
return self.workflow_action_default(action="verify", came_from=came_from)
示例4: workflow_action_preserve
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def workflow_action_preserve(self):
form = self.request.form
workflow = getToolByName(self.context, 'portal_workflow')
action, came_from = WorkflowAction._get_form_workflow_action(self)
checkPermission = self.context.portal_membership.checkPermission
# Partition Preservation
# the partition table shown in AR and Sample views sends it's
# action button submits here.
objects = WorkflowAction._get_selected_items(self)
transitioned = []
incomplete = []
for obj_uid, obj in objects.items():
part = obj
# can't transition inactive items
if workflow.getInfoFor(part, 'inactive_state', '') == 'inactive':
continue
if not checkPermission(PreserveSample, part):
continue
# grab this object's Preserver and DatePreserved from the form
Preserver = form['getPreserver'][0][obj_uid].strip()
Preserver = Preserver and Preserver or ''
DatePreserved = form['getDatePreserved'][0][obj_uid].strip()
DatePreserved = DatePreserved and DateTime(DatePreserved) or ''
# write them to the sample
part.setPreserver(Preserver)
part.setDatePreserved(DatePreserved)
# transition the object if both values are present
if Preserver and DatePreserved:
workflow.doActionFor(part, action)
transitioned.append(part.id)
else:
incomplete.append(part.id)
part.reindexObject()
part.aq_parent.reindexObject()
message = None
if len(transitioned) > 1:
message = _('${items} are waiting to be received.',
mapping={'items': safe_unicode(', '.join(transitioned))})
self.context.plone_utils.addPortalMessage(message, 'info')
elif len(transitioned) == 1:
message = _('${item} is waiting to be received.',
mapping={'item': safe_unicode(', '.join(transitioned))})
self.context.plone_utils.addPortalMessage(message, 'info')
if not message:
message = _('No changes made.')
self.context.plone_utils.addPortalMessage(message, 'info')
if len(incomplete) > 1:
message = _('${items} are missing Preserver or Date Preserved',
mapping={'items': safe_unicode(', '.join(incomplete))})
self.context.plone_utils.addPortalMessage(message, 'error')
elif len(incomplete) == 1:
message = _('${item} is missing Preserver or Preservation Date',
mapping={'item': safe_unicode(', '.join(incomplete))})
self.context.plone_utils.addPortalMessage(message, 'error')
self.destination_url = self.request.get_header("referer",
self.context.absolute_url())
self.request.response.redirect(self.destination_url)
示例5: __call__
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def __call__(self):
form = self.request.form
plone.protect.CheckAuthenticator(form)
workflow = getToolByName(self.context, 'portal_workflow')
rc = getToolByName(self.context, REFERENCE_CATALOG)
uc = getToolByName(self.context, 'uid_catalog')
action, came_from = WorkflowAction._get_form_workflow_action(self)
if action == 'duplicate':
selected_services = WorkflowAction._get_selected_items(self)
## Create a copy of the selected services
folder = self.context.bika_setup.bika_analysisservices
created = []
for service in selected_services.values():
_id = folder.invokeFactory('AnalysisService', id = 'tmp')
dup = folder[_id]
dup.setTitle('%s (copy)' % service.Title())
_id = renameAfterCreation(dup)
dup.edit(
description = service.Description(),
PointOfCapture = service.getPointOfCapture(),
ReportDryMatter = service.getReportDryMatter(),
Unit = service.getUnit(),
Precision = service.getPrecision(),
Price = service.getPrice(),
CorporatePrice = service.getCorporatePrice(),
VAT = service.getVAT(),
Calculation = service.getCalculation(),
Instrument = service.getInstrument(),
MaxTimeAllowed = service.getMaxTimeAllowed(),
DuplicateVariation = service.getDuplicateVariation(),
Category = service.getCategory(),
Department = service.getDepartment(),
Accredited = service.getAccredited(),
Uncertainties = service.getUncertainties(),
ResultOptions = service.getResultOptions()
)
created.append(_id)
if len(created) > 1:
message = self.context.translation_service.translate(
_('Services ${services} were successfully created.',
mapping = {'services': ', '.join(created)}))
self.destination_url = self.request.get_header("referer",
self.context.absolute_url())
else:
message = self.context.translation_service.translate(
_('Analysis request ${service} was successfully created.',
mapping = {'service': ', '.join(created)}))
self.destination_url = dup.absolute_url() + "/base_edit"
self.context.plone_utils.addPortalMessage(message, 'info')
self.request.response.redirect(self.destination_url)
else:
# default bika_listing.py/WorkflowAction for other transitions
WorkflowAction.__call__(self)
示例6: workflow_action_publish
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def workflow_action_publish(self):
action, came_from = WorkflowAction._get_form_workflow_action(self)
if not isActive(self.context):
message = _('Item is inactive.')
self.context.plone_utils.addPortalMessage(message, 'info')
self.request.response.redirect(self.context.absolute_url())
return
# AR publish preview
self.request.response.redirect(self.context.absolute_url() + "/publish")
示例7: workflow_action_save_analyses_button
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def workflow_action_save_analyses_button(self):
form = self.request.form
workflow = getToolByName(self.context, 'portal_workflow')
action, came_from = WorkflowAction._get_form_workflow_action(self)
# AR Manage Analyses: save Analyses
ar = self.context
sample = ar.getSample()
objects = WorkflowAction._get_selected_items(self)
if not objects:
message = _("No analyses have been selected")
self.context.plone_utils.addPortalMessage(message, 'info')
self.destination_url = self.context.absolute_url() + "/analyses"
self.request.response.redirect(self.destination_url)
return
Analyses = objects.keys()
prices = form.get("Price", [None])[0]
specs = {}
if form.get("min", None):
for service_uid in Analyses:
specs[service_uid] = {
"min": form["min"][0][service_uid],
"max": form["max"][0][service_uid],
"error": form["error"][0][service_uid]
}
else:
for service_uid in Analyses:
specs[service_uid] = {"min": "", "max": "", "error": ""}
new = ar.setAnalyses(Analyses, prices=prices, specs=specs)
# link analyses and partitions
# If Bika Setup > Analyses > 'Display individual sample
# partitions' is checked, no Partitions available.
# https://github.com/bikalabs/Bika-LIMS/issues/1030
if 'Partition' in form:
for service_uid, service in objects.items():
part_id = form['Partition'][0][service_uid]
part = sample[part_id]
analysis = ar[service.getKeyword()]
analysis.setSamplePartition(part)
analysis.reindexObject()
if new:
for analysis in new:
# if the AR has progressed past sample_received, we need to bring it back.
ar_state = workflow.getInfoFor(ar, 'review_state')
if ar_state in ('attachment_due', 'to_be_verified'):
# Apply to AR only; we don't want this transition to cascade.
ar.REQUEST['workflow_skiplist'].append("retract all analyses")
workflow.doActionFor(ar, 'retract')
ar.REQUEST['workflow_skiplist'].remove("retract all analyses")
ar_state = workflow.getInfoFor(ar, 'review_state')
# Then we need to forward new analyses state
analysis.updateDueDate()
changeWorkflowState(analysis, 'bika_analysis_workflow', ar_state)
message = PMF("Changes saved.")
self.context.plone_utils.addPortalMessage(message, 'info')
self.destination_url = self.context.absolute_url()
self.request.response.redirect(self.destination_url)
示例8: __call__
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def __call__(self):
form = self.request.form
plone.protect.CheckAuthenticator(form)
action, _ = WorkflowAction._get_form_workflow_action(self)
if action == 'receive' and 'Type' in form:
BiospecimenWorkflowAction.__call__(self)
elif action == 'receive' and 'AliquotType' in form:
AliquotWorkflowAction.__call__(self)
else:
WorkflowAction.__call__(self)
示例9: workflow_action_keep
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def workflow_action_keep(self):
workflow = getToolByName(self.context, 'portal_workflow')
action, came_from = WorkflowAction._get_form_workflow_action(self)
objects = WorkflowAction._get_selected_items(self)
for obj_uid, obj in objects.items():
pitem = obj
old_d = pitem.Description()
new_message = "\n*** Restored in Inventory at " + time.strftime("%c") + " ***\n"
pitem.setDescription(old_d + new_message)
pitem.reindexObject()
workflow.doActionFor(pitem, action)
message = PMF("Changes saved.")
self.context.plone_utils.addPortalMessage(message, 'info')
self.destination_url = self.context.absolute_url()
self.request.response.redirect(self.destination_url)
示例10: workflow_action_receive
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def workflow_action_receive(self):
action, came_from = WorkflowAction._get_form_workflow_action(self)
items = [self.context] if came_from == "workflow_action" else self._get_selected_items().values()
trans, dest = self.submitTransition(action, came_from, items)
if trans and "receive" in self.context.bika_setup.getAutoPrintStickers():
transitioned = [item.id for item in items]
tmpl = self.context.bika_setup.getAutoStickerTemplate()
q = "/sticker?autoprint=1&template=%s&items=" % tmpl
q += ",".join(transitioned)
self.request.response.redirect(self.context.absolute_url() + q)
elif trans:
message = PMF("Changes saved.")
self.context.plone_utils.addPortalMessage(message, "info")
self.destination_url = self.context.absolute_url()
self.request.response.redirect(self.destination_url)
示例11: __call__
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def __call__(self):
form = self.request.form
plone.protect.CheckAuthenticator(form)
action, came_from = WorkflowAction._get_form_workflow_action(self)
if type(action) in (list, tuple):
action = action[0]
if type(came_from) in (list, tuple):
came_from = came_from[0]
# Call out to the workflow action method
# Use default bika_listing.py/WorkflowAction for other transitions
method_name = 'workflow_action_' + action
method = getattr(self, method_name, False)
if method:
method()
else:
WorkflowAction.__call__(self)
示例12: workflow_action_receive
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def workflow_action_receive(self):
action, came_from = WorkflowAction._get_form_workflow_action(self)
items = [self.context,] if came_from == 'workflow_action' \
else self._get_selected_items().values()
trans, dest = self.submitTransition(action, came_from, items)
if trans and 'receive' in self.context.bika_setup.getAutoPrintLabels():
transitioned = [item.id for item in items]
size = self.context.bika_setup.getAutoLabelSize()
q = "/sticker?size=%s&items=" % size
q += ",".join(transitioned)
self.request.response.redirect(self.context.absolute_url() + q)
elif trans:
message = PMF('Changes saved.')
self.context.plone_utils.addPortalMessage(message, 'info')
self.destination_url = self.context.absolute_url()
self.request.response.redirect(self.destination_url)
示例13: __call__
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def __call__(self):
form = self.request.form
CheckAuthenticator(form)
workflow = getToolByName(self.context, 'portal_workflow')
rc = getToolByName(self.context, REFERENCE_CATALOG)
action, came_from = WorkflowAction._get_form_workflow_action(self)
if action == 'reassign':
mtool = getToolByName(self.context, 'portal_membership')
if not mtool.checkPermission(ManageWorksheets, self.context):
# Redirect to WS list
msg = _('You do not have sufficient privileges to '
'manage worksheets.')
self.context.plone_utils.addPortalMessage(msg, 'warning')
portal = getToolByName(self.context, 'portal_url').getPortalObject()
self.destination_url = portal.absolute_url() + "/worksheets"
self.request.response.redirect(self.destination_url)
return
selected_worksheets = WorkflowAction._get_selected_items(self)
selected_worksheet_uids = selected_worksheets.keys()
if selected_worksheets:
changes = False
for uid in selected_worksheet_uids:
worksheet = selected_worksheets[uid]
# Double-check the state first
if workflow.getInfoFor(worksheet, 'review_state') == 'open':
worksheet.setAnalyst(form['Analyst'][0][uid])
worksheet.reindexObject(idxs=['getAnalyst'])
changes = True
if changes:
message = PMF('Changes saved.')
self.context.plone_utils.addPortalMessage(message, 'info')
self.destination_url = self.request.get_header("referer",
self.context.absolute_url())
self.request.response.redirect(self.destination_url)
else:
# default bika_listing.py/WorkflowAction for other transitions
WorkflowAction.__call__(self)
示例14: workflow_action_publish
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def workflow_action_publish(self):
action, came_from = WorkflowAction._get_form_workflow_action(self)
if not isActive(self.context):
message = _('Item is inactive.')
self.context.plone_utils.addPortalMessage(message, 'info')
self.request.response.redirect(self.context.absolute_url())
return
# publish entire AR.
self.context.setDatePublished(DateTime())
transitioned = self.doPublish(self.context,
self.request,
action,
[self.context, ])()
if len(transitioned) == 1:
message = _(
'${items} published.',
mapping={'items': safe_unicode(', '.join(transitioned))})
else:
message = _("No items were published")
self.context.plone_utils.addPortalMessage(message, 'info')
self.destination_url = self.request.get_header("referer",
self.context.absolute_url())
self.request.response.redirect(self.destination_url)
示例15: __call__
# 需要导入模块: from bika.lims.browser.bika_listing import WorkflowAction [as 别名]
# 或者: from bika.lims.browser.bika_listing.WorkflowAction import _get_form_workflow_action [as 别名]
def __call__(self):
form = self.request.form
plone.protect.CheckAuthenticator(form)
workflow = getToolByName(self.context, 'portal_workflow')
rc = getToolByName(self.context, REFERENCE_CATALOG)
bsc = getToolByName(self.context, 'bika_setup_catalog')
bac = getToolByName(self.context, 'bika_analysis_catalog')
action, came_from = WorkflowAction._get_form_workflow_action(self)
if action == 'submit':
# Submit the form. Saves the results, methods, etc.
self.submit()
## assign
elif action == 'assign':
if not self.context.checkUserManage():
self.request.response.redirect(self.context.absolute_url())
return
selected_analyses = WorkflowAction._get_selected_items(self)
selected_analysis_uids = selected_analyses.keys()
if selected_analyses:
for uid in selected_analysis_uids:
analysis = rc.lookupObject(uid)
# Double-check the state first
if (workflow.getInfoFor(analysis, 'worksheetanalysis_review_state') == 'unassigned'
and workflow.getInfoFor(analysis, 'review_state') == 'sample_received'
and workflow.getInfoFor(analysis, 'cancellation_state') == 'active'):
self.context.addAnalysis(analysis)
self.destination_url = self.context.absolute_url()
self.request.response.redirect(self.destination_url)
## unassign
elif action == 'unassign':
if not self.context.checkUserManage():
self.request.response.redirect(self.context.absolute_url())
return
selected_analyses = WorkflowAction._get_selected_items(self)
selected_analysis_uids = selected_analyses.keys()
for analysis_uid in selected_analysis_uids:
try:
analysis = bac(UID=analysis_uid)[0].getObject()
except IndexError:
# Duplicate analyses are removed when their analyses
# get removed, so indexerror is expected.
continue
if skip(analysis, action, peek=True):
continue
self.context.removeAnalysis(analysis)
message = PMF("Changes saved.")
self.context.plone_utils.addPortalMessage(message, 'info')
self.destination_url = self.context.absolute_url()
self.request.response.redirect(self.destination_url)
## verify
elif action == 'verify':
# default bika_listing.py/WorkflowAction, but then go to view screen.
self.destination_url = self.context.absolute_url()
return self.workflow_action_default(action='verify',
came_from='edit')
else:
# default bika_listing.py/WorkflowAction for other transitions
WorkflowAction.__call__(self)