Ejemplo n.º 1
0
Archivo: file.py Proyecto: dnouri/Kotti
 class FileSchema(ContentSchema):
     file = SchemaNode(
         FileData(),
         title=_(u'File'),
         missing=null,
         widget=FileUploadWidget(tmpstore),
         )
Ejemplo n.º 2
0
 class FileSchema(ContentSchema):
     file = SchemaNode(
         FileData(),
         title=_(u'File'),
         widget=FileUploadWidget(tmpstore),
         validator=validate_file_size_limit,
     )
Ejemplo n.º 3
0
class BankAccountStatement(MappingSchema):
    class Store(dict):
        def preview_url(self, name):
            return ''

    file = SchemaNode(FileData(),
                      widget=FileUploadWidget(Store(), accept='text/xml'))
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
Archivo: file.py Proyecto: dnouri/Kotti
 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),
         )
Ejemplo n.º 6
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'',
     )
Ejemplo n.º 7
0
class PDFUploadSchema(colander.Schema):
    """ use colander to define a data validation schema for linkage with
    a deform object.
    """
    csn = colander.SchemaNode

    serial = csn(colander.String(), validator=colander.Length(3, 50))

    # Based on: # http://stackoverflow.com/questions/6563546/\
    # how-to-make-file-upload-facultative-with-deform-and-colander
    # Various demos delete this temporary file on succesful submission
    pdf_tmp_store = MemoryTmpStore()
    fuw = widget.FileUploadWidget(pdf_tmp_store)
    pdf_upload = csn(FileData(), widget=fuw)
Ejemplo n.º 8
0
class StickerSchema(colander.Schema):
    """ use colander to define a data validation schema for linkage with
    a deform object.
    """
    serial = colander.SchemaNode(colander.String(),
                                 validator=colander.Length(3, 15))

    domain = colander.SchemaNode(colander.String(),
                                 validator=colander.url,
                                 default="http://waspho.com")

    # Based on: # http://stackoverflow.com/questions/6563546/\
    # how-to-make-file-upload-facultative-with-deform-and-colander
    # Various demos delete this temporary file on succesful submission
    tmpstore = MemoryTmpStore()
    fuw = widget.FileUploadWidget(tmpstore)
    upload = colander.SchemaNode(FileData(), 
                                 missing=colander.null,
                                 widget=fuw)
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
class CompanySchema(colander.MappingSchema):
    """
        Company add/edit form schema
    """
    user_id = forms.id_node()
    name = colander.SchemaNode(colander.String(),
                               widget=deferred_edit_adminonly_widget,
                               title=u'Nom')

    goal = colander.SchemaNode(colander.String(),
                               title=u"Descriptif de l'activité")

    activities = CompanyActivitySchema(
        title=u"Domaines d'activité",
        missing=colander.drop,
    )

    email = forms.mail_node(missing=u'')

    phone = colander.SchemaNode(colander.String(),
                                title=u'Téléphone',
                                missing=u'')

    mobile = colander.SchemaNode(colander.String(),
                                 title=u'Téléphone portable',
                                 missing=u'')

    logo = colander.SchemaNode(
        FileData(),
        widget=files.deferred_upload_widget,
        title="Choisir un logo",
        validator=validate_image_mime,
        missing=colander.drop,
        description=u"Charger un fichier de type image *.png *.jpeg \
*.jpg ...")

    header = colander.SchemaNode(
        FileData(),
        widget=deferred_upload_header_widget,
        title=u'Entête des fichiers PDF',
        validator=validate_image_mime,
        missing=colander.drop,
        description=u"Charger un fichier de type image *.png *.jpeg \
*.jpg ... Le fichier est idéalement au format 20/4 (par exemple 1000px x \
200 px)",
    )

    # Fields specific to the treasury
    code_compta = colander.SchemaNode(
        colander.String(),
        title=u"Compte analytique",
        description=u"Compte analytique utilisé dans le logiciel de \
comptabilité",
        missing="")

    contribution = colander.SchemaNode(
        colander.Integer(),
        widget=deform.widget.TextInputWidget(input_append="%",
                                             css_class="col-md-1"),
        validator=colander.Range(
            min=0,
            max=100,
            min_err=u"Veuillez fournir un nombre supérieur à 0",
            max_err=u"Veuillez fournir un nombre inférieur à 100"),
        title=u"Contribution à la CAE",
        missing=colander.drop,
        description=u"Pourcentage que cette entreprise contribue à la CAE",
    )

    cgv = forms.textarea_node(
        title=u"Conditions générales complémentaires",
        richwidget=True,
        missing="",
    )

    RIB = colander.SchemaNode(colander.String(), title=u'RIB', missing=u'')

    IBAN = colander.SchemaNode(colander.String(), title=u'IBAN', missing=u'')
Ejemplo n.º 11
0
                                      widget=widget.CheckboxChoiceWidget(values=looking_fors))

    traits = []
    likes = []
    aboutme = colander.SchemaNode(
                colander.String(),
                validator=colander.Length(max=500),
                widget=widget.TextAreaWidget(rows=10, cols=40),
                description='Enter some text')

class EditPictureSchema(colander.MappingSchema):
	"""
	Picture edit schema
	"""
    image = colander.SchemaNode(
                FileData(),
                widget=widget.FileUploadWidget(tmpstore))

class MessageSchema(colander.MappingSchema):
	"""Messaging schema
	"""
    message = colander.SchemaNode(colander.String(),
                                  widget=widget.TextAreaWidget(rows=10, cols=40))

									  
"""Views"""

@view_config(route_name='root', renderer='templates/userhome.pt')
def root(request):
	"""The home page if you are logged in, this route shows a particular user,
	    or returns not found if that user doesn't exist
Ejemplo n.º 12
0
class AddSchema(colander.Schema):
    upload = colander.SchemaNode(
                FileData(),
                widget=widget.FileUploadWidget(tmpstore),
                title='Unggah')
Ejemplo n.º 13
0
class EditBinarySchema(MappingSchema):
    binary = SchemaNode(FileData(),
                        widget=FileUploadWidget(TmpStore()),
                        validator=valid_binary_file)
Ejemplo n.º 14
0
class AddSourceSchema(MappingSchema):
    source = SchemaNode(FileData(),
                        widget=FileUploadWidget(TmpStore()),
                        validator=valid_source_file)
Ejemplo n.º 15
0
    def __init__(self,
                 title,
                 name,
                 round=1,
                 missing=None,
                 widget=None,
                 mapinit=None,
                 desc=None,
                 table_reduce=False,
                 rank=0,
                 required=False,
                 missing_msg='champ requis',
                 primary_key=False):

        # Form display
        self.title = title
        self.name = name
        self.required = required
        self.missing_msg = missing_msg
        self.type = str
        self.desc = desc
        self.tmpstore = FileUploadTempStore(dict())
        self.widget = widget
        self.round = round
        self.mapinit = {
            'filename': None,
            'fp': None,
            'mimetype': None,
            'preview_url': None,
            'size': None,
            'uid': None
        }

        # Table display
        self.table_reduce, self.rank, = table_reduce, rank

        # Db column
        self.dbcol_ = (name, Colsql(Strsql(250), primary_key=primary_key))

        if mapinit is not None:
            self.mapinit.update(mapinit)

        if missing is None:
            missing = {'filename': '', 'uid': ''}

        self.processing_form = {
            'form': lambda x: x,
            'db': lambda x: {
                'filename': x
            }
        }
        self.processing_db = {
            'upload': lambda x: x.get('filename', ''),
            'download': lambda x: x
        }

        self.sn = sn(FileData(),
                     title=self.title,
                     name=name,
                     widget=self.widget,
                     description=desc,
                     required=self.required,
                     missing_msg=self.missing_msg)

        if not required:
            self.sn.missing = missing