def is_wrong_type(self, upload):
        if not upload:
            return _(u"label_required", default=u"Required field")

        else:
            _root, extension = os.path.splitext(upload.filename)
            if extension.lower() not in self.allowed_extensions:
                return _(
                    u"label_notallowedtype",
                    default=u"Not allowed type (${types})",
                    mapping={u"types": ", ".join(self.allowed_extensions)},
                )

        return False
 def description(self):
     types = self.allowed_extensions
     types.sort()
     return translate(
         _(u"help_simple_upload", default=u"Allowed types are: ${types}", mapping={"types": ", ".join(types)}),
         context=self.request,
     )
Beispiel #3
0
    def __call__(self, value, *args, **kwargs):
        instance = kwargs.get('instance', None)

        conditions = bool(instance.getConditions())
        if conditions and not value:
            return translate(_('Please accept the conditions.'),
                             context=instance.REQUEST)
Beispiel #4
0
 def __call__(self, value, *args, **kwargs):
     phone = re.compile('^(0|\+|00)[\d \'-/]{6,}$')
     if not phone.match(value):
         msg = _(
             "Validation failed($name: no valid phone number)",
             mapping={
                 'name': safe_unicode(self.name),
             },
         )
         return msg
     return True
Beispiel #5
0
 def __call__(self, value, *args, **kwargs):
     mail = re.compile("^(\w&.%#$&'\*+-/=?^_`{}|~]+!)*[\w&.%#$&'\*+-/=" +
                       "?^_`{}|~]+@(([0-9a-z]([0-9a-z-]*[0-9a-z])?" +
                       "\.)+[a-z]{2,6}|([0-9]{1,3}\.){3}[0-9]{1,3})$")
     if not mail.match(value):
         msg = _(
             "Validation failed($name: no valid email)",
             mapping={
                 'name': safe_unicode(self.name),
             },
         )
         return recursiveTranslate(msg)
     return True
Beispiel #6
0
 def title(self):
     return _(
         u'label_billboardactions',
         default=u'Billboard Actions portlet')
Beispiel #7
0
validation.register(ConditionsValidator('acceptConditions'))


BillboardAdSchema = folder.ATFolderSchema.copy() + atapi.Schema((
    atapi.TextField(
        name='text',
        searchable=True,
        required=False,
        allowable_content_types=('text/html',),
        default_content_type='text/html',
        validators=('isTidyHtmlWithCleanup',),
        default_output_type='text/x-html-safe',
        default_input_type='text/html',
        storage=atapi.AnnotationStorage(),
        widget=atapi.RichWidget(
            label=_(u"label_description", default=u"Description"),
            rows=15,
            allow_file_upload=False,
            allow_buttons=TINYMCE_ALLOWED_BUTTONS,
        ),
    ),

    atapi.FixedPointField(
        name='price',
        schemata='default',
        required=False,
        widget=atapi.DecimalWidget(
            label=_(u'label_price', default='price'),
            description=_(u'help_price', default='Leave blank '),
        ),
    ),
                                     maxsize=zconf.ATImage.max_file_size))


BillboardCategorySchema = folder.ATFolderSchema.copy() + atapi.Schema((
    atapi.TextField(
        name='conditions',
        searchable=True,
        required=False,
        allowable_content_types=('text/html',),
        default_content_type='text/html',
        validators=('isTidyHtmlWithCleanup',),
        default_output_type='text/x-html-safe',
        default_input_type='text/html',
        storage=atapi.AnnotationStorage(),
        widget=atapi.RichWidget(
            label=_(u"label_conditions", default=u"Billboard conditions"),
            rows=15,
            allow_file_upload=False,
            allow_buttons=TINYMCE_ALLOWED_BUTTONS,
        ),
    ),

    atapi.ImageField(
        name='image',
        required=False,
        primary=True,
        languageIndependent=True,
        storage=atapi.AnnotationStorage(),
        swallowResizeExceptions=zconf.swallowImageResizeExceptions.enable,
        pil_quality=zconf.pil_config.quality,
        pil_resize_algo=zconf.pil_config.resize_algo,