def pdf(self): cssfn = resource_filename("bika.uw", "browser/css/batch-pdf.css") pdf_data = createPdf(t(self.pdf_wrapper()), css=cssfn) setheader = self.request.RESPONSE.setHeader setheader('Content-Length', len(pdf_data)) setheader('Content-Type', 'application/pdf') fn = self.context.Title() + ".pdf" setheader('Content-Disposition', 'inline; filename="{0}"'.format(fn)) self.request.RESPONSE.write(pdf_data)
def get_mail_subject(self, ar): """ Returns the email subject in accordance with the client preferences """ client = ar.aq_parent subject_items = client.getEmailSubject() ai = co = cr = cs = False if 'ar' in subject_items: ai = True if 'co' in subject_items: co = True if 'cr' in subject_items: cr = True if 'cs' in subject_items: cs = True ais = [] cos = [] crs = [] css = [] blanks_found = False if ai: ais.append(ar.getRequestID()) if co: if ar.getClientOrderNumber(): if not ar.getClientOrderNumber() in cos: cos.append(ar.getClientOrderNumber()) else: blanks_found = True if cr or cs: sample = ar.getSample() if cr: if sample.getClientReference(): if not sample.getClientReference() in crs: crs.append(sample.getClientReference()) else: blanks_found = True if cs: if sample.getClientSampleID(): if not sample.getClientSampleID() in css: css.append(sample.getClientSampleID()) else: blanks_found = True line_items = [] if ais: ais.sort() li = t(_('ARs: ${ars}', mapping={'ars': ', '.join(ais)})) line_items.append(li) if cos: cos.sort() li = t(_('Orders: ${orders}', mapping={'orders': ', '.join(cos)})) line_items.append(li) if crs: crs.sort() li = t(_('Refs: ${references}', mapping={'references':', '.join(crs)})) line_items.append(li) if css: css.sort() li = t(_('Samples: ${samples}', mapping={'samples': ', '.join(css)})) line_items.append(li) tot_line = ' '.join(line_items) if tot_line: subject = t(_('Analysis results for ${subject_parts}', mapping={'subject_parts':tot_line})) if blanks_found: subject += (' ' + t(_('and others'))) else: subject = t(_('Analysis results')) return subject, tot_line
def get_mail_subject(self, ar): """ Returns the email subject in accordance with the client preferences """ client = ar.aq_parent subject_items = client.getEmailSubject() ai = co = cr = cs = cn = False if 'ar' in subject_items: ai = True if 'co' in subject_items: co = True if 'cr' in subject_items: cr = True if 'cs' in subject_items: cs = True if 'cn' in subject_items: cn = True ais = [] cos = [] crs = [] css = [] cns = [] blanks_found = False if ai: ais.append(ar.getRequestID()) if co: if ar.getClientOrderNumber(): if not ar.getClientOrderNumber() in cos: cos.append(ar.getClientOrderNumber()) else: blanks_found = True if cr or cs: sample = ar.getSample() if cr: if sample.getClientReference(): if not sample.getClientReference() in crs: crs.append(sample.getClientReference()) else: blanks_found = True if cs: if sample.getClientSampleID(): if not sample.getClientSampleID() in css: css.append(sample.getClientSampleID()) else: blanks_found = True if cn: cns.append(ar.getClientTitle()) line_items = [] if ais: ais.sort() li = t(_('ARs: ${ars}', mapping={'ars': ', '.join(ais)})) line_items.append(li) if cos: cos.sort() li = t(_('Orders: ${orders}', mapping={'orders': ', '.join(cos)})) line_items.append(li) if crs: crs.sort() li = t(_('Refs: ${references}', mapping={'references':', '.join(crs)})) line_items.append(li) if css: css.sort() li = t(_('Samples: ${samples}', mapping={'samples': ', '.join(css)})) line_items.append(li) if cns: cns.sort() li = t(_('Client: ${client}', mapping={'client': ', '.join(cns)})) line_items.append(li) tot_line = ' '.join(line_items) if tot_line: subject = t(_('Analysis results for ${subject_parts}', mapping={'subject_parts':tot_line})) if blanks_found: subject += (' ' + t(_('and others'))) else: subject = t(_('Analysis results')) return subject, tot_line
def Import(context, request): """ PANalytical - Omnia Axios_XRF analysis results """ infile = request.form['panalytical_omnia_axios_file'] fileformat = request.form['panalytical_omnia_axios_format'] artoapply = request.form['panalytical_omnia_axios_artoapply'] override = request.form['panalytical_omnia_axios_override'] instrument = request.form.get('instrument', None) errors = [] logs = [] warns = [] # Load the most suitable parser according to file extension/options/etc... parser = None if not hasattr(infile, 'filename'): errors.append(_("No file selected")) if fileformat == 'csv': parser = AxiosXrfCSVParser(infile) elif fileformat == 'csv_multi': parser = AxiosXrfCSVMultiParser(infile) else: errors.append(t(_("Unrecognized file format ${file_format}", mapping={"file_format": fileformat}))) if parser: # Load the importer status = ['sample_received', 'attachment_due', 'to_be_verified'] if artoapply == 'received': status = ['sample_received'] elif artoapply == 'received_tobeverified': status = ['sample_received', 'attachment_due', 'to_be_verified'] over = [False, False] if override == 'nooverride': over = [False, False] elif override == 'override': over = [True, False] elif override == 'overrideempty': over = [True, True] importer = AxiosXrfImporter(parser=parser, context=context, allowed_ar_states=status, allowed_analysis_states=None, override=over, instrument_uid=instrument) tbex = '' try: importer.process() except: tbex = traceback.format_exc() errors = importer.errors logs = importer.logs warns = importer.warns if tbex: errors.append(tbex) results = {'errors': errors, 'log': logs, 'warns': warns} return json.dumps(results)
def Import(context, request): """ PANalytical - Omnia Axios_XRF analysis results """ infile = request.form['panalytical_omnia_axios_file'] fileformat = request.form['panalytical_omnia_axios_format'] artoapply = request.form['panalytical_omnia_axios_artoapply'] override = request.form['panalytical_omnia_axios_override'] sample = request.form.get('panalytical_omnia_axios_sample', 'requestid') instrument = request.form.get('panalytical_omnia_axios_instrument', None) errors = [] logs = [] warns = [] # Load the most suitable parser according to file extension/options/etc... parser = None if not hasattr(infile, 'filename'): errors.append(_("No file selected")) if fileformat == 'csv': parser = AxiosXrfCSVParser(infile) elif fileformat == 'csv_multi': parser = AxiosXrfCSVMultiParser(infile) else: errors.append(t(_("Unrecognized file format ${file_format}", mapping={"file_format": fileformat}))) if parser: # Load the importer status = ['sample_received', 'attachment_due', 'to_be_verified'] if artoapply == 'received': status = ['sample_received'] elif artoapply == 'received_tobeverified': status = ['sample_received', 'attachment_due', 'to_be_verified'] over = [False, False] if override == 'nooverride': over = [False, False] elif override == 'override': over = [True, False] elif override == 'overrideempty': over = [True, True] sam = ['getRequestID', 'getSampleID', 'getClientSampleID'] if sample == 'requestid': sam = ['getRequestID'] if sample == 'sampleid': sam = ['getSampleID'] elif sample == 'clientsid': sam = ['getClientSampleID'] elif sample == 'sample_clientsid': sam = ['getSampleID', 'getClientSampleID'] importer = AxiosXrfImporter(parser=parser, context=context, idsearchcriteria=sam, allowed_ar_states=status, allowed_analysis_states=None, override=over, instrument_uid=instrument) tbex = '' try: importer.process() except: tbex = traceback.format_exc() errors = importer.errors logs = importer.logs warns = importer.warns if tbex: errors.append(tbex) results = {'errors': errors, 'log': logs, 'warns': warns} return json.dumps(results)