Ejemplo n.º 1
0
class ActiveDirectoryVariableSpecific(colander.MappingSchema):
    sssd_conf = colander.SchemaNode(deform.FileData(),
                                    widget=FileUploadWidget(filestore),
                                    title=_('SSSD conf'))
    krb5_conf = colander.SchemaNode(deform.FileData(),
                                    widget=FileUploadWidget(filestore),
                                    title=_('KRB5 conf'))
    smb_conf = colander.SchemaNode(deform.FileData(),
                                   widget=FileUploadWidget(filestore),
                                   title=_('SMB conf'))
    pam_conf = colander.SchemaNode(deform.FileData(),
                                   widget=FileUploadWidget(filestore),
                                   title=_('PAM conf'))
Ejemplo n.º 2
0
class FileUploadSchema(colander.Schema):
    parent_id = colander.SchemaNode(
        colander.Integer(),
        widget=deform.widget.HiddenWidget(),
        missing=colander.drop,
    )

    come_from = forms.come_from_node()

    filetype = colander.SchemaNode(
        colander.String(),
        widget=deferred_filetype_select,
        missing="",
        title=u"Type de fichier",
    )

    description = colander.SchemaNode(colander.String())

    upload = colander.SchemaNode(
        deform.FileData(),
        widget=deferred_upload_widget,
        title=u"Choix du fichier",
        description=file_description,
        validator=filesize_validator,
    )
Ejemplo n.º 3
0
class AddImageSchema(colander.Schema):
    name = colander.SchemaNode(
        colander.String(),
        title='Image Name',
    )
    upload = colander.SchemaNode(
        deform.FileData(), widget=deform.widget.FileUploadWidget(tmpstore))
Ejemplo n.º 4
0
    def _colander_schema(self, instance, value):
        class MemoryTmpStore(dict):
            def __getitem__(self, name):
                return self.get(name)

            def get(self, name):
                item = super(MemoryTmpStore, self).get(name)

                if item is not None and item['fp'] is not None:
                    if not item['fp'].read(100):
                        item['fp'] = None
                    else:
                        item['fp'].seek(0)

                return item

            def preview_url(self, name):
                return None

        tmpstore = MemoryTmpStore()

        kwargs = {
            'widget': deform.widget.FileUploadWidget(tmpstore),
            'name': self.name
        }
        if not self.required:
            kwargs.update({'missing': None})

        return colander.SchemaNode(deform.FileData(), **kwargs)
Ejemplo n.º 5
0
class SiteConfig(colander.MappingSchema):
    """
        Site configuration
        logos ...
    """
    logo = colander.SchemaNode(
        deform.FileData(),
        widget=files.deferred_upload_widget,
        title=u"Choisir un logo",
        validator=validate_image_mime,
        missing=colander.drop,
        description=u"Charger un fichier de type image *.png *.jpeg \
*.jpg ...")
    welcome = forms.textarea_node(
        title=u"Texte d'accueil",
        richwidget=True,
        missing=u'',
        admin=True,
    )
    cae_admin_mail = colander.SchemaNode(
        colander.String(),
        title=CONFIGURATION_KEYS['cae_admin_mail']['title'],
        description=CONFIGURATION_KEYS['cae_admin_mail']['description'],
        validator=forms.mail_validator(),
        missing=u"")
Ejemplo n.º 6
0
 class FileUpload(colander.Schema):
     upload = colander.SchemaNode(
         deform.FileData(),
         missing=colander.drop,
         widget=deform.widget.FileUploadWidget(tempstore),
         oid="file-upload",
     )
Ejemplo n.º 7
0
        class ExampleSchema(colander.Schema):

            tmpstore = FileUploadTempStore()
            upload = colander.SchemaNode(
                deform.FileData(),
                title='Upload',
                widget=deform.widget.FileUploadWidget(tmpstore)
                )
Ejemplo n.º 8
0
class ImportForm(colander.MappingSchema):

    url = colander.SchemaNode(colander.String())
    content = colander.SchemaNode(colander.String(),
                                  widget=deform.widget.TextAreaWidget(),
                                  missing=None)
    upload = colander.SchemaNode(deform.FileData(),
                                 widget=get_file_upload_widget,
                                 missing=None)
Ejemplo n.º 9
0
class AddFileSchema(BaseSchema, DCMetadataSchema):
    title = colander.SchemaNode(
        colander.String(),
        title=_("Titile"),
        description=_("Filename will be used if you leave this blank"),
        missing=u"")
    file_data = colander.SchemaNode(deform.FileData(),
                                    title=_(u"Upload file"),
                                    blob_key=default_blob_key,
                                    widget=FileAttachmentWidget())
Ejemplo n.º 10
0
class Record(colander.MappingSchema):
    bhajan = colander.SchemaNode(
        colander.String(),
        widget=deform.widget.SelectWidget(values=Choices(bhajan_ch)),
        title=u'Баджана')
    artist = colander.SchemaNode(colander.String(),
                                 validator=colander.Length(1, 100),
                                 title=u'Исполнитель')
    audio = colander.SchemaNode(deform.FileData(),
                                widget=GaeFileUploadWidget(
                                    GaeUploadTempStore()),
                                title=u'Аудио файл')
Ejemplo n.º 11
0
class CarrierExtraSettings(colander.MappingSchema):
    carrier_image = colander.SchemaNode(deform.FileData(),
                                        widget=widget.FileUploadWidget(tmpstore=tmpstore),
                                        title='Carrier Image',
                                        description="Choose file to upload",
                                        missing=colander.null)
    carrier_motd = colander.SchemaNode(colander.String(),
                                       widget=widget.TextInputWidget(),
                                       description="Set your carrier's Motto / MOTD.",
                                       title="Carrier Motto",
                                       validator=colander.Length(max=150),
                                       missing=colander.null)
Ejemplo n.º 12
0
 class TableFileSchema(ContentSchema):
     file = colander.SchemaNode(
         deform.FileData(),
         title=_(u'File'),
         missing=colander.null,
         widget=deform.widget.FileUploadWidget(tmpstore),
         #validator=validate_file_size_limit,
     )
     table_name = colander.SchemaNode(
         colander.String(),
         title=_(u"Table Name"),
         validator=validate_name,
     )
Ejemplo n.º 13
0
 class Sample(colander.MappingSchema):
     setup_schema(None, spectra)
     spectraSchema = spectra.__colanderalchemy__
     type = colander.SchemaNode(
         colander.String(),
         default='',
         widget=deform.widget.SelectWidget(values=type_choices))
     format = colander.SchemaNode(
         colander.String(),
         default='',
         widget=deform.widget.SelectWidget(values=format_choices))
     sample_power_spectrum = colander.SchemaNode(
         deform.FileData(), widget=deform.widget.FileUploadWidget(tmpstore))
     background_power_spectrum = colander.SchemaNode(
         deform.FileData(), widget=deform.widget.FileUploadWidget(tmpstore))
     initial_result_spectrum = colander.SchemaNode(
         deform.FileData(), widget=deform.widget.FileUploadWidget(tmpstore))
     final_spectrum = colander.SchemaNode(
         deform.FileData(), widget=deform.widget.FileUploadWidget(tmpstore))
     setup_schema(None, post_processing_and_deposited_spectra)
     ppSchema = post_processing_and_deposited_spectra.__colanderalchemy__
     upload = colander.SchemaNode(
         deform.FileData(), widget=deform.widget.FileUploadWidget(tmpstore))
Ejemplo n.º 14
0
def get_file_dl_node(title, additionnal_description=""):
    """
    Return a file download node
    """
    description = u"Charger un fichier de type image *.png *.jpeg *.jpg ... \
{0}".format(additionnal_description)

    return colander.SchemaNode(
        deform.FileData(),
        widget=files.deferred_upload_widget,
        title=title,
        validator=validate_image_mime,
        missing=colander.drop,
        description=description,
    )
Ejemplo n.º 15
0
class BannerSchema(CSRFSchema):
    title = colander.SchemaNode(colander.String())
    image = colander.SchemaNode(
            deform.FileData(),
            widget=deform.widget.FileUploadWidget(tmpstore),
            validator=image_validator,
            missing=None
            )

    url = colander.SchemaNode(colander.String(), validator=url_validator)
    visible = colander.SchemaNode(
            colander.Boolean(),
            widget=deform.widget.CheckboxWidget(),
            default=True
            )
Ejemplo n.º 16
0
class UserSchema(colander.Schema):
    first_name = colander.SchemaNode(colander.String(),
                                     title=_(u"First name"),
                                     missing=u"")
    last_name = colander.SchemaNode(colander.String(),
                                    title=_(u"Last name"),
                                    missing=u"")
    email = colander.SchemaNode(colander.String(),
                                title=_(u"Email adress"),
                                validator=colander.Email())
    image_data = colander.SchemaNode(deform.FileData(),
                                     missing=colander.null,
                                     blob_key='image',
                                     title=_(u"Profile image"),
                                     validator=supported_thumbnail_mimetype,
                                     widget=FileAttachmentWidget())
Ejemplo n.º 17
0
def upload_form(context: ModelUI, request: morepath.Request) -> deform.Form:
    fields = {}
    model = context.model
    for f in model.blob_fields:
        fields[f] = colander.SchemaNode(
            deform.FileData(),
            missing=colander.drop,
            widget=deform.widget.FileUploadWidget(
                FSBlobFileUploadTempStore(f, context, request,
                                          "/tmp/tempstore")),
            oid="file-upload-%s" % f,
        )

    FileUpload = type("FileUpload", (colander.Schema, ), fields)
    fs = FileUpload()
    return deform.Form(fs, buttons=("Upload", ), formid="upload-form")
Ejemplo n.º 18
0
    def get_schema_node(self):
        kw = self._get_schema_node_args(defaul=False)
        f = self.field
        if not f.required:
            kw['missing'] = c.null

        def image_validation(node, val):
            mimetype = val['mimetype']
            size = val['size']
            configured = f.get_option('mimeTypes').split('|')
            for allowed in [m for m in mt.mimetypes]:
                if allowed['desc'] in configured and mimetype in allowed['py']:
                    return
            raise c.Invalid(node, _("Invalid image format"))

        kw['validator'] = image_validation
        return c.SchemaNode(d.FileData(), **kw)
Ejemplo n.º 19
0
class BaseOrgSchema(colander.Schema):
    title = colander.SchemaNode(colander.String(), title=_("Title"))
    description = colander.SchemaNode(
        colander.String(),
        title=_("Description"),
        widget=deform.widget.TextAreaWidget(rows=3),
        missing=u"")
    tags = colander.SchemaNode(colander.List(),
                               title=_("Tags or subjects"),
                               missing="",
                               widget=tagging_widget)
    image_data = colander.SchemaNode(deform.FileData(),
                                     missing=None,
                                     title=_(u"Image"),
                                     blob_key='image',
                                     validator=supported_thumbnail_mimetype,
                                     widget=FileAttachmentWidget())
Ejemplo n.º 20
0
class DocumentSchema(BaseSchema, DCMetadataSchema):
    body = colander.SchemaNode(colander.String(),
                               widget=deform.widget.RichTextWidget(),
                               missing=u"")
    image_data = colander.SchemaNode(deform.FileData(),
                                     missing=None,
                                     title=_(u"Image"),
                                     blob_key='image',
                                     validator=supported_thumbnail_mimetype,
                                     widget=FileAttachmentWidget())
    show_byline = colander.SchemaNode(
        colander.Bool(),
        default=True,
        tab=tabs['visibility'],
        title=_(u"Show byline"),
        description=
        u"If anything exist that will render a byline, like the Byline portlet.",
    )
Ejemplo n.º 21
0
 def colander_literal_type(self, data_input):
     # LOGGER.debug('data input type = %s', data_input.dataType)
     if 'boolean' in data_input.dataType:
         return colander.Boolean()
     elif 'integer' in data_input.dataType:
         return colander.Integer()
     elif 'float' in data_input.dataType:
         return colander.Float()
     elif 'double' in data_input.dataType:
         return colander.Float()
     elif 'angle' in data_input.dataType:
         return colander.Float()
     elif 'decimal' in data_input.dataType:
         return colander.Decimal()
     elif 'string' in data_input.dataType:
         if data_input.maxOccurs > 1:
             # we are going to use a SelectWidget with multiple=True
             return colander.Set()
         elif data_input.identifier.endswith("FileUpload"):
             # we want to upload a file but just return a string containing
             # the path
             return deform.FileData()
         else:
             return colander.String()
     elif 'dateTime' in data_input.dataType:
         return colander.DateTime()
     elif 'date' in data_input.dataType:
         return colander.Date()
     elif 'time' in data_input.dataType:
         return colander.Time()
     elif 'duration' in data_input.dataType:
         # TODO: check correct type
         # http://www.w3.org/TR/xmlschema-2/#duration
         return colander.Time()
     # guessing from default
     elif hasattr(data_input, 'defaultValue'):
         try:
             dateutil.parser.parse(data_input.defaultValue)
         except Exception:
             return colander.String()
         else:
             return colander.DateTime()
     else:
         return colander.String()
Ejemplo n.º 22
0
    def get_schema_node(self):
        kw = self._get_schema_node_args(defaul=False)
        if not self.field.required:
            kw['missing'] = c.null

        def file_validation(node, val):
            mimetype = val['mimetype']
            size = val['size']

            is_mimetype_allowed = False
            for allowed in mt.mimetypes:
                if mimetype == allowed['py']:
                    is_mimetype_allowed = True

            if not is_mimetype_allowed:
                raise c.Invalid(node, _("Invalid file format"))

        kw['validator'] = file_validation
        return c.SchemaNode(d.FileData(), **kw)
Ejemplo n.º 23
0
class BannerSchema(colander.MappingSchema):
    title_name = colander.SchemaNode(
        colander.String(),
        title="Banner Name",
    )
    position = colander.SchemaNode(
        colander.Integer(strict=True),
        widget=deform.widget.TextInputWidget(attributes={
            'type': 'number',
            'length': 8
        }),
        title='Display position',
        missing=colander.null)
    status = colander.SchemaNode(colander.Boolean(),
                                 widget=deform.widget.CheckboxWidget(),
                                 title='Add to carusel')
    image_file = colander.SchemaNode(
        deform.FileData(),
        widget=deform.widget.FileUploadWidget(store),
        title='Upload')
Ejemplo n.º 24
0
class CsvFileUploadSchema(colander.Schema):
    """
    Csv import first step schema
    """
    csv_file = colander.SchemaNode(
        deform.FileData(),
        widget=deferred_temporary_upload_widget,
        title=u"Fichier csv",
        description=u"Fichier csv contenant les données à importer (delimiter: \
';' quotechar: '\"'), le fichier doit être enregistré au format utf-8",
        validator=check_csv_content,
    )
    model_type = colander.SchemaNode(
        colander.String(),
        widget=deferred_model_type_widget,
        title=u"Type de données",
    )
    association = colander.SchemaNode(
        colander.String(),
        widget=deferred_preferences,
        title=u"Type de fichiers",
        description=u"Permet de pré-charger automatiquement des associations \
de champs pour l'étape 2",
        missing=colander.drop)
    delimiter = colander.SchemaNode(
        colander.String(),
        title=u"Caractère utilisé pour délimiter les champs du fichier",
        widget=deform.widget.SelectWidget(values=zip(csv_import.DELIMITERS,
                                                     csv_import.DELIMITERS), ),
        default=csv_import.DEFAULT_DELIMITER,
        missing=csv_import.DEFAULT_DELIMITER,
    )
    quotechar = colander.SchemaNode(
        colander.String(),
        title=u"Caractère utilisé pour délimiter les chaînes de caractères",
        widget=deform.widget.SelectWidget(values=zip(csv_import.QUOTECHARS,
                                                     csv_import.QUOTECHARS), ),
        default=csv_import.DEFAULT_QUOTECHAR,
        missing=csv_import.DEFAULT_QUOTECHAR,
    )
Ejemplo n.º 25
0
class UpdateModel(colander.MappingSchema):
    '''
    Schema for representing an update in form 
    '''
    local_file = colander.SchemaNode(deform.FileData(),
                                     widget=FileUploadWidget(filestore),
                                     preparer=unzip_preparer,
                                     validator = colander.All(
                                         UpdateNamingValidator(), 
                                         UpdateSequenceValidator(),
                                         UpdateFileStructureValidator(), 
                                         UpdateControlFileValidator(),
                                         UpdateScriptRangeValidator()),
                                     missing=colander.null,
                                     title=_('Update ZIP'))
    remote_file = colander.SchemaNode(UrlFile(),
                                      preparer=unzip_preparer,
                                      validator = colander.All(
                                          UpdateNamingValidator(), 
                                          UpdateSequenceValidator(),
                                          UpdateFileStructureValidator(), 
                                          UpdateControlFileValidator()),
                                      missing=colander.null,
                                      title=_('URL download'))
Ejemplo n.º 26
0
 class Schema(colander.Schema):
     upload = colander.SchemaNode(
         deform.FileData(), widget=deform.widget.FileUploadWidget(tmpstore))
Ejemplo n.º 27
0
class EditFileSchema(AddFileSchema, DCMetadataSchema):
    file_data = colander.SchemaNode(deform.FileData(),
                                    title=_(u"Change file"),
                                    missing=colander.null,
                                    blob_key=default_blob_key,
                                    widget=FileAttachmentWidget())
Ejemplo n.º 28
0
class RestoreUploadFormSchema(colander.MappingSchema):
    file = colander.SchemaNode(deform.FileData(),
                               widget=deform.widget.FileUploadWidget(tmpstore),
                               title='Backup data to restore')
Ejemplo n.º 29
0
class UploadSchema(Schema):
    # title = SchemaNode(String())
    upload = SchemaNode(
        deform.FileData(),
        widget=deform.widget.FileUploadWidget(tmpstore)
    )
Ejemplo n.º 30
0
 class Schema(colander.Schema):
     file = colander.SchemaNode(
         deform.FileData(),
         widget=deform.widget.FileUploadWidget(tmpStore),
         name='file',
         title='File')