Skip to content

Instantly share code, notes, and snippets.

@rockfruit
Created May 9, 2016 10:14
Show Gist options
  • Save rockfruit/de832b60d7706fbcc723742586d78646 to your computer and use it in GitHub Desktop.
Save rockfruit/de832b60d7706fbcc723742586d78646 to your computer and use it in GitHub Desktop.
really simple two column sticker template
<!--
THIS version prints TWO stickers side by side. It does this by calling
view.nextItem manually in the tal:define on the <tal:bothstickers> block.
To retrieve the item, use view.current_item, that will return an array like:
[analysis_request_object, sample_object, sample_partition_object]
Although sample_object (position 1 in the array) will never be None,
analysis_request_object can be None when
a) The user requested to render stickers for samples (instead of ARs) or
b) The user requested to render stickers for sample partitions or
c) The user requested to render stickers for reference samples.
If c), both analysis_request_object and sample_partition_object will be None
-->
<tal:bothstickers tal:define="items python:[view.current_item];
dummy python:view.nextItem();
dummy python:items.append(view.current_item);
portal_state context/@@plone_portal_state;
portal_url portal_state/portal_url;
show_partitions python:context.bika_setup.getShowPartitions();">
<tal:sticker tal:repeat="item items">
<div class="sticker" tal:define="
ar python:item[0];
sample python:item[1];
part python:item[2];
ar_id ar/getId;
sample_id sample/getId;
CSID python:sample.getClientSampleID();
Order python:sample.getAnalysisRequests()[0].getClientOrderNumber();
Hazardous python:sample.getSampleType().getHazardous();
SamplePoint python:sample.getSamplePoint() and sample.getSamplePoint().Title() or '';
SampleType python:sample.getSampleType().Title();
Sampler python:sample.getSampler();
Preservation python:part.getPreservation() and part.getPreservation().Title() or '';
Container python:part.getContainer() and part.getContainer().Title() or '';
SamplingDate python:sample.getSamplingDate() and sample.getSamplingDate().Date();
Deviation python:sample.getSamplingDeviation() and sample.getSamplingDeviation().Title() or '';
DateSampled python:sample.getDateSampled() and sample.getDateSampled().Date();
Composite python:sample.getComposite();
AdHoc python:sample.getAdHoc();
analyses python:part.getBackReferences('AnalysisSamplePartition');
field_analyses python:[analysis for analysis in analyses if analysis.getService().getPointOfCapture()=='field'];
hazardous python:sample.getSampleType().getHazardous();">
<table cellpadding="0" cellspacing="0">
<tr>
<th i18n:translate="">Sample ID</th>
<td tal:content="sample/getId"/>
<th i18n:translate="">Create date</th>
<td tal:content=""/>
<tr>
<tr>
<th i18n:translate="">Sampling Date</th>
<td tal:content="SamplingDate"/>
<th i18n:translate="">Sampler</th>
<td tal:content="Sampler"/>
<tr>
<tr>
<td colspan="4" class='barcode-container'>
<!-- Barcode -->
<div class="barcode"
tal:attributes="data-id sample_id;"
data-barHeight="12"
data-code="code39"
data-addQuietZone="true"
data-showHRI="false">
</div>
</td>
</tr>
</table>
</div>
</tal:sticker>
</tal:bothstickers>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment