Example #1
0
 class BannerBoxSchema(ContentSchema):
     file = colander.SchemaNode(
         FileData(),
         title=_(u'File'),
         widget=FileUploadWidget(tmpstore),
         validator=validate_file_size_limit,
     )
     link = colander.SchemaNode(
         colander.String(),
         title=_('Link'),
         validator=link_validator,
         missing=u'',
     )
Example #2
0
class BannerBoxAddForm(ImageAddForm):
    item_type = _(u"Banner Box")
    item_class = BannerBox

    def schema_factory(self):
        tmpstore = FileUploadTempStore(self.request)
        return BannerBoxSchema(tmpstore)

    def save_success(self, appstruct):
        # overried this method (no filename as title
        # like images)
        return AddFormView.save_success(self, appstruct)

    def add(self, **appstruct):
        # override (no tags in our form)
        buf = appstruct['file']['fp'].read()
        filename = appstruct['file']['filename']
        return self.item_class(
            title=appstruct['title'] or filename,
            description=appstruct['description'],
            data=buf,
            filename=filename,
            link=appstruct.get('link', u''),
            mimetype=appstruct['file']['mimetype'],
            size=len(buf),
        )
Example #3
0
class LeftBoxManagerAddForm(AddFormView):
    """ Form to add a new instance of BoxManager. """

    schema_factory = LeftBoxManagerSchema
    add = LeftBoxManager
    item_type = _(u"LeftBoxManager")
Example #4
0
 def after_bind(self, node, kw):
     super(BelowContentBoxManagerSchema, self).after_bind(node, kw)
     node['title'].default = _('BelowContentBoxManager')
Example #5
0
 def after_bind(self, node, kw):
     super(AboveFooterBoxManagerSchema, self).after_bind(node, kw)
     node['title'].default = _('AboveFooterBoxManager')
Example #6
0
 def after_bind(self, node, kw):
     super(LeftBoxManagerSchema, self).after_bind(node, kw)
     node['title'].default = _('LeftBoxManager')
Example #7
0
class BelowContentBoxManagerAddForm(AddFormView):
    """ Form to add a new instance of BoxManager. """

    schema_factory = BelowContentBoxManagerSchema
    add = BelowContentBoxManager
    item_type = _(u"BelowContentBoxManager")
Example #8
0
class AboveFooterBoxManagerAddForm(AddFormView):
    """ Form to add a new instance of BoxManager. """

    schema_factory = AboveFooterBoxManagerSchema
    add = AboveFooterBoxManager
    item_type = _(u"AboveFooterBoxManager")
Example #9
0
 def raise_invalid_url(node, value):
     raise colander.Invalid(node, _(u"You must provide a valid url."))