Ejemplo n.º 1
0
    def __call__(self):
        annotations = IAnnotations(self.context)

        # get the contents of the context
        mimetype, payload = self.getPayload()

        if mimetype:
            basetype = mimetype.split('/')[0]
        else:
            basetype = None

        if basetype in EXCLUDE_TYPES:
            logger.warn('Type {0} is in excluded types, '
                        'skipping {1}'.format(
                            basetype,
                            self.context.getId())
                        )
            annotations[PREVIEW_MESSAGE_KEY] = ('There is no preview for this '
                                                'file type')
            return

        try:
            converted = self.convert_on_server(payload, mimetype)
        except ServerError as e:
            if e.args and e.args[0].startswith("Error connecting"):
                annotations[PREVIEW_MESSAGE_KEY] = (
                    'Could not contact conversion server')
            else:
                annotations[PREVIEW_MESSAGE_KEY] = (
                    'Sorry, this document type cannot be converted. There is '
                    'no preview available.')
            return
        except ConfigError:
            converted = self.convert_locally(payload, mimetype)

        pdfdata = FileField()
        pdfdata.set(self.context, converted['pdfs'][0])
        previewdata = []
        thumbdata = []
        for filedata in converted['previews'][:20]:
            IF = ImageField()
            IF.set(self.context, filedata)
            previewdata.append(IF)
        for filedata in converted['thumbnails'][:20]:
            IF = ImageField()
            IF.set(self.context, filedata)
            thumbdata.append(IF)

        annotations[PDF_VERSION_KEY] = pdfdata
        annotations[PREVIEW_IMAGES_KEY] = previewdata
        annotations[THUMBNAIL_KEY] = thumbdata
Ejemplo n.º 2
0
from bika.lims import api
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,
Ejemplo n.º 3
0
            },
        ),
    ),

    # atapi.ReferenceField(
    #     name='anexos',
    #     widget = ReferenceBrowserWidget(
    #         label=_(u"Anexos"),
    #     ),
    #     type=['File', 'ArquivoBiblioteca'],
    #     required=True,
    #     multiValued=True,
    # )
    FileField(
        name='anexos',
        title=u'Anexo',
        description=u'É obrigatório a inserção de pelo menos um anexo',
        required=True,
    ),
))

BoaPratica_schema['description'].default_content_type = 'text/html'
BoaPratica_schema['description'].allowable_content_types = ('text/html', )
BoaPratica_schema['description'].default_output_type = 'text/html'
BoaPratica_schema['description'].widget = atapi.RichWidget(
    label=u'Descrição', allow_file_upload=False)

schemata.finalizeATCTSchema(BoaPratica_schema, folderish=True)


class BoaPratica(folder.ATFolder):
    """ Reserve Content for BoaPratica"""
Ejemplo n.º 4
0
ATTestDocumentSchema = ATDocumentSchema.copy() + atapi.Schema((
    atapi.StringField("testStringField"),
    atapi.BooleanField("testBooleanField"),
    atapi.IntegerField("testIntegerField"),
    atapi.FloatField("testFloatField"),
    atapi.FixedPointField("testFixedPointField"),
    atapi.DateTimeField("testDateTimeField"),
    atapi.LinesField("testLinesField"),
    atapi.FileField("testFileField"),
    atapi.TextField("testTextField"),
    atapi.ImageField("testImageField"),
    atapi.ReferenceField("testReferenceField", relationship="testrelation"),
    atapi.ReferenceField(
        "testMVReferenceField", relationship="testrelation", multiValued=True),
    BlobField("testBlobField"),
    FileField("testBlobFileField"),
    ImageField("testBlobImageField"),
    QueryField("testQueryField"),
    atapi.StringField("testRequiredField", required=True),
    atapi.StringField("testReadonlyField", mode="r"),
    atapi.StringField("testWriteonlyField", mode="w"),
    atapi.StringField("testReadPermissionField",
                      read_permission=permissions.ManagePortal),
    atapi.StringField("testWritePermissionField",
                      write_permission=permissions.ManagePortal),
    atapi.StringField("testURLField", validators=("isURL", )),
))


class ATTestDocument(ATDocumentBase):
    """A test type containing a set of standard Archetypes fields."""
Ejemplo n.º 5
0
            visible={'view': 'hidden', 'edit': 'hidden'},
            label=_(u"Probmap View"),
            #description=_(u"A SimMap view visualzing the Probmap."),
            startup_directory='/luc/drivers',
        ),
        required=False,
        relationship='probmap_probview',
        allowed_types=('SimMap'),
        multiValued=False,
    ),
    
    FileField(
        'probfile',
        storage=atapi.AnnotationStorage(),
        widget=atapi.FileWidget(
            visible={'view': 'hidden', 'edit': 'visible'},
            label=_(u"Probmap File"),
            #description=_(u"Precomputed version of the probability map."),
        ),
        required=False,
    ),

))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

ProbmapSchema['title'].storage = atapi.AnnotationStorage()
ProbmapSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(ProbmapSchema, moveDiscussion=False)
Ejemplo n.º 6
0
ATTestDocumentSchema = ATDocumentSchema.copy() + atapi.Schema((
    atapi.StringField('testStringField'),
    atapi.BooleanField('testBooleanField'),
    atapi.IntegerField('testIntegerField'),
    atapi.FloatField('testFloatField'),
    atapi.FixedPointField('testFixedPointField'),
    atapi.DateTimeField('testDateTimeField'),
    atapi.LinesField('testLinesField'),
    atapi.FileField('testFileField'),
    atapi.TextField('testTextField'),
    atapi.ImageField('testImageField'),
    atapi.ReferenceField('testReferenceField', relationship='testrelation'),
    atapi.ReferenceField(
        'testMVReferenceField', relationship='testrelation', multiValued=True),
    BlobField('testBlobField'),
    FileField('testBlobFileField'),
    ImageField('testBlobImageField'),
    QueryField('testQueryField'),
    atapi.StringField('testRequiredField', required=True),
    atapi.StringField('testReadonlyField', mode='r'),
    atapi.StringField('testWriteonlyField', mode='w'),
    atapi.StringField('testReadPermissionField',
                      read_permission=permissions.ManagePortal),
    atapi.StringField('testWritePermissionField',
                      write_permission=permissions.ManagePortal),
    atapi.StringField('testURLField', validators=('isURL', )),
))


class ATTestDocument(ATDocumentBase):
    """A test type containing a set of standard Archetypes fields."""
Ejemplo n.º 7
0
from plone.app.blob.config import packageName
from plone.app.blob.config import permissions
from plone.app.blob.field import FileField
from plone.app.blob.field import ImageField
from plone.app.blob.tests.base import changeAllowedSizes
from plone.app.blob.tests.base import ReplacementTestCase
from plone.app.blob.tests.utils import getFile
from Products.Archetypes.public import BaseContent
from Products.Archetypes.public import BaseSchema
from Products.Archetypes.public import FileWidget
from Products.Archetypes.public import ImageWidget
from Products.Archetypes.public import registerType
from Products.Archetypes.public import Schema

SampleSchema = BaseSchema.copy() + Schema((
    FileField(name='foo',
              widget=FileWidget(label='File', description='a file')),
    ImageField(name='bar',
               widget=ImageWidget(label='Image', description='an image')),
    ImageField(name='hmm',
               sizes={'tiny': (42, 42)},
               widget=ImageWidget(label='Image', description='an image')),
))


class SampleType(BaseContent):

    portal_type = 'SampleType'
    schema = SampleSchema


permissions['SampleType'] = packageName + ': SampleType'
Ejemplo n.º 8
0
from bika.lims.content.bikaschema import BikaSchema
from bika.lims.interfaces import IMultifile
from plone.app.blob.field import FileField
from Products.Archetypes import atapi
from Products.Archetypes.public import BaseContent
from zope.interface import implements

schema = BikaSchema.copy() + atapi.Schema((
    atapi.StringField("DocumentID",
                      required=1,
                      searchable=True,
                      validators=("uniquefieldvalidator", ),
                      widget=atapi.StringWidget(label=_("Document ID"), )),
    FileField("File",
              required=1,
              widget=atapi.FileWidget(
                  label=_("Document"),
                  description=_("File upload "),
              )),
    atapi.StringField("DocumentVersion",
                      widget=atapi.StringWidget(
                          label=_("Document Version"), )),
    atapi.StringField(
        "DocumentLocation",
        searchable=True,
        widget=atapi.StringWidget(
            label=_("Document Location"),
            description=_("Location where the document set is shelved"),
        )),
    atapi.StringField("DocumentType",
                      required=1,
                      searchable=True,