def test_size_in_field(self):
     validator = MaxSizeValidator('checkFileMaxSize')
     or_image_size = self.settings.image_size
     self.settings.image_size = 0
     self.assertEqual(
         float(10),
         self.helper_view.get_maxsize(validator,
                                      **{'field': base.get_image_field()}))
     self.settings.image_size = or_image_size
 def test_size_in_instance(self):
     validator = MaxSizeValidator('checkFileMaxSize')
     or_file_size = self.settings.file_size
     self.settings.file_size = 0
     self.assertEqual(
         float(20),
         self.helper_view.get_maxsize(
             validator, **{
                 'field': base.get_file_field(),
                 'instance': base.PFObject()
             }))
     self.settings.file_size = or_file_size
 def test_size_from_validator_instance(self):
     # original validator for file and image read maxsize from
     # zconf.ATFile.max_file_size at the end we have a number
     # By default in the registry we have 30MB for file and 10MB for images
     validator = MaxSizeValidator('checkFileMaxSize', maxsize=50.0)
     or_file_size = self.settings.file_size
     self.settings.file_size = 0
     self.assertEqual(
         float(50),
         self.helper_view.get_maxsize(validator,
                                      **{'field': base.get_file_field()}))
     self.settings.file_size = or_file_size
Beispiel #4
0
 def test_size_in_kwargs(self):
     validator = MaxSizeValidator('checkFileMaxSize')
     or_file_size = self.settings.file_size
     self.settings.file_size = 0
     self.assertEqual(
         float(15),
         get_maxsize(
             validator, self.settings, **{
                 'maxsize': 15.0,
                 'field': base.get_file_field(),
                 'instance': base.PFObject()
             }))
     self.settings.file_size = or_file_size
 def test_size_from_registry_type_setting(self):
     # new in version 1.3: type/field specific settings
     validator = MaxSizeValidator('checkFileMaxSize', maxsize=50.0)
     new_value = (TypesSettings(u'News Item', u'image', 7), )
     self.settings.types_settings += new_value
     self.assertEqual(
         float(7),
         self.helper_view.get_maxsize(
             validator, **{
                 'maxsize': 15.0,
                 'field': base.get_image_field(),
                 'instance': base.PFObject()
             }))
     self.settings.types_settings = ()
 def test_size_from_registry(self):
     # original validator for file and image read maxsize from
     # zconf.ATFile.max_file_size at the end we have a number
     # so we pass maxsize=N.
     # By default in the registry we have 30MB for file and 10MB for images
     # and calling the validator with all the possible values, validation
     # should be done with user values
     validator = MaxSizeValidator('checkFileMaxSize', maxsize=50.0)
     self.assertEqual(
         float(30),
         self.helper_view.get_maxsize(
             validator, **{
                 'maxsize': 15.0,
                 'field': base.get_file_field(),
                 'instance': base.PFObject()
             }))
     self.assertEqual(
         float(10),
         self.helper_view.get_maxsize(
             validator, **{
                 'maxsize': 15.0,
                 'field': base.get_image_field(),
                 'instance': base.PFObject()
             }))
Beispiel #7
0
from Products.ATContentTypes.content.base import registerATCT
from Products.ATContentTypes.content.base import ATCTFileContent
from Products.ATContentTypes.content.schemata import ATContentTypeSchema
from Products.ATContentTypes.content.schemata import finalizeATCTSchema
from Products.ATContentTypes.interfaces import IATFile

from Products.ATContentTypes import ATCTMessageFactory as _

from Products.validation.validators.SupplValidators import MaxSizeValidator
from Products.validation.config import validation
from Products.validation import V_REQUIRED

LOG = logging.getLogger('ATCT')

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,
               )), ),
from Products.ATContentTypes.content.document import ATDocumentBase
from Products.ATContentTypes.content.image import ATCTImageTransform
from Products.ATContentTypes.content.schemata import ATContentTypeSchema
from Products.ATContentTypes.content.schemata import finalizeATCTSchema
from Products.ATContentTypes.interfaces import IATNewsItem

from Products.ATContentTypes import ATCTMessageFactory as _

from Products.CMFCore.permissions import View

from Products.validation.config import validation
from Products.validation.validators.SupplValidators import MaxSizeValidator
from Products.validation import V_REQUIRED

validation.register(
    MaxSizeValidator('checkNewsImageMaxSize',
                     maxsize=zconf.ATNewsItem.max_file_size))

ATNewsItemSchema = ATContentTypeSchema.copy() + Schema(
    (
        TextField(
            'text',
            required=False,
            searchable=True,
            primary=True,
            storage=AnnotationStorage(migrate=True),
            validators=('isTidyHtmlWithCleanup', ),
            #validators = ('isTidyHtml',),
            default_output_type='text/x-html-safe',
            widget=RichWidget(
                description='',
                label=_(u'label_body_text', u'Body Text'),
Beispiel #9
0
from Products.ATContentTypes.configuration import zconf
from Products.ATContentTypes.content.base import ATCTFileContent
from Products.ATContentTypes.content.base import registerATCT
from Products.ATContentTypes.content.schemata import ATContentTypeSchema
from Products.ATContentTypes.content.schemata import finalizeATCTSchema
from Products.ATContentTypes.interfaces import IATImage
from Products.ATContentTypes.lib.imagetransform import ATCTImageTransform
from Products.CMFCore.permissions import ModifyPortalContent
from Products.CMFCore.permissions import View
from Products.validation import V_REQUIRED
from Products.validation.config import validation
from Products.validation.validators.SupplValidators import MaxSizeValidator
from zope.interface import implementer

validation.register(
    MaxSizeValidator('checkImageMaxSize', maxsize=zconf.ATImage.max_file_size))

ATImageSchema = ATContentTypeSchema.copy() + Schema(
    (ImageField(
        'image',
        required=True,
        primary=True,
        languageIndependent=True,
        storage=AnnotationStorage(migrate=True),
        swallowResizeExceptions=zconf.swallowImageResizeExceptions.enable,
        pil_quality=zconf.pil_config.quality,
        pil_resize_algo=zconf.pil_config.resize_algo,
        max_size=zconf.ATImage.max_image_dimension,
        sizes={
            'large': (768, 768),
            'preview': (400, 400),
Beispiel #10
0
from Products.Archetypes import atapi
from Products.ATContentTypes.content import schemata, link
from Products.Archetypes.atapi import StringField, ImageField
from Products.Archetypes.atapi import ImageWidget, StringWidget

from pd.content.interfaces import ISlideshowItem
from pd.content.config import PROJECTNAME

from Products.ATContentTypes.configuration import zconf
from pd.content import contentMessageFactory as _

from Products.validation.config import validation
from Products.validation.validators.SupplValidators import MaxSizeValidator
from Products.validation import V_REQUIRED

validation.register(MaxSizeValidator('checkImageMaxSize',
                                     maxsize=zconf.ATImage.max_file_size))

SlideshowItemSchema = link.ATLinkSchema.copy() + atapi.Schema((

    ImageField('image',
        required=True,
        storage=atapi.AnnotationStorage(),
        languageIndependent=True,
        max_size=zconf.ATNewsItem.max_image_dimension,
        sizes={'large': (768, 768),
               'preview': (400, 400),
              },
        validators=(('isNonEmptyFile', V_REQUIRED),
                    ('checkNewsImageMaxSize', V_REQUIRED)),
        widget=ImageWidget(
            description=_(u'help_slideshow_image',