Skip to content

Instantly share code, notes, and snippets.

View rockfruit's full-sized avatar

Campbell rockfruit

View GitHub Profile
@rockfruit
rockfruit / analysisrequest.py
Created January 15, 2017 10:34
Modify widgets of some sample/AR fields
# You'd make one of these for sample.py and add zcml config for those, too
from archetypes.schemaextender.interfaces import IOrderableSchemaExtender
from archetypes.schemaextender.interfaces import ISchemaModifier
from bika.lims.interfaces import IAnalysisRequest
from zope.component import adapts
from zope.interface import implements
from Products.CMFCore import permissions
from bika.lims.browser.widgets import DateTimeWidget
@rockfruit
rockfruit / multi_ar_report.css
Created November 2, 2016 12:24
multi_ar report without <table> tags
/* IMPORTANT NOTE
* Do not use margins, use padding instead
*/
@page {
}
#report {
font: 8pt Arial, Verdana, serif;
}
@rockfruit
rockfruit / stickertemplate.pt
Created May 9, 2016 10:14
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
@rockfruit
rockfruit / README.txt
Last active April 15, 2016 22:55
Snippets for poking at data in a Plone/bika.lims installation.
Run the scripts like this:
$ bin/client_reserved -O <site_id> run <script>.py
# To login at the debug prompt, this:
user_name_or_id = 'admin'
from AccessControl.SecurityManagement import newSecurityManager
user = app.acl_users.getUser(user_name_or_id)
newSecurityManager(None, user.__of__(app.acl_users))
@rockfruit
rockfruit / remove_transactional.py
Last active January 4, 2016 02:40
Remove all ARs, Samples, Analyses, Worksheets, Pricelists, SupplyOrders, and invoices.
# bin/client1 -O Plone remove_transactional.py
user_name_or_id = 'admin'
from AccessControl.SecurityManagement import newSecurityManager
user = app.acl_users.getUser(user_name_or_id)
newSecurityManager(None, user.__of__(app.acl_users))
bc = app.Plone.bika_catalog
pc = app.Plone.portal_catalog
:10072B0000004C00002B3500000000000000000012
:10073B00041F2BE31E141D00E400392C00E1E5001F
:10074B00004F00DF52000000E20000DE000000E678
:10075B0000000000002A28000000000048E0000014
:10076B0000000000000000001A3A4E3B4B291B15FD
:10077B00003C4C3D000000001620092518083606E9
:10078B0007210A221317051911230F240D0B100E25
:10079B002F3E283F2E31E35034402D41261C370C81
:1007AB0038425143271233300044E0454A000000E1
:1007BB0000004C00002F3000000000000000000083
bika2_export.py
===============
Export bika2 data to CSV files. You can use any bika2 instance - only
standard python modules are required.
$ bin/instance run bika2_export.py sitename
This will create a folder called ./sitename-csv