_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q20900
generateUniqueId
train
def generateUniqueId(context, **kw): """ Generate pretty content IDs. """ # get the config for this portal type from the system setup config = get_config(context, **kw) # get the variables map for later string interpolation variables = get_variables(context, **kw) # The new generate seque...
python
{ "resource": "" }
q20901
ObjectTransitionedEventHandler
train
def ObjectTransitionedEventHandler(obj, event): """Object has been transitioned to an new state """ # only snapshot supported objects if not supports_snapshots(obj): return # default transition entry entry = { "modified": DateTime().ISO(), "action": event.action, } ...
python
{ "resource": "" }
q20902
ObjectModifiedEventHandler
train
def ObjectModifiedEventHandler(obj, event): """Object has been modified """ # only snapshot supported objects if not supports_snapshots(obj): return # take a new snapshot take_snapshot(obj, action="edit") # reindex the object in the auditlog catalog reindex_object(obj)
python
{ "resource": "" }
q20903
ObjectInitializedEventHandler
train
def ObjectInitializedEventHandler(obj, event): """Object has been created """ # only snapshot supported objects if not supports_snapshots(obj): return # object has already snapshots if has_snapshots(obj): return # take a new snapshot take_snapshot(obj, action="create")
python
{ "resource": "" }
q20904
AnalysisSpec.Title
train
def Title(self): """ Return the title if possible, else return the Sample type. Fall back on the instance's ID if there's no sample type or title. """ title = '' if self.title: title = self.title else: sampletype = self.getSampleType() ...
python
{ "resource": "" }
q20905
AnalysisSpec.getSampleTypes
train
def getSampleTypes(self, active_only=True): """Return all sampletypes """ catalog = api.get_tool("bika_setup_catalog") query = { "portal_type": "SampleType", # N.B. The `sortable_title` index sorts case sensitive. Since there # is no sort key for ...
python
{ "resource": "" }
q20906
_objectdata_cache_key
train
def _objectdata_cache_key(func, obj): """Cache Key for object data """ uid = api.get_uid(obj) modified = api.get_modification_date(obj).millis() review_state = api.get_review_status(obj) return "{}-{}-{}".format(uid, review_state, modified)
python
{ "resource": "" }
q20907
get_storage
train
def get_storage(obj): """Get or create the audit log storage for the given object :param obj: Content object :returns: PersistentList """ annotation = IAnnotations(obj) if annotation.get(SNAPSHOT_STORAGE) is None: annotation[SNAPSHOT_STORAGE] = PersistentList() return annotation[SNA...
python
{ "resource": "" }
q20908
get_snapshot_count
train
def get_snapshot_count(obj): """Returns the number of snapsots :param obj: Content object :returns: Current snapshots in the storage """ try: annotation = IAnnotations(obj) except TypeError: return 0 storage = annotation.get(SNAPSHOT_STORAGE, []) return len(storage)
python
{ "resource": "" }
q20909
get_snapshot_by_version
train
def get_snapshot_by_version(obj, version=0): """Get a snapshot by version Snapshot versions begin with `0`, because this is the first index of the storage, which is a list. :param obj: Content object :param version: The index position of the snapshot in the storage :returns: Snapshot at the gi...
python
{ "resource": "" }
q20910
get_object_data
train
def get_object_data(obj): """Get object schema data NOTE: We RAM cache this data because it should only change when the object was modified! XXX: We need to set at least the modification date when we set fields in Ajax Listing when we take a snapshot there! :param obj: Content object :ret...
python
{ "resource": "" }
q20911
get_object_metadata
train
def get_object_metadata(obj, **kw): """Get object metadata :param obj: Content object :returns: Dictionary of extracted object metadata """ # inject metadata of volatile data metadata = { "actor": get_user_id(), "roles": get_roles(), "action": "", "review_state"...
python
{ "resource": "" }
q20912
compare_last_two_snapshots
train
def compare_last_two_snapshots(obj, raw=False): """Helper to compare the last two snapshots directly """ if get_snapshot_count(obj) < 2: return {} version = get_version(obj) snap1 = get_snapshot_by_version(obj, version - 1) snap2 = get_snapshot_by_version(obj, version) return com...
python
{ "resource": "" }
q20913
diff_values
train
def diff_values(value_a, value_b, raw=False): """Returns a human-readable diff between two values :param value_a: First value to compare :param value_b: Second value to compare :param raw: True to compare the raw values, e.g. UIDs :returns a list of diff tuples """ if not raw: valu...
python
{ "resource": "" }
q20914
_process_value
train
def _process_value(value): """Convert the value into a human readable diff string """ if not value: value = _("Not set") # XXX: bad data, e.g. in AS Method field elif value == "None": value = _("Not set") # 0 is detected as the portal UID elif value == "0": pass e...
python
{ "resource": "" }
q20915
Batch.Title
train
def Title(self): """Return the Batch ID if title is not defined """ titlefield = self.Schema().getField('title') if titlefield.widget.visible: return safe_unicode(self.title).encode('utf-8') else: return safe_unicode(self.id).encode('utf-8')
python
{ "resource": "" }
q20916
Batch.getClient
train
def getClient(self): """Retrieves the Client for which the current Batch is attached to Tries to retrieve the Client from the Schema property, but if not found, searches for linked ARs and retrieve the Client from the first one. If the Batch has no client, returns None. ...
python
{ "resource": "" }
q20917
Batch.BatchLabelVocabulary
train
def BatchLabelVocabulary(self): """Return all batch labels as a display list """ bsc = getToolByName(self, 'bika_setup_catalog') ret = [] for p in bsc(portal_type='BatchLabel', is_active=True, sort_on='sortable_title'): ret.ap...
python
{ "resource": "" }
q20918
Batch.getAnalysisRequestsBrains
train
def getAnalysisRequestsBrains(self, **kwargs): """Return all the Analysis Requests brains linked to the Batch kargs are passed directly to the catalog. """ kwargs['getBatchUID'] = self.UID() catalog = getToolByName(self, CATALOG_ANALYSIS_REQUEST_LISTING) brains = catalog(...
python
{ "resource": "" }
q20919
Batch.getAnalysisRequests
train
def getAnalysisRequests(self, **kwargs): """Return all the Analysis Requests objects linked to the Batch kargs are passed directly to the catalog. """ brains = self.getAnalysisRequestsBrains(**kwargs) return [b.getObject() for b in brains]
python
{ "resource": "" }
q20920
Instrument.getValidCertifications
train
def getValidCertifications(self): """ Returns the certifications fully valid """ certs = [] today = date.today() for c in self.getCertifications(): validfrom = c.getValidFrom() if c else None validto = c.getValidTo() if validfrom else None if n...
python
{ "resource": "" }
q20921
Instrument.isValid
train
def isValid(self): """ Returns if the current instrument is not out for verification, calibration, out-of-date regards to its certificates and if the latest QC succeed """ return self.isOutOfDate() is False \ and self.isQCValid() is True \ and self.getDisposeUntil...
python
{ "resource": "" }
q20922
Instrument.isQCValid
train
def isQCValid(self): """ Returns True if the results of the last batch of QC Analyses performed against this instrument was within the valid range. For a given Reference Sample, more than one Reference Analyses assigned to this same instrument can be performed and the Results Capture Da...
python
{ "resource": "" }
q20923
Instrument.addReferences
train
def addReferences(self, reference, service_uids): """ Add reference analyses to reference """ # TODO Workflow - Analyses. Assignment of refanalysis to Instrument addedanalyses = [] wf = getToolByName(self, 'portal_workflow') bsc = getToolByName(self, 'bika_setup_catalog')...
python
{ "resource": "" }
q20924
Instrument.setImportDataInterface
train
def setImportDataInterface(self, values): """ Return the current list of import data interfaces """ exims = self.getImportDataInterfacesList() new_values = [value for value in values if value in exims] if len(new_values) < len(values): logger.warn("Some Interfaces wer...
python
{ "resource": "" }
q20925
AttachmentsViewlet.show
train
def show(self): """Controls if the viewlet should be rendered """ url = self.request.getURL() # XXX: Hack to show the viewlet only on the AR base_view if not any(map(url.endswith, ["base_view", "manage_results"])): return False return self.attachments_view.use...
python
{ "resource": "" }
q20926
Import
train
def Import(context, request): """ Read analysis results from an XML string """ errors = [] logs = [] # Do import stuff here logs.append("Generic XML Import is not available") results = {'errors': errors, 'log': logs} return json.dumps(results)
python
{ "resource": "" }
q20927
get_storage_location
train
def get_storage_location(): """ get the portal with the plone.api """ location = api.portal.getSite() if location.get('bika_setup', False): location = location['bika_setup'] return location
python
{ "resource": "" }
q20928
NumberGenerator.storage
train
def storage(self): """ get the counter storage """ annotation = get_portal_annotation() if annotation.get(NUMBER_STORAGE) is None: annotation[NUMBER_STORAGE] = OIBTree() return annotation[NUMBER_STORAGE]
python
{ "resource": "" }
q20929
NumberGenerator.get_number
train
def get_number(self, key): """ get the next consecutive number """ storage = self.storage logger.debug("NUMBER before => %s" % storage.get(key, '-')) try: logger.debug("*** consecutive number lock acquire ***") lock.acquire() try: ...
python
{ "resource": "" }
q20930
NumberGenerator.set_number
train
def set_number(self, key, value): """ set a key's value """ storage = self.storage if not isinstance(value, int): logger.error("set_number: Value must be an integer") return try: lock.acquire() storage[key] = value finally...
python
{ "resource": "" }
q20931
SampleType.getJSMinimumVolume
train
def getJSMinimumVolume(self, **kw): """Try convert the MinimumVolume to 'ml' or 'g' so that JS has an easier time working with it. If conversion fails, return raw value. """ default = self.Schema()['MinimumVolume'].get(self) try: mgdefault = default.split(' ', 1) ...
python
{ "resource": "" }
q20932
SampleType._sticker_templates_vocabularies
train
def _sticker_templates_vocabularies(self): """ Returns the vocabulary to be used in AdmittedStickerTemplates.small_default If the object has saved not AdmittedStickerTemplates.admitted stickers, this method will return an empty DisplayList. Otherwise it returns the stick...
python
{ "resource": "" }
q20933
EmailView.fail
train
def fail(self, message, status=500, **kw): """Set a JSON error object and a status to the response """ self.request.response.setStatus(status) result = {"success": False, "errors": message, "status": status} result.update(kw) return result
python
{ "resource": "" }
q20934
EmailView.handle_ajax_request
train
def handle_ajax_request(self): """Handle requests ajax routes """ # check if the method exists func_arg = self.traverse_subpath[0] func_name = "ajax_{}".format(func_arg) func = getattr(self, func_name, None) if func is None: return self.fail("Invalid ...
python
{ "resource": "" }
q20935
EmailView.parse_email
train
def parse_email(self, email): """parse an email to an unicode name, email tuple """ splitted = safe_unicode(email).rsplit(",", 1) if len(splitted) == 1: return (False, splitted[0]) elif len(splitted) == 2: return (splitted[0], splitted[1]) else: ...
python
{ "resource": "" }
q20936
EmailView.to_email_attachment
train
def to_email_attachment(self, filename, filedata, **kw): """Create a new MIME Attachment The Content-Type: header is build from the maintype and subtype of the guessed filename mimetype. Additional parameters for this header are taken from the keyword arguments. """ main...
python
{ "resource": "" }
q20937
EmailView.send_email
train
def send_email(self, recipients, subject, body, attachments=None): """Prepare and send email to the recipients :param recipients: a list of email or name,email strings :param subject: the email subject :param body: the email body :param attachments: list of email attachments ...
python
{ "resource": "" }
q20938
EmailView.send
train
def send(self, msg_string, immediate=True): """Send the email via the MailHost tool """ try: mailhost = api.get_tool("MailHost") mailhost.send(msg_string, immediate=immediate) except SMTPException as e: logger.error(e) return False ...
python
{ "resource": "" }
q20939
EmailView.add_status_message
train
def add_status_message(self, message, level="info"): """Set a portal status message """ return self.context.plone_utils.addPortalMessage(message, level)
python
{ "resource": "" }
q20940
EmailView.get_report_data
train
def get_report_data(self, report): """Report data to be used in the template """ ar = report.getAnalysisRequest() attachments = map(self.get_attachment_data, ar.getAttachment()) pdf = self.get_pdf(report) filesize = "{} Kb".format(self.get_filesize(pdf)) filename ...
python
{ "resource": "" }
q20941
EmailView.get_recipients_data
train
def get_recipients_data(self, reports): """Recipients data to be used in the template """ if not reports: return [] recipients = [] recipient_names = [] for num, report in enumerate(reports): # get the linked AR of this ARReport ar = ...
python
{ "resource": "" }
q20942
EmailView.get_responsibles_data
train
def get_responsibles_data(self, reports): """Responsibles data to be used in the template """ if not reports: return [] recipients = [] recipient_names = [] for num, report in enumerate(reports): # get the linked AR of this ARReport a...
python
{ "resource": "" }
q20943
EmailView.email_from_name
train
def email_from_name(self): """Portal email name """ lab_from_name = self.laboratory.getName() portal_from_name = self.portal.email_from_name return lab_from_name or portal_from_name
python
{ "resource": "" }
q20944
EmailView.get_total_size
train
def get_total_size(self, *files): """Calculate the total size of the given files """ # Recursive unpack an eventual list of lists def iterate(item): if isinstance(item, (list, tuple)): for i in item: for ii in iterate(i): ...
python
{ "resource": "" }
q20945
EmailView.get_object_by_uid
train
def get_object_by_uid(self, uid): """Get the object by UID """ logger.debug("get_object_by_uid::UID={}".format(uid)) obj = api.get_object_by_uid(uid, None) if obj is None: logger.warn("!! No object found for UID #{} !!") return obj
python
{ "resource": "" }
q20946
EmailView.get_filesize
train
def get_filesize(self, f): """Return the filesize of the PDF as a float """ try: filesize = float(f.get_size()) return float("%.2f" % (filesize / 1024)) except (POSKeyError, TypeError, AttributeError): return 0.0
python
{ "resource": "" }
q20947
EmailView.get_recipients
train
def get_recipients(self, ar): """Return the AR recipients in the same format like the AR Report expects in the records field `Recipients` """ plone_utils = api.get_tool("plone_utils") def is_email(email): if not plone_utils.validateSingleEmailAddress(email): ...
python
{ "resource": "" }
q20948
EmailView.ajax_recalculate_size
train
def ajax_recalculate_size(self): """Recalculate the total size of the selected attachments """ reports = self.get_reports() attachments = self.get_attachments() total_size = self.get_total_size(reports, attachments) return { "files": len(reports) + len(attach...
python
{ "resource": "" }
q20949
is_worksheet_context
train
def is_worksheet_context(): """Returns whether the current context from the request is a Worksheet """ request = api.get_request() parents = request.get("PARENTS", []) portal_types_names = map(lambda p: getattr(p, "portal_type", None), parents) if "Worksheet" in portal_types_names: retur...
python
{ "resource": "" }
q20950
guard_assign
train
def guard_assign(analysis): """Return whether the transition "assign" can be performed or not """ # Only if the request was done from worksheet context. if not is_worksheet_context(): return False # Cannot assign if the Sample has not been received if not analysis.isSampleReceived(): ...
python
{ "resource": "" }
q20951
guard_submit
train
def guard_submit(analysis): """Return whether the transition "submit" can be performed or not """ # Cannot submit without a result if not analysis.getResult(): return False # Cannot submit with interims without value for interim in analysis.getInterimFields(): if not interim.get...
python
{ "resource": "" }
q20952
guard_multi_verify
train
def guard_multi_verify(analysis): """Return whether the transition "multi_verify" can be performed or not The transition multi_verify will only take place if multi-verification of results is enabled. """ # Cannot multiverify if there is only one remaining verification remaining_verifications = a...
python
{ "resource": "" }
q20953
guard_retract
train
def guard_retract(analysis): """ Return whether the transition "retract" can be performed or not """ # Cannot retract if there are dependents that cannot be retracted if not is_transition_allowed(analysis.getDependents(), "retract"): return False dependencies = analysis.getDependencies() ...
python
{ "resource": "" }
q20954
user_has_super_roles
train
def user_has_super_roles(): """Return whether the current belongs to superuser roles """ member = api.get_current_user() super_roles = ["LabManager", "Manager"] diff = filter(lambda role: role in super_roles, member.getRoles()) return len(diff) > 0
python
{ "resource": "" }
q20955
current_user_was_last_verifier
train
def current_user_was_last_verifier(analysis): """Returns whether the current user was the last verifier or not """ verifiers = analysis.getVerificators() return verifiers and verifiers[:-1] == api.get_current_user().getId()
python
{ "resource": "" }
q20956
is_transition_allowed
train
def is_transition_allowed(analyses, transition_id): """Returns whether all analyses can be transitioned or not """ if not analyses: return True if not isinstance(analyses, list): return is_transition_allowed([analyses], transition_id) for analysis in analyses: if not wf.isTra...
python
{ "resource": "" }
q20957
is_submitted_or_submittable
train
def is_submitted_or_submittable(analysis): """Returns whether the analysis is submittable or has already been submitted """ if ISubmitted.providedBy(analysis): return True if wf.isTransitionAllowed(analysis, "submit"): return True return False
python
{ "resource": "" }
q20958
is_verified_or_verifiable
train
def is_verified_or_verifiable(analysis): """Returns whether the analysis is verifiable or has already been verified """ if IVerified.providedBy(analysis): return True if wf.isTransitionAllowed(analysis, "verify"): return True if wf.isTransitionAllowed(analysis, "multi_verify"): ...
python
{ "resource": "" }
q20959
InstrumentValidation.isValidationInProgress
train
def isValidationInProgress(self): """Checks if the date is beteween a validation period """ today = DateTime() down_from = self.getDownFrom() down_to = self.getDownTo() return down_from <= today <= down_to
python
{ "resource": "" }
q20960
InstrumentValidation.getRemainingDaysInValidation
train
def getRemainingDaysInValidation(self): """Returns the days until the instrument returns from validation """ delta = 0 today = DateTime() down_from = self.getDownFrom() or today down_to = self.getDownTo() # one of the fields is not set, return 0 days if n...
python
{ "resource": "" }
q20961
LabContact.hasUser
train
def hasUser(self): """Check if contact has user """ username = self.getUsername() if not username: return False user = api.get_user(username) return user is not None
python
{ "resource": "" }
q20962
LabContact._departmentsVoc
train
def _departmentsVoc(self): """Vocabulary of available departments """ query = { "portal_type": "Department", "is_active": True } results = api.search(query, "bika_setup_catalog") items = map(lambda dept: (api.get_uid(dept), api.get_title(dept)), ...
python
{ "resource": "" }
q20963
LabContact._defaultDepsVoc
train
def _defaultDepsVoc(self): """Vocabulary of all departments """ # Getting the assigned departments deps = self.getDepartments() items = [] for d in deps: items.append((api.get_uid(d), api.get_title(d))) return api.to_display_list(items, sort_by="value"...
python
{ "resource": "" }
q20964
LabContact.addDepartment
train
def addDepartment(self, dep): """Adds a department :param dep: UID or department object :returns: True when the department was added """ if api.is_uid(dep): dep = api.get_object_by_uid(dep) deps = self.getDepartments() if dep not in deps: ...
python
{ "resource": "" }
q20965
LabContact.removeDepartment
train
def removeDepartment(self, dep): """Removes a department :param dep: UID or department object :returns: True when the department was removed """ if api.is_uid(dep): dep = api.get_object_by_uid(dep) deps = self.getDepartments() if dep not in deps: ...
python
{ "resource": "" }
q20966
rename_bika_setup
train
def rename_bika_setup(): """ Rename Bika Setup to just Setup to avoid naming confusions for new users """ logger.info("Renaming Bika Setup...") bika_setup = api.get_bika_setup() bika_setup.setTitle("Setup") bika_setup.reindexObject() setup = api.get_portal().portal_setup setup.runImp...
python
{ "resource": "" }
q20967
guard_retract
train
def guard_retract(worksheet): """Return whether the transition retract can be performed or not to the worksheet passed in. Since the retract transition from worksheet is a shortcut to retract transitions from all analyses the worksheet contains, this guard only returns True if retract transition is allo...
python
{ "resource": "" }
q20968
guard_rollback_to_open
train
def guard_rollback_to_open(worksheet): """Return whether 'rollback_to_receive' transition can be performed or not """ for analysis in worksheet.getAnalyses(): if api.get_review_status(analysis) in ["assigned"]: return True return False
python
{ "resource": "" }
q20969
ContainerType.getContainers
train
def getContainers(self): """Return a list of all containers of this type """ _containers = [] for container in self.bika_setup.bika_containers.objectValues(): containertype = container.getContainerType() if containertype and containertype.UID() == self.UID()...
python
{ "resource": "" }
q20970
Calculation.setFormula
train
def setFormula(self, Formula=None): """Set the Dependent Services from the text of the calculation Formula """ bsc = getToolByName(self, 'bika_setup_catalog') if Formula is None: self.setDependentServices(None) self.getField('Formula').set(self, Formula) e...
python
{ "resource": "" }
q20971
Calculation.getCalculationDependants
train
def getCalculationDependants(self, deps=None): """Return a flat list of services who depend on this calculation. This refers only to services who's Calculation UIDReferenceField have the value set to point to this calculation. It has nothing to do with the services referenced in the ca...
python
{ "resource": "" }
q20972
Calculation._getGlobals
train
def _getGlobals(self, **kwargs): """Return the globals dictionary for the formula calculation """ # Default globals globs = { "__builtins__": None, "all": all, "any": any, "bool": bool, "chr": chr, "cmp": cmp, ...
python
{ "resource": "" }
q20973
Calculation._getModuleMember
train
def _getModuleMember(self, dotted_name, member): """Get the member object of a module. :param dotted_name: The dotted name of the module, e.g. 'scipy.special' :type dotted_name: string :param member: The name of the member function, e.g. 'gammaincinv' :type member: string ...
python
{ "resource": "" }
q20974
after_unassign
train
def after_unassign(reference_analysis): """Removes the reference analysis from the system """ analysis_events.after_unassign(reference_analysis) ref_sample = reference_analysis.aq_parent ref_sample.manage_delObjects([reference_analysis.getId()])
python
{ "resource": "" }
q20975
after_retract
train
def after_retract(reference_analysis): """Function triggered after a 'retract' transition for the reference analysis passed in is performed. The reference analysis transitions to "retracted" state and a new copy of the reference analysis is created """ reference = reference_analysis.getSample() ...
python
{ "resource": "" }
q20976
Update.require
train
def require(self, fieldname, allow_blank=False): """fieldname is required""" if self.request.form and fieldname not in self.request.form.keys(): raise Exception("Required field not found in request: %s" % fieldname) if self.request.form and (not self.request.form[fieldname] or allow_...
python
{ "resource": "" }
q20977
Update.used
train
def used(self, fieldname): """fieldname is used, remove from list of unused fields""" if fieldname in self.unused: self.unused.remove(fieldname)
python
{ "resource": "" }
q20978
ReferenceResultsView.get_reference_results
train
def get_reference_results(self): """Return a mapping of Analysis Service -> Reference Results """ referenceresults = self.context.getReferenceResults() return dict(map(lambda rr: (rr.get("uid"), rr), referenceresults))
python
{ "resource": "" }
q20979
is_import_interface
train
def is_import_interface(instrument_interface): """Returns whether the instrument interface passed in is for results import """ if IInstrumentImportInterface.providedBy(instrument_interface): return True # TODO Remove this once classic instrument interface migrated if hasattr(instrument_inte...
python
{ "resource": "" }
q20980
is_export_interface
train
def is_export_interface(instrument_interface): """Returns whether the instrument interface passed in is for results export """ if IInstrumentExportInterface.providedBy(instrument_interface): return True # TODO Remove this once classic instrument interface migrated if hasattr(instrument_inte...
python
{ "resource": "" }
q20981
getExim
train
def getExim(exim_id): """Returns the instrument interface for the exim_id passed in """ interfaces = filter(lambda i: i[0]==exim_id, get_instrument_interfaces()) return interfaces and interfaces[0][1] or None
python
{ "resource": "" }
q20982
get_automatic_parser
train
def get_automatic_parser(exim_id, infile): """Returns the parser to be used by default for the instrument id interface and results file passed in. """ adapter = getExim(exim_id) if IInstrumentAutoImportInterface.providedBy(adapter): return adapter.get_automatic_parser(infile) # TODO Rem...
python
{ "resource": "" }
q20983
ReferenceSamplesView.is_manage_allowed
train
def is_manage_allowed(self): """Check if manage is allowed """ checkPermission = self.context.portal_membership.checkPermission return checkPermission(ManageWorksheets, self.context)
python
{ "resource": "" }
q20984
ReferenceSamplesView.get_assigned_services
train
def get_assigned_services(self): """Get the current assigned services of this Worksheet """ analyses = self.context.getAnalyses() routine_analyses = filter( lambda an: IRoutineAnalysis.providedBy(an), analyses) services = map(lambda an: an.getAnalysisService(), routin...
python
{ "resource": "" }
q20985
ReferenceSamplesView.get_assigned_services_uids
train
def get_assigned_services_uids(self): """Get the current assigned services UIDs of this Worksheet """ services = self.get_assigned_services() uids = map(api.get_uid, services) return list(set(uids))
python
{ "resource": "" }
q20986
ReferenceSamplesView.get_supported_services_uids
train
def get_supported_services_uids(self, referencesample): """Get the supported services of the reference sample """ uids = referencesample.getSupportedServices(only_uids=True) return list(set(uids))
python
{ "resource": "" }
q20987
ReferenceSamplesView.make_supported_services_choices
train
def make_supported_services_choices(self, referencesample): """Create choices for supported services """ choices = [] assigned_services = self.get_assigned_services_uids() for uid in self.get_supported_services_uids(referencesample): service = api.get_object(uid) ...
python
{ "resource": "" }
q20988
ReferenceSamplesView.make_position_choices
train
def make_position_choices(self): """Create choices for available positions """ choices = [] for pos in self.get_available_positions(): choices.append({ "ResultValue": pos, "ResultText": pos, }) return choices
python
{ "resource": "" }
q20989
ReferenceSamplesView.get_available_positions
train
def get_available_positions(self): """Return a list of empty slot numbers """ available_positions = ["new"] layout = self.context.getLayout() used_positions = [int(slot["position"]) for slot in layout] if used_positions: used = [ pos for pos in...
python
{ "resource": "" }
q20990
AnalysesView.isItemAllowed
train
def isItemAllowed(self, obj): """Returns true if the current analysis to be rendered has a slot assigned for the current layout. :param obj: analysis to be rendered as a row in the list :type obj: ATContentType/DexterityContentType :return: True if the obj has an slot assigned. ...
python
{ "resource": "" }
q20991
AnalysesView.folderitems
train
def folderitems(self): """Returns an array of dictionaries, each dictionary represents an analysis row to be rendered in the list. The array returned is sorted in accordance with the layout positions set for the analyses this worksheet contains when the analyses were added in the workshe...
python
{ "resource": "" }
q20992
AnalysesView.get_item_position
train
def get_item_position(self, analysis_uid): """Returns a list with the position for the analysis_uid passed in within the current worksheet in accordance with the current layout, where the first item from the list returned is the slot and the second is the position of the analysis within ...
python
{ "resource": "" }
q20993
AnalysesView.fill_empty_slots
train
def fill_empty_slots(self, items): """Append dicts to the items passed in for those slots that don't have any analysis assigned but the row needs to be rendered still. :param items: dictionary with the items to be rendered in the list """ for pos in self.get_empty_slots(): ...
python
{ "resource": "" }
q20994
AnalysesView.fill_slots_headers
train
def fill_slots_headers(self, items): """Generates the header cell for each slot. For each slot, the first cell displays information about the parent all analyses within that given slot have in common, such as the AR Id, SampleType, etc. :param items: dictionary with items to be rendered...
python
{ "resource": "" }
q20995
AnalysesView.skip_item_key
train
def skip_item_key(self, item, key): """Add the key to the item's "skip" list """ if "skip" in item: item["skip"].append(key) else: item["skip"] = [key] return item
python
{ "resource": "" }
q20996
AnalysesView.render_remarks_tag
train
def render_remarks_tag(self, ar): """Renders a remarks image icon """ if not ar.getRemarks(): return "" uid = api.get_uid(ar) url = ar.absolute_url() title = ar.Title() tooltip = _("Remarks of {}").format(title) # Note: The 'href' is picked u...
python
{ "resource": "" }
q20997
AnalysisRequest.Description
train
def Description(self): """Returns searchable data as Description""" descr = " ".join((self.getId(), self.aq_parent.Title())) return safe_unicode(descr).encode('utf-8')
python
{ "resource": "" }
q20998
AnalysisRequest.getDefaultMemberDiscount
train
def getDefaultMemberDiscount(self): """Compute default member discount if it applies """ if hasattr(self, 'getMemberDiscountApplies'): if self.getMemberDiscountApplies(): settings = self.bika_setup return settings.getMemberDiscount() else: ...
python
{ "resource": "" }
q20999
AnalysisRequest.getResponsible
train
def getResponsible(self): """Return all manager info of responsible departments """ managers = {} for department in self.getDepartments(): manager = department.getManager() if manager is None: continue manager_id = manager.getId() ...
python
{ "resource": "" }