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'))
class BankAccountStatement(MappingSchema): class Store(dict): def preview_url(self, name): return '' file = SchemaNode(FileData(), widget=FileUploadWidget(Store(), accept='text/xml'))
class FileSchema(ContentSchema): file = SchemaNode( FileData(), title=_(u'File'), widget=FileUploadWidget(tmpstore), validator=validate_file_size_limit, )
class FileSchema(ContentSchema): file = SchemaNode( FileData(), title=_(u'File'), missing=null, widget=FileUploadWidget(tmpstore), )
def set_mode(self): kwargs = {'key': self.name} return FileFields(self.title, self.name, self.round, widget=FileUploadWidget(self.tmpstore, **kwargs), mapinit=None, desc=self.desc)
def serialize(self, field, cstruct, **kw): if cstruct in (null, None): cstruct = {} kw['url'] = None if 'uid' not in cstruct and 'id' in cstruct: cstruct['uid'] = cstruct['id'] if cstruct['id'] != null and self.get_url: kw['url'] = self.get_url(self.request, cstruct['id']) return DeformFileUploadWidget.serialize(self, field, cstruct, **kw)
class AddBinarySchema(MappingSchema): binary = SchemaNode(FileData(), widget=FileUploadWidget(TmpStore()), validator=valid_binary_file) operatingsystem = SchemaNode(String(), widget=deferred_operating_system_widget, validator=deferred_operating_system_validator) architecture = SchemaNode(String(), widget=deferred_architecture_widget, validator=deferred_architecture_validator)
def serialize(self, field, cstruct, **kw): if cstruct in (null, None): cstruct = {} kw['url'] = None if 'uid' not in cstruct and self.id_field in cstruct: cstruct['uid'] = cstruct[self.id_field] if cstruct[self.id_field] != null and self.get_url: kw['url'] = self.get_url(self.request, cstruct[self.id_field]) if cstruct.get('filename', None) == null: cstruct['filename'] = "" return DeformFileUploadWidget.serialize(self, field, cstruct, **kw)
class FileSchema(MappingSchema): title = SchemaNode(String(), title=_(u'Title'), missing=u'') description = SchemaNode( String(), title=_('Description'), missing=u"", widget=TextAreaWidget(cols=40, rows=5), ) file = SchemaNode( FileData(), title=_(u'File'), widget=FileUploadWidget(tmpstore), )
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'', )
class SubmissionSchema(colander.MappingSchema): name = colander.SchemaNode(colander.String(), title=_("Full Name")) sender = colander.SchemaNode(colander.String(), validator=colander.Email(), title=_("E-Mail Address")) subject = colander.SchemaNode(colander.String(), title=_("Subject")) content = colander.SchemaNode(colander.String(), widget=TextAreaWidget(cols=40, rows=5), title=_("Your message")) attachment = colander.SchemaNode( FileData(), title=_('Attachment'), widget=FileUploadWidget(tmpstore), validator=file_size_limit, missing=None, ) _LOCALE_ = colander.SchemaNode(colander.String(), widget=HiddenWidget(), default=locale_name)
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'))
def deserialize(self, field, pstruct): value = DeformFileUploadWidget.deserialize(self, field, pstruct) if value != null and 'fp' in value: value['data'] = value['fp'] return value
def __init__(self, tmpstore, get_url=None, **kw): DeformFileUploadWidget.__init__(self, tmpstore, **kw) self.get_url = get_url
def __init__(self, tmpstore, **kw): FileUploadWidget.__init__(self, **kw) self.tmpstore = tmpstore
def __init__(self, **kw): if 'tmpstore' not in kw: kw['tmpstore'] = MemoryTmpStore() FileUploadWidget.__init__(self, **kw)
class Schema(colander.MappingSchema): file = colander.SchemaNode(FileData(), widget=FileUploadWidget(store))
def __init__(self, **kw): FileUploadWidget.__init__(self, None, **kw) self.tmpstore = tmpstore self.thumb_size = kw.get('thumb_size')
class EditBinarySchema(MappingSchema): binary = SchemaNode(FileData(), widget=FileUploadWidget(TmpStore()), validator=valid_binary_file)
import colander from storage.schemas import FileData from deform.widget import (TextInputWidget, TextAreaWidget, HiddenWidget, FileUploadWidget) class MemoryFileUploadTempStore(dict): def preview_url(self, uuid): return None tmpstore = MemoryFileUploadTempStore() input_widget = TextInputWidget(css_class='form-control') text_widget = TextAreaWidget(css_class='form-control body-field') file_widget = FileUploadWidget(tmpstore, css_class='form-control') class BlogCreateSchema(colander.Schema): title = colander.SchemaNode(colander.String(), title='Title', widget=input_widget) slug = colander.SchemaNode(colander.String(), missing=None, title='Slug', widget=input_widget) body = colander.SchemaNode(colander.String(), title='Body', widget=text_widget) image = colander.SchemaNode(FileData(upload_to='blog/'), missing='', title='Image',
class AddSourceSchema(MappingSchema): source = SchemaNode(FileData(), widget=FileUploadWidget(TmpStore()), validator=valid_source_file)
def serialize(self, field, cstruct, **kw): if cstruct in (null, None): cstruct = {} if 'id' in cstruct: cstruct['uid'] = cstruct['id'] return DeformFileUploadWidget.serialize(self, field, cstruct, **kw)
def __init__(self,**kw): FileUploadWidget.__init__(self, None, **kw) self.tmpstore = DummyTempStore()