_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21300 | Import | train | def Import(context, request, instrumentname='sysmex_xs_500i'):
""" Sysmex XS - 500i analysis results
"""
# I don't really know how this file works, for this reason I added an 'Analysis Service selector'.
# If non Analysis Service is selected, each 'data' column will be interpreted as a different Analysi... | python | {
"resource": ""
} |
q21301 | notify_rejection | train | def notify_rejection(analysisrequest):
"""
Notifies via email that a given Analysis Request has been rejected. The
notification is sent to the Client contacts assigned to the Analysis
Request.
:param analysisrequest: Analysis Request to which the notification refers
:returns: true if success
... | python | {
"resource": ""
} |
q21302 | fields_to_dict | train | def fields_to_dict(obj, skip_fields=None):
"""
Generates a dictionary with the field values of the object passed in, where
keys are the field names. Skips computed fields
"""
data = {}
obj = api.get_object(obj)
for field_name, field in api.get_fields(obj).items():
if skip_fields and ... | python | {
"resource": ""
} |
q21303 | update_permissions_rejected_analysis_requests | train | def update_permissions_rejected_analysis_requests():
"""
Maps and updates the permissions for rejected analysis requests so lab clerks, clients, owners and
RegulatoryInspector can see rejected analysis requests on lists.
:return: None
"""
workflow_tool = api.get_tool("portal_workflow")
work... | python | {
"resource": ""
} |
q21304 | migrate_to_blob | train | def migrate_to_blob(context, portal_type, query={}, remove_old_value=True):
"""Migrates FileFields fields to blob ones for a given portal_type.
The wueries are done against 'portal_catalog', 'uid_catalog' and
'reference_catalog'
:param context: portal root object as context
:param query: an express... | python | {
"resource": ""
} |
q21305 | makeMigrator | train | def makeMigrator(context, portal_type, remove_old_value=True):
""" generate a migrator for the given at-based portal type """
meta_type = portal_type
class BlobMigrator(BaseInlineMigrator):
"""in-place migrator for archetypes based content that copies
file/image data from old non-blob field... | python | {
"resource": ""
} |
q21306 | BikaCustomQueryWalker.walk | train | def walk(self):
"""
Walks around and returns all objects which needs migration
It does exactly the same as the original method, but add some
progress loggers.
:return: objects (with acquisition wrapper) that needs migration
:rtype: generator
"""
catalog =... | python | {
"resource": ""
} |
q21307 | UpgradeUtils.refreshCatalogs | train | def refreshCatalogs(self):
"""
It reindexes the modified catalogs but, while cleanAndRebuildCatalogs
recatalogs all objects in the database, this method only reindexes over
the already cataloged objects.
If a metacolumn is added it refreshes the catalog, if only a new index
... | python | {
"resource": ""
} |
q21308 | UpgradeUtils.recursiveUpdateRoleMappings | train | def recursiveUpdateRoleMappings(self, ob, wfs=None, commit_window=1000):
"""Code taken from Products.CMFPlone.WorkflowTool
This version adds some commits and loggins
"""
wf_tool = api.get_tool("portal_workflow")
if wfs is None:
wfs = {}
for id in wf_tool... | python | {
"resource": ""
} |
q21309 | Worksheet.addAnalyses | train | def addAnalyses(self, analyses):
"""Adds a collection of analyses to the Worksheet at once
"""
actions_pool = ActionHandlerPool.get_instance()
actions_pool.queue_pool()
for analysis in analyses:
self.addAnalysis(api.get_object(analysis))
actions_pool.resume() | python | {
"resource": ""
} |
q21310 | Worksheet.removeAnalysis | train | def removeAnalysis(self, analysis):
""" Unassigns the analysis passed in from the worksheet.
Delegates to 'unassign' transition for the analysis passed in
"""
# We need to bypass the guard's check for current context!
api.get_request().set("ws_uid", api.get_uid(self))
if ... | python | {
"resource": ""
} |
q21311 | Worksheet.addToLayout | train | def addToLayout(self, analysis, position=None):
""" Adds the analysis passed in to the worksheet's layout
"""
# TODO Redux
layout = self.getLayout()
container_uid = self.get_container_for(analysis)
if IRequestAnalysis.providedBy(analysis) and \
not IDuplic... | python | {
"resource": ""
} |
q21312 | Worksheet.purgeLayout | train | def purgeLayout(self):
""" Purges the layout of not assigned analyses
"""
uids = map(api.get_uid, self.getAnalyses())
layout = filter(lambda slot: slot.get("analysis_uid", None) in uids,
self.getLayout())
self.setLayout(layout) | python | {
"resource": ""
} |
q21313 | Worksheet._getInstrumentsVoc | train | def _getInstrumentsVoc(self):
"""
This function returns the registered instruments in the system as a
vocabulary. The instruments are filtered by the selected method.
"""
cfilter = {'portal_type': 'Instrument', 'is_active': True}
if self.getMethod():
cfilter['... | python | {
"resource": ""
} |
q21314 | Worksheet.nextRefAnalysesGroupID | train | def nextRefAnalysesGroupID(self, reference):
""" Returns the next ReferenceAnalysesGroupID for the given reference
sample. Gets the last reference analysis registered in the system
for the specified reference sample and increments in one unit the
suffix.
"""
p... | python | {
"resource": ""
} |
q21315 | Worksheet.get_suitable_slot_for_duplicate | train | def get_suitable_slot_for_duplicate(self, src_slot):
"""Returns the suitable position for a duplicate analysis, taking into
account if there is a WorksheetTemplate assigned to this worksheet.
By default, returns a new slot at the end of the worksheet unless there
is a slot defined for a... | python | {
"resource": ""
} |
q21316 | Worksheet.get_suitable_slot_for_reference | train | def get_suitable_slot_for_reference(self, reference):
"""Returns the suitable position for reference analyses, taking into
account if there is a WorksheetTemplate assigned to this worksheet.
By default, returns a new slot at the end of the worksheet unless there
is a slot defined for a ... | python | {
"resource": ""
} |
q21317 | Worksheet.get_duplicates_for | train | def get_duplicates_for(self, analysis):
"""Returns the duplicates from the current worksheet that were created
by using the analysis passed in as the source
:param analysis: routine analyses used as the source for the duplicates
:return: a list of duplicates generated from the analysis ... | python | {
"resource": ""
} |
q21318 | Worksheet.get_analyses_at | train | def get_analyses_at(self, slot):
"""Returns the list of analyses assigned to the slot passed in, sorted by
the positions they have within the slot.
:param slot: the slot where the analyses are located
:type slot: int
:return: a list of analyses
"""
# ensure we h... | python | {
"resource": ""
} |
q21319 | Worksheet.get_container_at | train | def get_container_at(self, slot):
"""Returns the container object assigned to the slot passed in
:param slot: the slot where the analyses are located
:type slot: int
:return: the container (analysis request, reference sample, etc.)
"""
# ensure we have an integer
... | python | {
"resource": ""
} |
q21320 | Worksheet.get_slot_positions | train | def get_slot_positions(self, type='a'):
"""Returns a list with the slots occupied for the type passed in.
Allowed type of analyses are:
'a' (routine analysis)
'b' (blank analysis)
'c' (control)
'd' (duplicate)
'all' (all analyses)
... | python | {
"resource": ""
} |
q21321 | Worksheet.get_slot_position | train | def get_slot_position(self, container, type='a'):
"""Returns the slot where the analyses from the type and container passed
in are located within the worksheet.
:param container: the container in which the analyses are grouped
:param type: type of the analysis
:return: the slot ... | python | {
"resource": ""
} |
q21322 | Worksheet.get_analysis_type | train | def get_analysis_type(self, instance):
"""Returns the string used in slots to differentiate amongst analysis
types
"""
if IDuplicateAnalysis.providedBy(instance):
return 'd'
elif IReferenceAnalysis.providedBy(instance):
return instance.getReferenceType()
... | python | {
"resource": ""
} |
q21323 | Worksheet.get_container_for | train | def get_container_for(self, instance):
"""Returns the container id used in slots to group analyses
"""
if IReferenceAnalysis.providedBy(instance):
return api.get_uid(instance.getSample())
return instance.getRequestUID() | python | {
"resource": ""
} |
q21324 | Worksheet.get_slot_position_for | train | def get_slot_position_for(self, instance):
"""Returns the slot where the instance passed in is located. If not
found, returns None
"""
uid = api.get_uid(instance)
slot = filter(lambda s: s['analysis_uid'] == uid, self.getLayout())
if not slot:
return None
... | python | {
"resource": ""
} |
q21325 | Worksheet.resolve_available_slots | train | def resolve_available_slots(self, worksheet_template, type='a'):
"""Returns the available slots from the current worksheet that fits
with the layout defined in the worksheet_template and type of analysis
passed in.
Allowed type of analyses are:
'a' (routine analysis)
... | python | {
"resource": ""
} |
q21326 | Worksheet.applyWorksheetTemplate | train | def applyWorksheetTemplate(self, wst):
""" Add analyses to worksheet according to wst's layout.
Will not overwrite slots which are filled already.
If the selected template has an instrument assigned, it will
only be applied to those analyses for which the instrument
... | python | {
"resource": ""
} |
q21327 | Worksheet.getWorksheetServices | train | def getWorksheetServices(self):
"""get list of analysis services present on this worksheet
"""
services = []
for analysis in self.getAnalyses():
service = analysis.getAnalysisService()
if service and service not in services:
services.append(service... | python | {
"resource": ""
} |
q21328 | Worksheet.setInstrument | train | def setInstrument(self, instrument, override_analyses=False):
""" Sets the specified instrument to the Analysis from the
Worksheet. Only sets the instrument if the Analysis
allows it, according to its Analysis Service and Method.
If an analysis has already assigned an instrum... | python | {
"resource": ""
} |
q21329 | Worksheet.setMethod | train | def setMethod(self, method, override_analyses=False):
""" Sets the specified method to the Analyses from the
Worksheet. Only sets the method if the Analysis
allows to keep the integrity.
If an analysis has already been assigned to a method, it won't
be overriden.
... | python | {
"resource": ""
} |
q21330 | Worksheet.checkUserManage | train | def checkUserManage(self):
""" Checks if the current user has granted access to this worksheet
and if has also privileges for managing it.
"""
granted = False
can_access = self.checkUserAccess()
if can_access is True:
pm = getToolByName(self, 'portal_memb... | python | {
"resource": ""
} |
q21331 | Worksheet.checkUserAccess | train | def checkUserAccess(self):
""" Checks if the current user has granted access to this worksheet.
Returns False if the user has no access, otherwise returns True
"""
# Deny access to foreign analysts
allowed = True
pm = getToolByName(self, "portal_membership")
m... | python | {
"resource": ""
} |
q21332 | Worksheet.getProgressPercentage | train | def getProgressPercentage(self):
"""Returns the progress percentage of this worksheet
"""
state = api.get_workflow_status_of(self)
if state == "verified":
return 100
steps = 0
query = dict(getWorksheetUID=api.get_uid(self))
analyses = api.search(query... | python | {
"resource": ""
} |
q21333 | PartitionSetupWidget.process_form | train | def process_form(self, instance, field, form, empty_marker = None,
emptyReturnsMarker = False):
""" Some special field handling for disabled fields, which don't
get submitted by the browser but still need to be written away.
"""
bsc = getToolByName(instance, 'bika_se... | python | {
"resource": ""
} |
q21334 | guard_create_partitions | train | def guard_create_partitions(analysis_request):
"""Returns true if partitions can be created using the analysis request
passed in as the source.
"""
if not analysis_request.bika_setup.getShowPartitions():
# If partitions are disabled in Setup, return False
return False
if analysis_re... | python | {
"resource": ""
} |
q21335 | guard_submit | train | def guard_submit(analysis_request):
"""Return whether the transition "submit" can be performed or not.
Returns True if there is at least one analysis in a non-detached state and
all analyses in a non-detached analyses have been submitted.
"""
analyses_ready = False
for analysis in analysis_reque... | python | {
"resource": ""
} |
q21336 | guard_prepublish | train | def guard_prepublish(analysis_request):
"""Returns whether 'prepublish' transition can be perform or not. Returns
True if the analysis request has at least one analysis in 'verified' or in
'to_be_verified' status. Otherwise, return False
"""
valid_states = ['verified', 'to_be_verified']
for anal... | python | {
"resource": ""
} |
q21337 | guard_rollback_to_receive | train | def guard_rollback_to_receive(analysis_request):
"""Return whether 'rollback_to_receive' transition can be performed or not.
Returns True if the analysis request has at least one analysis in 'assigned'
or 'unassigned' status. Otherwise, returns False
"""
skipped = 0
valid_states = ['unassigned',... | python | {
"resource": ""
} |
q21338 | guard_cancel | train | def guard_cancel(analysis_request):
"""Returns whether 'cancel' transition can be performed or not. Returns
True only if all analyses are in "unassigned" status
"""
# Ask to partitions
for partition in analysis_request.getDescendants(all_descendants=False):
if not isTransitionAllowed(partiti... | python | {
"resource": ""
} |
q21339 | guard_reinstate | train | def guard_reinstate(analysis_request):
"""Returns whether 'reinstate" transition can be performed or not. Returns
True only if this is not a partition or the parent analysis request can be
reinstated or is not in a cancelled state
"""
parent = analysis_request.getParentAnalysisRequest()
if not p... | python | {
"resource": ""
} |
q21340 | guard_sample | train | def guard_sample(analysis_request):
"""Returns whether 'sample' transition can be performed or not. Returns
True only if the analysis request has the DateSampled and Sampler set or if
the user belongs to the Samplers group
"""
if analysis_request.getDateSampled() and analysis_request.getSampler():
... | python | {
"resource": ""
} |
q21341 | assigned_state | train | def assigned_state(instance):
"""Returns `assigned` or `unassigned` depending on the state of the
analyses the analysisrequest contains. Return `unassigned` if the Analysis
Request has at least one analysis in `unassigned` state.
Otherwise, returns `assigned`
"""
analyses = instance.getAnalyses(... | python | {
"resource": ""
} |
q21342 | handle_errors | train | def handle_errors(f):
""" simple JSON error handler
"""
import traceback
from plone.jsonapi.core.helpers import error
def decorator(*args, **kwargs):
try:
return f(*args, **kwargs)
except Exception:
var = traceback.format_exc()
return error(var)
... | python | {
"resource": ""
} |
q21343 | get_include_fields | train | def get_include_fields(request):
"""Retrieve include_fields values from the request
"""
include_fields = []
rif = request.get("include_fields", "")
if "include_fields" in request:
include_fields = [x.strip()
for x in rif.split(",")
if x.str... | python | {
"resource": ""
} |
q21344 | load_brain_metadata | train | def load_brain_metadata(proxy, include_fields):
"""Load values from the catalog metadata into a list of dictionaries
"""
ret = {}
for index in proxy.indexes():
if index not in proxy:
continue
if include_fields and index not in include_fields:
continue
val ... | python | {
"resource": ""
} |
q21345 | load_field_values | train | def load_field_values(instance, include_fields):
"""Load values from an AT object schema fields into a list of dictionaries
"""
ret = {}
schema = instance.Schema()
val = None
for field in schema.fields():
fieldname = field.getName()
if include_fields and fieldname not in include_... | python | {
"resource": ""
} |
q21346 | get_include_methods | train | def get_include_methods(request):
"""Retrieve include_methods values from the request
"""
methods = request.get("include_methods", "")
include_methods = [
x.strip() for x in methods.split(",") if x.strip()]
return include_methods | python | {
"resource": ""
} |
q21347 | set_fields_from_request | train | def set_fields_from_request(obj, request):
"""Search request for keys that match field names in obj,
and call field mutator with request value.
The list of fields for which schema mutators were found
is returned.
"""
schema = obj.Schema()
# fields contains all schema-valid field values from... | python | {
"resource": ""
} |
q21348 | RejectionWidget.isVisible | train | def isVisible(self, instance, mode='view', default=None, field=None):
"""
This function returns the visibility of the widget depending on whether
the rejection workflow is enabled or not.
"""
vis = super(RejectionWidget, self).isVisible(
instance=instance, mode=mode, ... | python | {
"resource": ""
} |
q21349 | RejectionWidget.rejectionOptionsList | train | def rejectionOptionsList(self):
"Return a sorted list with the options defined in bikasetup"
plone = getSite()
settings = plone.bika_setup
# RejectionReasons will return something like:
# [{'checkbox': u'on', 'textfield-2': u'b', 'textfield-1': u'c', 'textfield-0': u'a'}]
... | python | {
"resource": ""
} |
q21350 | Import | train | def Import(context, request):
""" Read Dimensional-CSV analysis results
"""
form = request.form
# TODO form['file'] sometimes returns a list
infile = form['instrument_results_file'][0] if \
isinstance(form['instrument_results_file'], list) else \
form['instrument_results_file']
a... | python | {
"resource": ""
} |
q21351 | guard_unassign | train | def guard_unassign(duplicate_analysis):
"""Return whether the transition 'unassign' can be performed or not
"""
analysis = duplicate_analysis.getAnalysis()
if wf.isTransitionAllowed(analysis, "unassign"):
return True
skip = ["retracted", "rejected", "unassigned"]
if api.get_review_status... | python | {
"resource": ""
} |
q21352 | ReflexRuleWidget._get_sorted_cond_keys | train | def _get_sorted_cond_keys(self, keys_list):
"""
This function returns only the elements starting with
'analysisservice-' in 'keys_list'. The returned list is sorted by the
index appended to the end of each element
"""
# The names can be found in reflexrulewidget.pt inside... | python | {
"resource": ""
} |
q21353 | ReflexRuleWidget._get_sorted_action_keys | train | def _get_sorted_action_keys(self, keys_list):
"""
This function returns only the elements starting with 'action-' in
'keys_list'. The returned list is sorted by the index appended to
the end of each element
"""
# The names can be found in reflexrulewidget.pt inside the
... | python | {
"resource": ""
} |
q21354 | SamplingRoundAddedEventHandler | train | def SamplingRoundAddedEventHandler(instance, event):
""" Event fired when BikaSetup object gets modified.
Since Sampling Round is a dexterity object we have to change the ID by "hand"
Then we have to redirect the user to the ar add form
"""
if instance.portal_type != "SamplingRound":
... | python | {
"resource": ""
} |
q21355 | AnalysisProfileAnalysesWidget.process_form | train | def process_form(self, instance, field, form, empty_marker=None,
emptyReturnsMarker=False):
"""Return UIDs of the selected services for the AnalysisProfile reference field
"""
# selected services
service_uids = form.get("uids", [])
# hidden services
... | python | {
"resource": ""
} |
q21356 | InvoiceView.format_price | train | def format_price(self, price):
"""Formats the price with the set decimal mark and currency
"""
# ensure we have a float
price = api.to_float(price, default=0.0)
dm = self.get_decimal_mark()
cur = self.get_currency_symbol()
price = "%s %.2f" % (cur, price)
... | python | {
"resource": ""
} |
q21357 | InvoiceView.get_billable_items | train | def get_billable_items(self):
"""Return a list of billable items
"""
items = []
for obj in self.context.getBillableItems():
if self.is_profile(obj):
items.append({
"obj": obj,
"title": obj.Title(),
"v... | python | {
"resource": ""
} |
q21358 | InstrumentCertification.setValidTo | train | def setValidTo(self, value):
"""Custom setter method to calculate a `ValidTo` date based on
the `ValidFrom` and `ExpirationInterval` field values.
"""
valid_from = self.getValidFrom()
valid_to = DateTime(value)
interval = self.getExpirationInterval()
if valid_fr... | python | {
"resource": ""
} |
q21359 | InstrumentCertification.getInterval | train | def getInterval(self):
"""Vocabulary of date intervals to calculate the "To" field date based
from the "From" field date.
"""
items = (
("", _(u"Not set")),
("1", _(u"daily")),
("7", _(u"weekly")),
("30", _(u"monthly")),
("90", ... | python | {
"resource": ""
} |
q21360 | InstrumentCertification.isValid | train | def isValid(self):
"""Returns if the current certificate is in a valid date range
"""
today = DateTime()
valid_from = self.getValidFrom()
valid_to = self.getValidTo()
return valid_from <= today <= valid_to | python | {
"resource": ""
} |
q21361 | InstrumentCertification.getDaysToExpire | train | def getDaysToExpire(self):
"""Returns the days until this certificate expires
:returns: Days until the certificate expires
:rtype: int
"""
delta = 0
today = DateTime()
valid_from = self.getValidFrom() or today
valid_to = self.getValidTo()
# one ... | python | {
"resource": ""
} |
q21362 | get_workflows | train | def get_workflows():
"""Returns a mapping of id->workflow
"""
wftool = api.get_tool("portal_workflow")
wfs = {}
for wfid in wftool.objectIds():
wf = wftool.getWorkflowById(wfid)
if hasattr(aq_base(wf), "updateRoleMappingsFor"):
wfs[wfid] = wf
return wfs | python | {
"resource": ""
} |
q21363 | update_role_mappings | train | def update_role_mappings(obj, wfs=None, reindex=True):
"""Update the role mappings of the given object
"""
wftool = api.get_tool("portal_workflow")
if wfs is None:
wfs = get_workflows()
chain = wftool.getChainFor(obj)
for wfid in chain:
wf = wfs[wfid]
wf.updateRoleMapping... | python | {
"resource": ""
} |
q21364 | fix_client_permissions | train | def fix_client_permissions(portal):
"""Fix client permissions
"""
wfs = get_workflows()
start = time.time()
clients = portal.clients.objectValues()
total = len(clients)
for num, client in enumerate(clients):
logger.info("Fixing permission for client {}/{} ({})"
.... | python | {
"resource": ""
} |
q21365 | before_sample | train | def before_sample(analysis_request):
"""Method triggered before "sample" transition for the Analysis Request
passed in is performed
"""
if not analysis_request.getDateSampled():
analysis_request.setDateSampled(DateTime())
if not analysis_request.getSampler():
analysis_request.setSamp... | python | {
"resource": ""
} |
q21366 | after_reinstate | train | def after_reinstate(analysis_request):
"""Method triggered after a 'reinstate' transition for the Analysis Request
passed in is performed. Sets its status to the last status before it was
cancelled. Reinstates the descendant partitions and all the analyses
associated to the analysis request as well.
... | python | {
"resource": ""
} |
q21367 | after_receive | train | def after_receive(analysis_request):
"""Method triggered after "receive" transition for the Analysis Request
passed in is performed
"""
# Mark this analysis request as IReceived
alsoProvides(analysis_request, IReceived)
analysis_request.setDateReceived(DateTime())
do_action_to_analyses(anal... | python | {
"resource": ""
} |
q21368 | after_sample | train | def after_sample(analysis_request):
"""Method triggered after "sample" transition for the Analysis Request
passed in is performed
"""
analysis_request.setDateSampled(DateTime())
idxs = ['getDateSampled']
for analysis in analysis_request.getAnalyses(full_objects=True):
analysis.reindexObj... | python | {
"resource": ""
} |
q21369 | AbstractRoutineAnalysis.getClientTitle | train | def getClientTitle(self):
"""Used to populate catalog values.
Returns the Title of the client for this analysis' AR.
"""
request = self.getRequest()
if request:
client = request.getClient()
if client:
return client.Title() | python | {
"resource": ""
} |
q21370 | AbstractRoutineAnalysis.getClientUID | train | def getClientUID(self):
"""Used to populate catalog values.
Returns the UID of the client for this analysis' AR.
"""
request = self.getRequest()
if request:
client = request.getClient()
if client:
return client.UID() | python | {
"resource": ""
} |
q21371 | AbstractRoutineAnalysis.getClientURL | train | def getClientURL(self):
"""This method is used to populate catalog values
Returns the URL of the client for this analysis' AR.
"""
request = self.getRequest()
if request:
client = request.getClient()
if client:
return client.absolute_url_pa... | python | {
"resource": ""
} |
q21372 | AbstractRoutineAnalysis.getDateReceived | train | def getDateReceived(self):
"""Used to populate catalog values.
Returns the date the Analysis Request this analysis belongs to was
received. If the analysis was created after, then returns the date
the analysis was created.
"""
request = self.getRequest()
if reques... | python | {
"resource": ""
} |
q21373 | AbstractRoutineAnalysis.getDueDate | train | def getDueDate(self):
"""Used to populate getDueDate index and metadata.
This calculates the difference between the time the analysis processing
started and the maximum turnaround time. If the analysis has no
turnaround time set or is not yet ready for proces, returns None
"""
... | python | {
"resource": ""
} |
q21374 | AbstractRoutineAnalysis.getResultsRange | train | def getResultsRange(self):
"""Returns the valid result range for this routine analysis based on the
results ranges defined in the Analysis Request this routine analysis is
assigned to.
A routine analysis will be considered out of range if it result falls
out of the range defined... | python | {
"resource": ""
} |
q21375 | AbstractRoutineAnalysis.getHidden | train | def getHidden(self):
""" Returns whether if the analysis must be displayed in results
reports or not, as well as in analyses view when the user logged in
is a Client Contact.
If the value for the field HiddenManually is set to False, this function
will delegate the action to the... | python | {
"resource": ""
} |
q21376 | AbstractRoutineAnalysis.setHidden | train | def setHidden(self, hidden):
""" Sets if this analysis must be displayed or not in results report and
in manage analyses view if the user is a lab contact as well.
The value set by using this field will have priority over the visibility
criteria set at Analysis Request, Template or Prof... | python | {
"resource": ""
} |
q21377 | LabProduct.getTotalPrice | train | def getTotalPrice(self):
""" compute total price """
price = self.getPrice()
price = Decimal(price or '0.00')
vat = Decimal(self.getVAT())
vat = vat and vat / 100 or 0
price = price + (price * vat)
return price.quantize(Decimal('0.00')) | python | {
"resource": ""
} |
q21378 | SupplyOrder.getProductUIDs | train | def getProductUIDs(self):
""" return the uids of the products referenced by order items
"""
uids = []
for orderitem in self.objectValues('XupplyOrderItem'):
product = orderitem.getProduct()
if product is not None:
uids.append(orderitem.getProduct()... | python | {
"resource": ""
} |
q21379 | ReferenceWidget.process_form | train | def process_form(self, instance, field, form, empty_marker=None,
emptyReturnsMarker=False):
"""Return a UID so that ReferenceField understands.
"""
fieldName = field.getName()
if fieldName + "_uid" in form:
uid = form.get(fieldName + "_uid", '')
... | python | {
"resource": ""
} |
q21380 | ajaxReferenceWidgetSearch.get_field_names | train | def get_field_names(self):
"""Return the field names to get values for
"""
col_model = self.request.get("colModel", None)
if not col_model:
return ["UID",]
names = []
col_model = json.loads(_u(col_model))
if isinstance(col_model, (list, tuple)):
... | python | {
"resource": ""
} |
q21381 | ajaxReferenceWidgetSearch.get_data_record | train | def get_data_record(self, brain, field_names):
"""Returns a dict with the column values for the given brain
"""
record = {}
model = None
for field_name in field_names:
# First try to get the value directly from the brain
value = getattr(brain, field_name,... | python | {
"resource": ""
} |
q21382 | ajaxReferenceWidgetSearch.search | train | def search(self):
"""Returns the list of brains that match with the request criteria
"""
brains = []
# TODO Legacy
for name, adapter in getAdapters((self.context, self.request),
IReferenceWidgetVocabulary):
brains.extend(adapte... | python | {
"resource": ""
} |
q21383 | ajaxReferenceWidgetSearch.to_data_rows | train | def to_data_rows(self, brains):
"""Returns a list of dictionaries representing the values of each brain
"""
fields = self.get_field_names()
return map(lambda brain: self.get_data_record(brain, fields), brains) | python | {
"resource": ""
} |
q21384 | ajaxReferenceWidgetSearch.to_json_payload | train | def to_json_payload(self, data_rows):
"""Returns the json payload
"""
num_rows = len(data_rows)
num_page = self.num_page
num_rows_page = self.num_rows_page
pages = num_rows / num_rows_page
pages += divmod(num_rows, num_rows_page)[1] and 1 or 0
start = (nu... | python | {
"resource": ""
} |
q21385 | rename_retract_ar_transition | train | def rename_retract_ar_transition(portal):
"""Renames retract_ar transition to invalidate
"""
logger.info("Renaming 'retract_ar' transition to 'invalidate'")
wf_tool = api.get_tool("portal_workflow")
workflow = wf_tool.getWorkflowById("bika_ar_workflow")
if "invalidate" not in workflow.transitio... | python | {
"resource": ""
} |
q21386 | rebind_invalidated_ars | train | def rebind_invalidated_ars(portal):
"""Rebind the ARs automatically generated because of the retraction of their
parent to the new field 'Invalidated'. The field used until now
'ParentAnalysisRequest' will be used for partitioning
"""
logger.info("Rebinding retracted/invalidated ARs")
# Walk th... | python | {
"resource": ""
} |
q21387 | recatalog_analyses_due_date | train | def recatalog_analyses_due_date(portal):
"""Recatalog the index and metadata field 'getDueDate'
"""
logger.info("Updating Analyses getDueDate")
# No need to update those analyses that are verified or published. Only
# those that are under work
catalog = api.get_tool(CATALOG_ANALYSIS_LISTING)
... | python | {
"resource": ""
} |
q21388 | update_rejection_permissions | train | def update_rejection_permissions(portal):
"""Adds the permission 'Reject Analysis Request' and update the permission
mappings accordingly """
updated = update_rejection_permissions_for(portal, "bika_ar_workflow",
"Reject Analysis Request")
if updated:
... | python | {
"resource": ""
} |
q21389 | update_analaysisrequests_due_date | train | def update_analaysisrequests_due_date(portal):
"""Removes the metadata getLate from ar-catalog and adds the column
getDueDate"""
logger.info("Updating getLate -> getDueDate metadata columns ...")
catalog_objects = False
catalog = api.get_tool(CATALOG_ANALYSIS_REQUEST_LISTING)
if "getLate" in cat... | python | {
"resource": ""
} |
q21390 | PartitionMagicView.push_primary_analyses_for_removal | train | def push_primary_analyses_for_removal(self, analysis_request, analyses):
"""Stores the analyses to be removed after partitions creation
"""
to_remove = self.analyses_to_remove.get(analysis_request, [])
to_remove.extend(analyses)
self.analyses_to_remove[analysis_request] = list(se... | python | {
"resource": ""
} |
q21391 | PartitionMagicView.remove_primary_analyses | train | def remove_primary_analyses(self):
"""Remove analyses relocated to partitions
"""
for ar, analyses in self.analyses_to_remove.items():
analyses_ids = list(set(map(api.get_id, analyses)))
ar.manage_delObjects(analyses_ids)
self.analyses_to_remove = dict() | python | {
"resource": ""
} |
q21392 | PartitionMagicView.get_ar_data | train | def get_ar_data(self):
"""Returns a list of AR data
"""
for obj in self.get_objects():
info = self.get_base_info(obj)
info.update({
"analyses": self.get_analysis_data_for(obj),
"sampletype": self.get_base_info(obj.getSampleType()),
... | python | {
"resource": ""
} |
q21393 | PartitionMagicView.get_sampletype_data | train | def get_sampletype_data(self):
"""Returns a list of SampleType data
"""
for obj in self.get_sampletypes():
info = self.get_base_info(obj)
yield info | python | {
"resource": ""
} |
q21394 | PartitionMagicView.get_container_data | train | def get_container_data(self):
"""Returns a list of Container data
"""
for obj in self.get_containers():
info = self.get_base_info(obj)
yield info | python | {
"resource": ""
} |
q21395 | PartitionMagicView.get_preservation_data | train | def get_preservation_data(self):
"""Returns a list of Preservation data
"""
for obj in self.get_preservations():
info = self.get_base_info(obj)
yield info | python | {
"resource": ""
} |
q21396 | PartitionMagicView.get_sampletypes | train | def get_sampletypes(self):
"""Returns the available SampleTypes of the system
"""
query = {
"portal_type": "SampleType",
"sort_on": "sortable_title",
"sort_order": "ascending",
"is_active": True,
}
results = api.search(query, "bika_... | python | {
"resource": ""
} |
q21397 | PartitionMagicView.get_containers | train | def get_containers(self):
"""Returns the available Containers of the system
"""
query = dict(portal_type="Container",
sort_on="sortable_title",
sort_order="ascending",
is_active=True)
results = api.search(query, "bika_setup_c... | python | {
"resource": ""
} |
q21398 | PartitionMagicView.get_analysis_data_for | train | def get_analysis_data_for(self, ar):
"""Return the Analysis data for this AR
"""
# Exclude analyses from children (partitions)
analyses = ar.objectValues("Analysis")
out = []
for an in analyses:
info = self.get_base_info(an)
info.update({
... | python | {
"resource": ""
} |
q21399 | PartitionMagicView.get_template_data_for | train | def get_template_data_for(self, ar):
"""Return the Template data for this AR
"""
info = None
template = ar.getTemplate()
ar_sampletype_uid = api.get_uid(ar.getSampleType())
ar_container_uid = ""
if ar.getContainer():
ar_container_uid = api.get_uid(ar.g... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.