_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21400 | PartitionMagicView.get_number_of_partitions_for | train | def get_number_of_partitions_for(self, ar):
"""Return the number of selected partitions
"""
# fetch the number of partitions from the request
uid = api.get_uid(ar)
num = self.request.get("primary", {}).get(uid)
if num is None:
# get the number of partitions f... | python | {
"resource": ""
} |
q21401 | PartitionMagicView.get_base_info | train | def get_base_info(self, obj):
"""Extract the base info from the given object
"""
obj = api.get_object(obj)
review_state = api.get_workflow_status_of(obj)
state_title = review_state.capitalize().replace("_", " ")
return {
"obj": obj,
"id": api.get_i... | python | {
"resource": ""
} |
q21402 | AccreditationView.selected_cats | train | def selected_cats(self, items):
"""return a list of all categories with accredited services
"""
cats = []
for item in items:
if 'category' in item and item['category'] not in cats:
cats.append(item['category'])
return cats | python | {
"resource": ""
} |
q21403 | AnalysisRequestPublishedResults.contentsMethod | train | def contentsMethod(self, contentFilter):
"""
ARReport objects associated to the current Analysis request.
If the user is not a Manager or LabManager or Client, no items are
displayed.
"""
allowedroles = ['Manager', 'LabManager', 'Client', 'LabClerk']
pm = getToolB... | python | {
"resource": ""
} |
q21404 | Report.add_filter_by_client | train | def add_filter_by_client(self, query, out_params):
"""Applies the filter by client to the search query
"""
current_client = logged_in_client(self.context)
if current_client:
query['getClientUID'] = api.get_uid(current_client)
elif self.request.form.get("ClientUID", ""... | python | {
"resource": ""
} |
q21405 | Report.add_filter_by_date | train | def add_filter_by_date(self, query, out_params):
"""Applies the filter by Requested date to the search query
"""
date_query = formatDateQuery(self.context, 'Requested')
if date_query:
query['created'] = date_query
requested = formatDateParms(self.context, 'Request... | python | {
"resource": ""
} |
q21406 | Report.add_filter_by_review_state | train | def add_filter_by_review_state(self, query, out_params):
"""Applies the filter by review_state to the search query
"""
self.add_filter_by_wf_state(query=query, out_params=out_params,
wf_id="bika_analysis_workflow",
index="re... | python | {
"resource": ""
} |
q21407 | Import | train | def Import(context, request):
""" Beckman Coulter Access 2 analysis results
"""
infile = request.form['rochecobas_taqman_model48_file']
fileformat = request.form['rochecobas_taqman_model48_format']
artoapply = request.form['rochecobas_taqman_model48_artoapply']
override = request.form['rochecoba... | python | {
"resource": ""
} |
q21408 | Attachment.getClientUID | train | def getClientUID(self):
"""Return the UID of the client
"""
client = api.get_parent(self)
if not client:
return ""
return api.get_uid(client) | python | {
"resource": ""
} |
q21409 | Attachment.getLinkedRequests | train | def getLinkedRequests(self):
"""Lookup linked Analysis Requests
:returns: sorted list of ARs, where the latest AR comes first
"""
rc = api.get_tool("reference_catalog")
refs = rc.getBackReferences(self, "AnalysisRequestAttachment")
# fetch the objects by UID and handle n... | python | {
"resource": ""
} |
q21410 | Attachment.getLinkedAnalyses | train | def getLinkedAnalyses(self):
"""Lookup linked Analyses
:returns: sorted list of ANs, where the latest AN comes first
"""
# Fetch the linked Analyses UIDs
refs = get_backreferences(self, "AnalysisAttachment")
# fetch the objects by UID and handle nonexisting UIDs graceful... | python | {
"resource": ""
} |
q21411 | Attachment.getTextTitle | train | def getTextTitle(self):
"""Return a title for texts and listings
"""
request_id = self.getRequestID()
if not request_id:
return ""
analysis = self.getAnalysis()
if not analysis:
return request_id
return "%s - %s" % (request_id, analysis.T... | python | {
"resource": ""
} |
q21412 | Attachment.getRequest | train | def getRequest(self):
"""Return the primary AR this attachment is linked
"""
ars = self.getLinkedRequests()
if len(ars) > 1:
# Attachment is assigned to more than one Analysis Request.
# This might happen when the AR was invalidated
ar_ids = ", ".join... | python | {
"resource": ""
} |
q21413 | Attachment.getAnalysis | train | def getAnalysis(self):
"""Return the primary analysis this attachment is linked
"""
analysis = None
ans = self.getLinkedAnalyses()
if len(ans) > 1:
# Attachment is assigned to more than one Analysis. This might
# happen when the AR was invalidated
... | python | {
"resource": ""
} |
q21414 | Method.getInstrumentsDisplayList | train | def getInstrumentsDisplayList(self):
"""Instruments capable to perform this method
"""
items = [(i.UID(), i.Title()) for i in self.getInstruments()]
return DisplayList(list(items)) | python | {
"resource": ""
} |
q21415 | FrontPageView.get_user_roles | train | def get_user_roles(self):
"""Returns a list of roles for the current user
"""
if self.is_anonymous_user():
return []
current_user = ploneapi.user.get_current()
return ploneapi.user.get_roles(user=current_user) | python | {
"resource": ""
} |
q21416 | FrontPageView.set_versions | train | def set_versions(self):
"""Configure a list of product versions from portal.quickinstaller
"""
self.versions = {}
self.upgrades = {}
qi = getToolByName(self.context, "portal_quickinstaller")
for key in qi.keys():
self.versions[key] = qi.getProductVersion(key)
... | python | {
"resource": ""
} |
q21417 | SamplingRound.getAnalysisRequests | train | def getAnalysisRequests(self):
""" Return all the Analysis Request brains linked to the Sampling Round
"""
# I have to get the catalog in this way because I can't do it with 'self'...
pc = getToolByName(api.portal.get(), 'portal_catalog')
contentFilter = {'portal_type': 'Analysis... | python | {
"resource": ""
} |
q21418 | SamplingRound.getClientContact | train | def getClientContact(self):
"""
Returns info from the Client contact who coordinates with the lab
"""
pc = getToolByName(api.portal.get(), 'portal_catalog')
contentFilter = {'portal_type': 'Contact',
'id': self.client_contact}
cnt = pc(contentFilt... | python | {
"resource": ""
} |
q21419 | SamplingRound.workflow_script_cancel | train | def workflow_script_cancel(self):
"""
When the round is cancelled, all its associated Samples and ARs are cancelled by the system.
"""
if skip(self, "cancel"):
return
self.reindexObject(idxs=["is_active", ])
# deactivate all analysis requests in this sampling ... | python | {
"resource": ""
} |
q21420 | AnalysisRequestAddView.get_view_url | train | def get_view_url(self):
"""Return the current view url including request parameters
"""
request = self.request
url = request.getURL()
qs = request.getHeader("query_string")
if not qs:
return url
return "{}?{}".format(url, qs) | python | {
"resource": ""
} |
q21421 | AnalysisRequestAddView.get_currency | train | def get_currency(self):
"""Returns the configured currency
"""
bika_setup = api.get_bika_setup()
currency = bika_setup.getCurrency()
currencies = locales.getLocale('en').numbers.currencies
return currencies[currency] | python | {
"resource": ""
} |
q21422 | AnalysisRequestAddView.get_ar_count | train | def get_ar_count(self):
"""Return the ar_count request paramteter
"""
ar_count = 1
try:
ar_count = int(self.request.form.get("ar_count", 1))
except (TypeError, ValueError):
ar_count = 1
return ar_count | python | {
"resource": ""
} |
q21423 | AnalysisRequestAddView.get_ar | train | def get_ar(self):
"""Create a temporary AR to fetch the fields from
"""
if not self.tmp_ar:
logger.info("*** CREATING TEMPORARY AR ***")
self.tmp_ar = self.context.restrictedTraverse(
"portal_factory/AnalysisRequest/Request new analyses")
return se... | python | {
"resource": ""
} |
q21424 | AnalysisRequestAddView.generate_specifications | train | def generate_specifications(self, count=1):
"""Returns a mapping of count -> specification
"""
out = {}
# mapping of UID index to AR objects {1: <AR1>, 2: <AR2> ...}
copy_from = self.get_copy_from()
for arnum in range(count):
# get the source object
... | python | {
"resource": ""
} |
q21425 | AnalysisRequestAddView.get_copy_from | train | def get_copy_from(self):
"""Returns a mapping of UID index -> AR object
"""
# Create a mapping of source ARs for copy
copy_from = self.request.form.get("copy_from", "").split(",")
# clean out empty strings
copy_from_uids = filter(lambda x: x, copy_from)
out = dict... | python | {
"resource": ""
} |
q21426 | AnalysisRequestAddView.get_default_value | train | def get_default_value(self, field, context, arnum):
"""Get the default value of the field
"""
name = field.getName()
default = field.getDefault(context)
if name == "Batch":
batch = self.get_batch()
if batch is not None:
default = batch
... | python | {
"resource": ""
} |
q21427 | AnalysisRequestAddView.get_field_value | train | def get_field_value(self, field, context):
"""Get the stored value of the field
"""
name = field.getName()
value = context.getField(name).get(context)
logger.info("get_field_value: context={} field={} value={}".format(
context, name, value))
return value | python | {
"resource": ""
} |
q21428 | AnalysisRequestAddView.get_client | train | def get_client(self):
"""Returns the Client
"""
context = self.context
parent = api.get_parent(context)
if context.portal_type == "Client":
return context
elif parent.portal_type == "Client":
return parent
elif context.portal_type == "Batch... | python | {
"resource": ""
} |
q21429 | AnalysisRequestAddView.get_batch | train | def get_batch(self):
"""Returns the Batch
"""
context = self.context
parent = api.get_parent(context)
if context.portal_type == "Batch":
return context
elif parent.portal_type == "Batch":
return parent
return None | python | {
"resource": ""
} |
q21430 | AnalysisRequestAddView.get_parent_ar | train | def get_parent_ar(self, ar):
"""Returns the parent AR
"""
parent = ar.getParentAnalysisRequest()
# Return immediately if we have no parent
if parent is None:
return None
# Walk back the chain until we reach the source AR
while True:
ppare... | python | {
"resource": ""
} |
q21431 | AnalysisRequestAddView.is_field_visible | train | def is_field_visible(self, field):
"""Check if the field is visible
"""
context = self.context
fieldname = field.getName()
# hide the Client field on client and batch contexts
if fieldname == "Client" and context.portal_type in ("Client", ):
return False
... | python | {
"resource": ""
} |
q21432 | AnalysisRequestAddView.get_fields_with_visibility | train | def get_fields_with_visibility(self, visibility, mode="add"):
"""Return the AR fields with the current visibility
"""
ar = self.get_ar()
mv = api.get_view("ar_add_manage", context=ar)
mv.get_field_order()
out = []
for field in mv.get_fields_with_visibility(visibi... | python | {
"resource": ""
} |
q21433 | AnalysisRequestAddView.get_service_categories | train | def get_service_categories(self, restricted=True):
"""Return all service categories in the right order
:param restricted: Client settings restrict categories
:type restricted: bool
:returns: Category catalog results
:rtype: brains
"""
bsc = api.get_tool("bika_set... | python | {
"resource": ""
} |
q21434 | AnalysisRequestAddView.get_services | train | def get_services(self, poc="lab"):
"""Return all Services
:param poc: Point of capture (lab/field)
:type poc: string
:returns: Mapping of category -> list of services
:rtype: dict
"""
bsc = api.get_tool("bika_setup_catalog")
query = {
"portal_... | python | {
"resource": ""
} |
q21435 | AnalysisRequestAddView.get_service_uid_from | train | def get_service_uid_from(self, analysis):
"""Return the service from the analysis
"""
analysis = api.get_object(analysis)
return api.get_uid(analysis.getAnalysisService()) | python | {
"resource": ""
} |
q21436 | AnalysisRequestAddView.is_service_selected | train | def is_service_selected(self, service):
"""Checks if the given service is selected by one of the ARs.
This is used to make the whole line visible or not.
"""
service_uid = api.get_uid(service)
for arnum in range(self.ar_count):
analyses = self.fieldvalues.get("Analyse... | python | {
"resource": ""
} |
q21437 | AnalysisRequestManageView.get_sorted_fields | train | def get_sorted_fields(self):
"""Return the sorted fields
"""
inf = float("inf")
order = self.get_field_order()
def field_cmp(field1, field2):
_n1 = field1.getName()
_n2 = field2.getName()
_i1 = _n1 in order and order.index(_n1) + 1 or inf
... | python | {
"resource": ""
} |
q21438 | AnalysisRequestManageView.get_fields_with_visibility | train | def get_fields_with_visibility(self, visibility="edit", mode="add"):
"""Return the fields with visibility
"""
fields = self.get_sorted_fields()
out = []
for field in fields:
v = field.widget.isVisible(
self.context, mode, default='invisible', field=f... | python | {
"resource": ""
} |
q21439 | ajaxAnalysisRequestAddView.to_iso_date | train | def to_iso_date(self, dt):
"""Return the ISO representation of a date object
"""
if dt is None:
return ""
if isinstance(dt, DateTime):
return dt.ISO8601()
if isinstance(dt, datetime):
return dt.isoformat()
raise TypeError("{} is neiter ... | python | {
"resource": ""
} |
q21440 | ajaxAnalysisRequestAddView.get_records | train | def get_records(self):
"""Returns a list of AR records
Fields coming from `request.form` have a number prefix, e.g. Contact-0.
Fields with the same suffix number are grouped together in a record.
Each record represents the data for one column in the AR Add form and
contains a ma... | python | {
"resource": ""
} |
q21441 | ajaxAnalysisRequestAddView.get_uids_from_record | train | def get_uids_from_record(self, record, key):
"""Returns a list of parsed UIDs from a single form field identified by
the given key.
A form field ending with `_uid` can contain an empty value, a
single UID or multiple UIDs separated by a comma.
This method parses the UID value a... | python | {
"resource": ""
} |
q21442 | ajaxAnalysisRequestAddView.get_objs_from_record | train | def get_objs_from_record(self, record, key):
"""Returns a mapping of UID -> object
"""
uids = self.get_uids_from_record(record, key)
objs = map(self.get_object_by_uid, uids)
return dict(zip(uids, objs)) | python | {
"resource": ""
} |
q21443 | ajaxAnalysisRequestAddView.get_base_info | train | def get_base_info(self, obj):
"""Returns the base info of an object
"""
if obj is None:
return {}
info = {
"id": obj.getId(),
"uid": obj.UID(),
"title": obj.Title(),
"description": obj.Description(),
"url": obj.abso... | python | {
"resource": ""
} |
q21444 | ajaxAnalysisRequestAddView.get_service_info | train | def get_service_info(self, obj):
"""Returns the info for a Service
"""
info = self.get_base_info(obj)
info.update({
"short_title": obj.getShortTitle(),
"scientific_name": obj.getScientificName(),
"unit": obj.getUnit(),
"keyword": obj.getKe... | python | {
"resource": ""
} |
q21445 | ajaxAnalysisRequestAddView.get_template_info | train | def get_template_info(self, obj):
"""Returns the info for a Template
"""
client = self.get_client()
client_uid = api.get_uid(client) if client else ""
profile = obj.getAnalysisProfile()
profile_uid = api.get_uid(profile) if profile else ""
profile_title = profile... | python | {
"resource": ""
} |
q21446 | ajaxAnalysisRequestAddView.get_profile_info | train | def get_profile_info(self, obj):
"""Returns the info for a Profile
"""
info = self.get_base_info(obj)
info.update({})
return info | python | {
"resource": ""
} |
q21447 | ajaxAnalysisRequestAddView.get_method_info | train | def get_method_info(self, obj):
"""Returns the info for a Method
"""
info = self.get_base_info(obj)
info.update({})
return info | python | {
"resource": ""
} |
q21448 | ajaxAnalysisRequestAddView.get_calculation_info | train | def get_calculation_info(self, obj):
"""Returns the info for a Calculation
"""
info = self.get_base_info(obj)
info.update({})
return info | python | {
"resource": ""
} |
q21449 | ajaxAnalysisRequestAddView.get_sampletype_info | train | def get_sampletype_info(self, obj):
"""Returns the info for a Sample Type
"""
info = self.get_base_info(obj)
# Bika Setup folder
bika_setup = api.get_bika_setup()
# bika samplepoints
bika_samplepoints = bika_setup.bika_samplepoints
bika_samplepoints_uid ... | python | {
"resource": ""
} |
q21450 | ajaxAnalysisRequestAddView.get_sample_info | train | def get_sample_info(self, obj):
"""Returns the info for a Sample
"""
info = self.get_base_info(obj)
# sample type
sample_type = obj.getSampleType()
sample_type_uid = sample_type and sample_type.UID() or ""
sample_type_title = sample_type and sample_type.Title() o... | python | {
"resource": ""
} |
q21451 | ajaxAnalysisRequestAddView.get_specification_info | train | def get_specification_info(self, obj):
"""Returns the info for a Specification
"""
info = self.get_base_info(obj)
results_range = obj.getResultsRange()
info.update({
"results_range": results_range,
"sample_type_uid": obj.getSampleTypeUID(),
"s... | python | {
"resource": ""
} |
q21452 | ajaxAnalysisRequestAddView.get_container_info | train | def get_container_info(self, obj):
"""Returns the info for a Container
"""
info = self.get_base_info(obj)
info.update({})
return info | python | {
"resource": ""
} |
q21453 | ajaxAnalysisRequestAddView.get_preservation_info | train | def get_preservation_info(self, obj):
"""Returns the info for a Preservation
"""
info = self.get_base_info(obj)
info.update({})
return info | python | {
"resource": ""
} |
q21454 | ajaxAnalysisRequestAddView.ajax_get_service | train | def ajax_get_service(self):
"""Returns the services information
"""
uid = self.request.form.get("uid", None)
if uid is None:
return self.error("Invalid UID", status=400)
service = self.get_object_by_uid(uid)
if not service:
return self.error("Ser... | python | {
"resource": ""
} |
q21455 | ajaxAnalysisRequestAddView.ajax_recalculate_prices | train | def ajax_recalculate_prices(self):
"""Recalculate prices for all ARs
"""
# When the option "Include and display pricing information" in
# Bika Setup Accounting tab is not selected
if not self.show_recalculate_prices():
return {}
# The sorted records from the ... | python | {
"resource": ""
} |
q21456 | GeneXpertParser._handle_header | train | def _handle_header(self, sline):
"""
A function for lines with only ONE COLUMN.
If line has only one column, then it is either a Section or
Subsection name.
"""
# All characters UPPER CASE means it is a Section.
if sline[0].isupper():
self._cur_section... | python | {
"resource": ""
} |
q21457 | GeneXpertParser._submit_result | train | def _submit_result(self):
"""
Adding current values as a Raw Result and Resetting everything.
Notice that we are not calculating final result of assay. We just set
NP and GP values and in Bika, AS will have a Calculation to generate
final result based on NP and GP values.
... | python | {
"resource": ""
} |
q21458 | GeneXpertParser._format_keyword | train | def _format_keyword(self, keyword):
"""
Removing special character from a keyword. Analysis Services must have
this kind of keywords. E.g. if assay name from GeneXpert Instrument is
'Ebola RUO', an AS must be created on Bika with the keyword 'EbolaRUO'
"""
import re
... | python | {
"resource": ""
} |
q21459 | ManageResultsView.get_instrument_title | train | def get_instrument_title(self):
"""Return the current instrument title
"""
instrument = self.context.getInstrument()
if not instrument:
return ""
return api.get_title(instrument) | python | {
"resource": ""
} |
q21460 | ManageResultsView.is_assignment_allowed | train | def is_assignment_allowed(self):
"""Check if analyst assignment is allowed
"""
if not self.is_manage_allowed():
return False
review_state = api.get_workflow_status_of(self.context)
edit_states = ["open", "attachment_due", "to_be_verified"]
return review_state ... | python | {
"resource": ""
} |
q21461 | ManageResultsView.get_wide_interims | train | def get_wide_interims(self):
"""Returns a dictionary with the analyses services from the current
worksheet which have at least one interim with 'Wide' attribute set to
true and that have not been yet submitted
The structure of the returned dictionary is the following:
<Analysis_... | python | {
"resource": ""
} |
q21462 | editableFields | train | def editableFields(self, instance, visible_only=False):
"""Returns a list of editable fields for the given instance
"""
ret = []
portal = getToolByName(instance, 'portal_url').getPortalObject()
for field in self.fields():
if field.writeable(instance, debug=False) and \
(not... | python | {
"resource": ""
} |
q21463 | isVisible | train | def isVisible(self, instance, mode='view', default="visible", field=None):
"""decide if a field is visible in a given mode -> 'state'.
"""
# Emulate Products.Archetypes.Widget.TypesWidget#isVisible first
vis_dic = getattr(aq_base(self), 'visible', _marker)
state = default
if vis_dic is _marker:
... | python | {
"resource": ""
} |
q21464 | skip | train | def skip(instance, action, peek=False, unskip=False):
"""Returns True if the transition is to be SKIPPED
peek - True just checks the value, does not set.
unskip - remove skip key (for manual overrides).
called with only (instance, action_id), this will set the request variable preventing the
... | python | {
"resource": ""
} |
q21465 | call_workflow_event | train | def call_workflow_event(instance, event, after=True):
"""Calls the instance's workflow event
"""
if not event.transition:
return False
portal_type = instance.portal_type
wf_module = _load_wf_module('{}.events'.format(portal_type.lower()))
if not wf_module:
return False
# In... | python | {
"resource": ""
} |
q21466 | get_workflow_actions | train | def get_workflow_actions(obj):
""" Compile a list of possible workflow transitions for this object
"""
def translate(id):
return t(PMF(id + "_transition_title"))
transids = getAllowedTransitions(obj)
actions = [{'id': it, 'title': translate(it)} for it in transids]
return actions | python | {
"resource": ""
} |
q21467 | get_review_history_statuses | train | def get_review_history_statuses(instance, reverse=False):
"""Returns a list with the statuses of the instance from the review_history
"""
review_history = getReviewHistory(instance, reverse=reverse)
return map(lambda event: event["review_state"], review_history) | python | {
"resource": ""
} |
q21468 | get_prev_status_from_history | train | def get_prev_status_from_history(instance, status=None):
"""Returns the previous status of the object. If status is set, returns the
previous status before the object reached the status passed in.
If instance has reached the status passed in more than once, only the last
one is considered.
"""
t... | python | {
"resource": ""
} |
q21469 | in_state | train | def in_state(obj, states, stateflowid='review_state'):
""" Returns if the object passed matches with the states passed in
"""
if not states:
return False
obj_state = getCurrentState(obj, stateflowid=stateflowid)
return obj_state in states | python | {
"resource": ""
} |
q21470 | getTransitionDate | train | def getTransitionDate(obj, action_id, return_as_datetime=False):
"""
Returns date of action for object. Sometimes we need this date in Datetime
format and that's why added return_as_datetime param.
"""
review_history = getReviewHistory(obj)
for event in review_history:
if event.get('acti... | python | {
"resource": ""
} |
q21471 | guard_handler | train | def guard_handler(instance, transition_id):
"""Generic workflow guard handler that returns true if the transition_id
passed in can be performed to the instance passed in.
This function is called automatically by a Script (Python) located at
bika/lims/skins/guard_handler.py, which in turn is fired by Zo... | python | {
"resource": ""
} |
q21472 | _load_wf_module | train | def _load_wf_module(module_relative_name):
"""Loads a python module based on the module relative name passed in.
At first, tries to get the module from sys.modules. If not found there, the
function tries to load it by using importlib. Returns None if no module
found or importlib is unable to load it be... | python | {
"resource": ""
} |
q21473 | push_reindex_to_actions_pool | train | def push_reindex_to_actions_pool(obj, idxs=None):
"""Push a reindex job to the actions handler pool
"""
indexes = idxs and idxs or []
pool = ActionHandlerPool.get_instance()
pool.push(obj, "reindex", success=True, idxs=indexes) | python | {
"resource": ""
} |
q21474 | ActionHandlerPool.push | train | def push(self, instance, action, success, idxs=_marker):
"""Adds an instance into the pool, to be reindexed on resume
"""
uid = api.get_uid(instance)
info = self.objects.get(uid, {})
idx = [] if idxs is _marker else idxs
info[action] = {'success': success, 'idxs': idx}
... | python | {
"resource": ""
} |
q21475 | ActionHandlerPool.succeed | train | def succeed(self, instance, action):
"""Returns if the task for the instance took place successfully
"""
uid = api.get_uid(instance)
return self.objects.get(uid, {}).get(action, {}).get('success', False) | python | {
"resource": ""
} |
q21476 | ActionHandlerPool.resume | train | def resume(self):
"""Resumes the pool and reindex all objects processed
"""
self.num_calls -= 1
if self.num_calls > 0:
return
logger.info("Resume actions for {} objects".format(len(self)))
# Fetch the objects from the pool
processed = list()
f... | python | {
"resource": ""
} |
q21477 | WorkflowMenu.getMenuItems | train | def getMenuItems(self, context, request):
"""Overrides the workflow actions menu displayed top right in the
object's view. Displays the current state of the object, as well as a
list with the actions that can be performed.
The option "Advanced.." is not displayed and the list is populate... | python | {
"resource": ""
} |
q21478 | WorkflowActionReceiveAdapter.is_auto_partition_required | train | def is_auto_partition_required(self, brain_or_object):
"""Returns whether the passed in object needs to be partitioned
"""
obj = api.get_object(brain_or_object)
if not IAnalysisRequest.providedBy(obj):
return False
template = obj.getTemplate()
return template ... | python | {
"resource": ""
} |
q21479 | WorkflowActionInvalidateAdapter.notify_ar_retract | train | def notify_ar_retract(self, sample):
"""Sends an email notification to sample's client contact if the sample
passed in has a retest associated
"""
retest = sample.getRetest()
if not retest:
logger.warn("No retest found for {}. And it should!"
.... | python | {
"resource": ""
} |
q21480 | WorkflowActionInvalidateAdapter.get_email_body | train | def get_email_body(self, sample):
"""Returns the email body text
"""
retest = sample.getRetest()
lab_address = api.get_bika_setup().laboratory.getPrintAddress()
setup = api.get_setup()
body = Template(setup.getEmailBodySampleInvalidation())\
.safe_substitute(
... | python | {
"resource": ""
} |
q21481 | WorkflowActionInvalidateAdapter.get_laboratory_formatted_email | train | def get_laboratory_formatted_email(self):
"""Returns the laboratory email formatted
"""
lab = api.get_bika_setup().laboratory
return self.get_formatted_email((lab.getName(), lab.getEmailAddress())) | python | {
"resource": ""
} |
q21482 | WorkflowActionInvalidateAdapter.get_lab_managers_formatted_emails | train | def get_lab_managers_formatted_emails(self):
"""Returns a list with lab managers formatted emails
"""
users = api.get_users_by_roles("LabManager")
users = map(lambda user: (user.getProperty("fullname"),
user.getProperty("email")), users)
return m... | python | {
"resource": ""
} |
q21483 | WorkflowActionInvalidateAdapter.get_contact_formatted_email | train | def get_contact_formatted_email(self, contact):
"""Returns a string with the formatted email for the given contact
"""
contact_name = contact.Title()
contact_email = contact.getEmailAddress()
return self.get_formatted_email((contact_name, contact_email)) | python | {
"resource": ""
} |
q21484 | WorkflowActionInvalidateAdapter.get_sample_contacts_formatted_emails | train | def get_sample_contacts_formatted_emails(self, sample):
"""Returns a list with the formatted emails from sample contacts
"""
contacts = list(set([sample.getContact()] + sample.getCCContact()))
return map(self.get_contact_formatted_email, contacts) | python | {
"resource": ""
} |
q21485 | WorkflowActionInvalidateAdapter.get_html_link | train | def get_html_link(self, obj):
"""Returns an html formatted link for the given object
"""
return "<a href='{}'>{}</a>".format(api.get_url(obj), api.get_id(obj)) | python | {
"resource": ""
} |
q21486 | WorkflowActionPrintSampleAdapter.set_printed_time | train | def set_printed_time(self, sample):
"""Updates the printed time of the last results report from the sample
"""
if api.get_workflow_status_of(sample) != "published":
return False
reports = sample.objectValues("ARReport")
reports = sorted(reports, key=lambda report: rep... | python | {
"resource": ""
} |
q21487 | WorkflowActionSampleAdapter.set_sampler_info | train | def set_sampler_info(self, sample):
"""Updates the Sampler and the Sample Date with the values provided in
the request. If neither Sampler nor SampleDate are present in the
request, returns False
"""
if sample.getSampler() and sample.getDateSampled():
# Sampler and Da... | python | {
"resource": ""
} |
q21488 | WorkflowActionPreserveAdapter.set_preserver_info | train | def set_preserver_info(self, sample):
"""Updates the Preserver and the Date Preserved with the values provided
in the request. If neither Preserver nor DatePreserved are present in
the request, returns False
"""
if sample.getPreserver() and sample.getDatePreserved():
... | python | {
"resource": ""
} |
q21489 | WorkflowActionScheduleSamplingAdapter.set_sampling_info | train | def set_sampling_info(self, sample):
"""Updates the scheduled Sampling sampler and the Sampling Date with the
values provided in the request. If neither Sampling sampler nor Sampling
Date are present in the request, returns False
"""
if sample.getScheduledSamplingSampler() and sa... | python | {
"resource": ""
} |
q21490 | WorkflowActionSaveAnalysesAdapter.is_hidden | train | def is_hidden(self, service):
"""Returns whether the request Hidden param for the given obj is True
"""
uid = api.get_uid(service)
hidden_ans = self.request.form.get("Hidden", {})
return hidden_ans.get(uid, "") == "on" | python | {
"resource": ""
} |
q21491 | WorkflowActionSaveAnalysesAdapter.get_specs | train | def get_specs(self, service):
"""Returns the analysis specs available in the request for the given uid
"""
uid = api.get_uid(service)
keyword = service.getKeyword()
specs = ResultsRangeDict(keyword=keyword, uid=uid).copy()
for key in specs.keys():
specs_value ... | python | {
"resource": ""
} |
q21492 | DefaultReferenceWidgetVocabulary.search_fields | train | def search_fields(self):
"""Returns the object field names to search against
"""
search_fields = self.request.get("search_fields", None)
if not search_fields:
return []
search_fields = json.loads(_u(search_fields))
return search_fields | python | {
"resource": ""
} |
q21493 | DefaultReferenceWidgetVocabulary.search_term | train | def search_term(self):
"""Returns the search term
"""
search_term = _c(self.request.get("searchTerm", ""))
return search_term.lower().strip() | python | {
"resource": ""
} |
q21494 | DefaultReferenceWidgetVocabulary.get_query_from_request | train | def get_query_from_request(self, name):
"""Returns the query inferred from the request
"""
query = self.request.get(name, "{}")
# json.loads does unicode conversion, which will fail in the catalog
# search for some cases. So we need to convert the strings to utf8
# https:... | python | {
"resource": ""
} |
q21495 | DefaultReferenceWidgetVocabulary.get_raw_query | train | def get_raw_query(self):
"""Returns the raw query to use for current search, based on the
base query + update query
"""
query = self.base_query.copy()
search_query = self.search_query.copy()
query.update(search_query)
# Add sorting criteria
sorting = self... | python | {
"resource": ""
} |
q21496 | DefaultReferenceWidgetVocabulary.resolve_sorting | train | def resolve_sorting(self, query):
"""Resolves the sorting criteria for the given query
"""
sorting = {}
# Sort on
sort_on = query.get("sidx", None)
sort_on = sort_on or query.get("sort_on", None)
sort_on = sort_on == "Title" and "sortable_title" or sort_on
... | python | {
"resource": ""
} |
q21497 | DefaultReferenceWidgetVocabulary.is_sortable_index | train | def is_sortable_index(self, index_name, catalog):
"""Returns whether the index is sortable
"""
index = self.get_index(index_name, catalog)
if not index:
return False
return index.meta_type in ["FieldIndex", "DateIndex"] | python | {
"resource": ""
} |
q21498 | DefaultReferenceWidgetVocabulary.get_index | train | def get_index(self, field_name, catalog):
"""Returns the index of the catalog for the given field_name, if any
"""
index = catalog.Indexes.get(field_name, None)
if not index and field_name == "Title":
# Legacy
return self.get_index("sortable_title", catalog)
... | python | {
"resource": ""
} |
q21499 | DefaultReferenceWidgetVocabulary.search | train | def search(self, query, search_term, search_field, catalog):
"""Performs a search against the catalog and returns the brains
"""
logger.info("Reference Widget Catalog: {}".format(catalog.id))
if not search_term:
return catalog(query)
index = self.get_index(search_fie... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.