class Red5StreamExtender(object): adapts(IRed5Stream) implements(ISchemaExtender) fields = [ ExtensionBlobField('file', required=True, primary=True, searchable=True, default='', read_permission=DownloadRed5Stream, index_method='getIndexValue', languageIndependent=True, storage=AnnotationStorage(migrate=True), validators=(('isNonEmptyFile', V_REQUIRED), ('checkFileMaxSize', V_REQUIRED)), widget=FileWidget( label=_(u'label_file', default=u'File'), description=_(u''), show_content_type=False, )) ] def __init__(self, context): self.context = context def getFields(self): return self.fields
class FileBlobAttachment(object): adapts(IFileAttachment) implements(ISchemaExtender) fields = [ FileField('file', required=True, primary=True, searchable=True, accessor='getFile', mutator='setFile', index_method='getIndexValue', languageIndependent=True, storage=AnnotationStorage(migrate=True), default_content_type='application/octet-stream', validators=(('isNonEmptyFile', V_REQUIRED), ('checkFileMaxSize', V_REQUIRED)), widget=FileWidget( label=_('label_file', default='File'), description=_(''), show_content_type=False, )), ] def __init__(self, context): self.context = context def getFields(self): return self.fields
def get_file_field(): return FileField('file', required=True, primary=True, searchable=True, languageIndependent=True, storage=AnnotationStorage(migrate=True), validators=(('isNonEmptyFile', V_REQUIRED), ('checkFileMaxSize', V_REQUIRED)), widget=FileWidget( description='', label='File', show_content_type=False, ))
def getFields(self): """ change the field to be languageIndependant = False""" return [ ExtensionBlobField('file', required=True, primary=True, searchable=True, default='', accessor='getFile', mutator='setFile', index_method='getIndexValue', languageIndependent=False, storage=AnnotationStorage(migrate=True), validators=(('isNonEmptyFile', V_REQUIRED), ('checkFileMaxSize', V_REQUIRED)), widget=FileWidget( label=_(u'File'), description=_(u''), show_content_type=False, )) ]
from bika.lims import logger from bika.lims.config import PROJECTNAME from bika.lims.config import ATTACHMENT_REPORT_OPTIONS from bika.lims import bikaMessageFactory as _ from bika.lims.content.bikaschema import BikaSchema from bika.lims.browser.widgets import DateTimeWidget schema = BikaSchema.copy() + Schema(( ComputedField( 'RequestID', expression='here.getRequestID()', widget=ComputedWidget(visible=True, ), ), FileField( 'AttachmentFile', widget=FileWidget(label=_("Attachment"), ), ), ReferenceField( 'AttachmentType', required=0, allowed_types=('AttachmentType', ), relationship='AttachmentAttachmentType', widget=ReferenceWidget(label=_("Attachment Type"), ), ), StringField( 'ReportOption', searchable=True, vocabulary="ATTACHMENT_REPORT_OPTIONS", widget=SelectionWidget( label=_("Report Options"), checkbox_bound=0,
validation.register( MaxSizeValidator('checkFileMaxSize', maxsize=zconf.ATFile.max_file_size)) ATFileSchema = ATContentTypeSchema.copy() + Schema( (FileField('file', required=True, primary=True, searchable=True, languageIndependent=True, storage=AnnotationStorage(migrate=True), validators=(('isNonEmptyFile', V_REQUIRED), ('checkFileMaxSize', V_REQUIRED)), widget=FileWidget( description='', label=_(u'label_file', default=u'File'), show_content_type=False, )), ), marshall=PrimaryFieldMarshaller()) # Title is pulled from the file name if we don't specify anything, # so it's not strictly required, unlike in the rest of ATCT. ATFileSchema['title'].required = False finalizeATCTSchema(ATFileSchema) class ATFile(ATCTFileContent): """An external file uploaded to the site.""" schema = ATFileSchema
'columnName': 'UID', 'hidden': True }, { 'columnName': 'JobTitle', 'width': '20', 'label': _('Job Title') }, { 'columnName': 'Title', 'width': '80', 'label': _('Name') }], ), ), BlobFileField('Document', widget=FileWidget( label=_("Report upload"), description=_("Load the certificate document here"), )), TextField("Remarks", allowable_content_types=("text/plain", ), widget=TextAreaWidget(label=_("Remarks"), )), )) schema['title'].widget.label = _("Certificate Code") class InstrumentCertification(BaseFolder): """Issued certification from an instrument calibration """ implements(IInstrumentCertification) security = ClassSecurityInfo() schema = schema
schemata='Additional info.', widget=ImageWidget( label=_("Photo image file"), description=_("Photo of the instrument"), ), ), DateTimeField('InstallationDate', schemata='Additional info.', widget=DateTimeWidget( label=_("InstallationDate"), description=_("The date the instrument was installed"), )), BlobFileField('InstallationCertificate', schemata='Additional info.', widget=FileWidget( label=_("Installation Certificate"), description=_("Installation certificate upload"), )), )) schema.moveField('AssetNumber', before='description') schema.moveField('SupplierName', before='Model') schema.moveField('ManufacturerName', before='SupplierName') schema.moveField('InstrumentTypeName', before='ManufacturerName') schema['description'].widget.visible = True schema['description'].schemata = 'default' def getDataInterfaces(context, export_only=False): """ Return the current list of data interfaces """
from eea.dataservice.interfaces import IEEAFigureFile from eea.dataservice.vocabulary import CATEGORIES_DICTIONARY_ID from AccessControl import ClassSecurityInfo # Schema schema = Schema( ( BlobField('file', required=False, primary=True, validators=(('checkFileMaxSize', V_REQUIRED), ), widget=FileWidget( description=("Select the file to be added by " "clicking the 'Browse' button."), description_msgid="help_file", label="File", label_msgid="label_file", i18n_domain="plone", show_content_type=False, )), StringField( name='category', default='edse', vocabulary=NamedVocabulary(CATEGORIES_DICTIONARY_ID), widget=SelectionWidget( format="select", # possible values: flex, select, radio label="Category", description="Category description.", label_msgid='dataservice_label_category', description_msgid='dataservice_help_category', i18n_domain='eea',
u'Poi_help_steps', default=(u"If applicable, please provide the steps to " u"reproduce the error or identify the issue, one per " u"line.")), rows=6, allow_file_upload=False, ), default_output_type="text/html", default_content_type=DEFAULT_ISSUE_MIME_TYPE, searchable=True), FileField( name='attachment', widget=FileWidget( label=_(u'Poi_label_attachment', default=u"Attachment"), description=_( u'Poi_help_attachment', default=( u"You may optionally upload a file attachment. Please " u"do not upload unnecessarily large files.")), ), storage=AttributeStorage(), write_permission=permissions.UploadAttachment), StringField(name='area', widget=SelectionWidget( label=_(u'Poi_label_area', default=u"Area"), description=_( u'Poi_help_area', default=u"Select the area this issue is relevant to."), ), enforceVocabulary=True, default_method='getDefaultArea', vocabulary='getAreasVocab',
allow_file_upload=False, label_msgid='Poi_label_steps', description_msgid='Poi_help_steps', i18n_domain='Poi', ), default_output_type="text/html", default_content_type=DEFAULT_ISSUE_MIME_TYPE, searchable=True ), FileField( name='attachment', widget=FileWidget( label="Attachment", description="You may optionally upload a file attachment. Please do not upload unnecessarily large files.", label_msgid='Poi_label_attachment', description_msgid='Poi_help_attachment', i18n_domain='Poi', ), storage=AttributeStorage(), write_permission=permissions.UploadAttachment ), StringField( name='area', index="FieldIndex:schema", widget=SelectionWidget( label="Area", description="Select the area this issue is relevant to.", label_msgid='Poi_label_area', description_msgid='Poi_help_area',
class BatchSchemaExtender(object): adapts(IBatch) implements(IOrderableSchemaExtender, IBrowserLayerAwareExtender) layer = INalLimsLayer security = ClassSecurityInfo() fields = [ ExtDateTimeField( "SDGDate", required=True, widget=DateTimeWidget( label="Date Received", description="The Date the Sample Delivery Group was received by the lab.", show_time=False, datepicker_nofuture=1, ) ), ExtStringField( 'SDGTime', required=True, widget=StringWidget( label=_("Time Received"), description=_("The Time the Sample Delivery Group was received by the lab."), ), ), ExtStringField( 'ReportContact', widget=StringWidget( label=_("Report Contact"), description=_("Optional field. Used if there is a secondary client the results are being tested for."), ), ), ExtReferenceField( 'ProjectContact', required=True, default_method='getContactUIDForUser', allowed_types=('Contact',), referenceClass=HoldingReference, relationship="SDGProjectContact", mode="rw", widget=ReferenceWidget( label=_("Project Contact"), size=20, helper_js=("bika_widgets/referencewidget.js", "++resource++bika.lims.js/contact.js"), description=_("The main contact for the project"), catalog_name="portal_catalog", base_query={"is_active": True, "sort_limit": 50, "sort_on": "sortable_title", "sort_order": "ascending"}, showOn=True, popup_width='400px', colModel=[ {'columnName': 'Fullname', 'width': '50', 'label': _('Name')}, {'columnName': 'EmailAddress', 'width': '50', 'label': _('Email Address')}, ], ui_item='Fullname', ), ), ExtReferenceField( 'SamplerContact', required=True, default_method='getContactUIDForUser', allowed_types=('Contact',), referenceClass=HoldingReference, relationship="SDGSamplerContact", mode="rw", widget=ReferenceWidget( label=_("Sampled By"), size=20, helper_js=("bika_widgets/referencewidget.js", "++resource++bika.lims.js/contact.js"), description=_("The person who performed the sampling method."), catalog_name="portal_catalog", base_query={"is_active": True, "sort_limit": 50, "sort_on": "sortable_title", "sort_order": "ascending"}, showOn=True, popup_width='400px', colModel=[ {'columnName': 'Fullname', 'width': '50', 'label': _('Name')}, {'columnName': 'EmailAddress', 'width': '50', 'label': _('Email Address')}, ], ui_item='Fullname', ), ), ExtFileField( 'COC', widget=FileWidget( label="Chain Of Custody", description="Select a printed COC to attach.", visible=False, ) ), ] #Custom function for Contact Fields security.declarePublic('getContactUIDForUser') security.declarePublic('getCurrentDate') def getContactUIDForUser(self): """get the UID of the contact associated with the authenticated user """ mt = getToolByName(self, 'portal_membership') user = mt.getAuthenticatedMember() user_id = user.getUserName() pc = getToolByName(self, 'portal_catalog') r = pc(portal_type='Contact', getUsername=user_id) if len(r) == 1: return r[0].UID def __init__(self, context): self.context = context def getOrder(self, schematas): return schematas def getFields(self): return self.fields
RESPONSE.setHeader("Content-disposition", header_value) return zfile.index_html(REQUEST, RESPONSE) schema = Schema(( FlashFileField('file', required=True, primary=True, languageIndependent=True, storage=AnnotationStorage(migrate=True), validators=(('isNonEmptyFile', V_REQUIRED), ('checkFileMaxSize', V_REQUIRED)), widget=FileWidget( description="", label="File", label_msgid="label_file", i18n_domain="plone", show_content_type=False, )), IntegerField('width', widget=IntegerWidget( label='Width', label_msgid='EEAContentTypes_label_width', description_msgid='EEAContentTypes_help_width', i18n_domain='EEAContentTypes', )), IntegerField('height', widget=IntegerWidget( label='Height', label_msgid='EEAContentTypes_label_height', description_msgid='EEAContentTypes_help_height',
} ECAssignmentSchema['description'].widget.visible = { 'view': 'invisible', 'edit': 'invisible' } # define schema ECAssignmentSchema = ECAssignmentSchema + Schema(( FileField( 'file', searchable=True, primary=True, widget=FileWidget( label="Answer", label_msgid="label_answer", description="The submission for this assignment", description_msgid="help_answer", i18n_domain=config.I18N_DOMAIN, macro='answer_widget', ), ), TextField( 'remarks', allowable_content_types=config.ALLOWED_CONTENT_TYPES, default_content_type=config.DEFAULT_CONTENT_TYPE, default_output_type=config.DEFAULT_OUTPUT_TYPE, widget=RichWidget( #widget = TextAreaWidget( label="Remarks", label_msgid="label_remarks", description= "Your remarks for this assignment (they will not be shown to the student)",