How to use the spam.lib.widgets.RestForm function in spam

To help you get started, we’ve selected a few spam examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lento / spam / spam / lib / widgets.py View on Github external
"""Base class for forms that submit data to a custom REST method via the
    ``_method`` parameter
    """
    custom_method = twc.Param('The custom REST method to use for submitting '
        'the form', default='POST')
    custom_method_field = twf.IgnoredField(name='_method')
    submit = SubmitWithFeedback(id='submit', value='Submit')

    def prepare(self):
        if not self.child.children.custom_method_field.value:
            self.child.children.custom_method_field.value = self.custom_method
        super(RestForm, self).prepare()


# User
class FormUserNew(RestForm):
    """New user form."""
    user_name = twf.TextField(validator=StringLength(max=16, required=True))
    display_name = twf.TextField(validator=StringLength(max=255, required=True))
    password = twf.PasswordField(validator=StringLength(max=80, required=True))


class FormUserEdit(RestForm):
    """Edit user form."""
    custom_method = 'PUT'
    user_id = twf.HiddenField()
    user_name_ = twf.LabelField()
    display_name = twf.TextField(validator=StringLength(max=255, required=True))


class FormUserConfirm(RestForm):
    """Generic user confirmation form."""
github lento / spam / spam / lib / widgets.py View on Github external
"""New note form."""
    proj = twf.HiddenField()
    annotable_id = twf.HiddenField()
    text = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS,
                                                        validator=twc.Required)
        

class FormNoteConfirm(RestForm):
    """Generic note confirmation form."""
    proj = twf.HiddenField()
    note_id = twf.HiddenField()
    text_ = twf.LabelField()


# Project
class FormProjectNew(RestForm):
    """New project form."""
    proj = twf.TextField(label='id', validator=twc.All(StringLength(max=15),
                    twc.RegexValidator(regex=G.pattern_name), required=True))
    project_name = twf.TextField(label='Name', validator=StringLength(max=40))
    description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)


class FormProjectEdit(RestForm):
    """Edit project form."""
    custom_method = 'PUT'
    proj = twf.HiddenField()
    id_ = twf.LabelField()
    project_name = twf.TextField(label='Name', validator=StringLength(max=40))
    description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
github lento / spam / spam / lib / widgets.py View on Github external
proj = twf.TextField(label='id', validator=twc.All(StringLength(max=15),
                    twc.RegexValidator(regex=G.pattern_name), required=True))
    project_name = twf.TextField(label='Name', validator=StringLength(max=40))
    description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)


class FormProjectEdit(RestForm):
    """Edit project form."""
    custom_method = 'PUT'
    proj = twf.HiddenField()
    id_ = twf.LabelField()
    project_name = twf.TextField(label='Name', validator=StringLength(max=40))
    description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)


class FormProjectConfirm(RestForm):
    """Generic project confirmation form."""
    proj = twf.HiddenField()
    id_ = twf.LabelField()
    project_name_ = twf.LabelField(label='Name')
    description_ = twf.LabelField()


# Scene
class FormSceneNew(RestForm):
    """New scene form."""
    proj = twf.HiddenField()
    project_name_ = twf.LabelField()
    sc = twf.TextField(label='name', validator=twc.All(StringLength(max=15),
                    twc.RegexValidator(regex=G.pattern_name), required=True))
    description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
github lento / spam / spam / lib / widgets.py View on Github external
description_ = twf.LabelField()


# Libgroups
class FormLibgroupNew(RestForm):
    """New libgroup form."""
    proj = twf.HiddenField()
    parent_id = twf.HiddenField()
    project_name_ = twf.LabelField()
    parent_ = twf.LabelField()
    name = twf.TextField(validator=twc.All(StringLength(max=15),
                    twc.RegexValidator(regex=G.pattern_name), required=True))
    description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)


class FormLibgroupEdit(RestForm):
    """Edit libgroup form."""
    custom_method = 'PUT'
    proj = twf.HiddenField()
    libgroup_id = twf.HiddenField()
    project_name_ = twf.LabelField()
    libgroup_name_ = twf.LabelField(label='Name')
    description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)


class FormLibgroupConfirm(RestForm):
    """Generic libgroup confirmation form."""
    proj = twf.HiddenField()
    libgroup_id = twf.HiddenField()
    project_name_ = twf.LabelField()
    libgroup_name_ = twf.LabelField(label='Name')
    description_ = twf.LabelField()
github lento / spam / spam / lib / widgets.py View on Github external
"""Generic note confirmation form."""
    proj = twf.HiddenField()
    note_id = twf.HiddenField()
    text_ = twf.LabelField()


# Project
class FormProjectNew(RestForm):
    """New project form."""
    proj = twf.TextField(label='id', validator=twc.All(StringLength(max=15),
                    twc.RegexValidator(regex=G.pattern_name), required=True))
    project_name = twf.TextField(label='Name', validator=StringLength(max=40))
    description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)


class FormProjectEdit(RestForm):
    """Edit project form."""
    custom_method = 'PUT'
    proj = twf.HiddenField()
    id_ = twf.LabelField()
    project_name = twf.TextField(label='Name', validator=StringLength(max=40))
    description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)


class FormProjectConfirm(RestForm):
    """Generic project confirmation form."""
    proj = twf.HiddenField()
    id_ = twf.LabelField()
    project_name_ = twf.LabelField(label='Name')
    description_ = twf.LabelField()
github lento / spam / spam / lib / widgets.py View on Github external
"""Remove tag form."""
    custom_method = 'REMOVE'
    taggable_id = twf.HiddenField()
    tagids = twf.MultipleSelectField(label='Tags', options=[], size=SEL_SIZE)


# Note
class FormNoteNew(RestForm):
    """New note form."""
    proj = twf.HiddenField()
    annotable_id = twf.HiddenField()
    text = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS,
                                                        validator=twc.Required)
        

class FormNoteConfirm(RestForm):
    """Generic note confirmation form."""
    proj = twf.HiddenField()
    note_id = twf.HiddenField()
    text_ = twf.LabelField()


# Project
class FormProjectNew(RestForm):
    """New project form."""
    proj = twf.TextField(label='id', validator=twc.All(StringLength(max=15),
                    twc.RegexValidator(regex=G.pattern_name), required=True))
    project_name = twf.TextField(label='Name', validator=StringLength(max=40))
    description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)


class FormProjectEdit(RestForm):
github lento / spam / spam / lib / widgets.py View on Github external
proj = twf.HiddenField()
    asset_id = twf.HiddenField()
    uploaded = twf.HiddenField(validator=twc.ListLengthValidator(
                    min=1, max=MAX_UPLOAD_FILES,
                    msgs={'tooshort': ('list_tooshort',
                                       'Please choose the file(s) to upload'),
                          'toolong': ('list_toolong',
                                      'Too many files selected'),
                         },
                    required=True))
    uploader = Upload(label='File(s) to Upload')
    spacer = twf.Spacer()
    comment = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)


class FormAssetStatus(RestForm):
    """Asset status form."""
    proj = twf.HiddenField()
    asset_id = twf.HiddenField()
    project_name_ = twf.LabelField()
    container_ = twf.LabelField()
    category_id_ = twf.LabelField()
    asset_name_ = twf.LabelField(label='Name')
    comment = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
github lento / spam / spam / lib / widgets.py View on Github external
category_id = twf.HiddenField()
    id_ = twf.LabelField()
    ordering = twf.TextField(validator=twc.IntValidator)
    naming_convention = twf.TextField(validator=StringLength(max=255))


class FormCategoryConfirm(RestForm):
    """Generic category confirmation form."""
    category_id = twf.HiddenField()
    id_ = twf.LabelField()
    ordering_ = twf.LabelField()
    naming_convention_ = twf.LabelField()


# Tag
class FormTagNew(RestForm):
    """New tag form."""
    taggable_id = twf.HiddenField()
    current_tags_ = twf.LabelField()
    tagids = twf.MultipleSelectField(label='Tags', options=[], size=SEL_SIZE)
    new_tags = twf.TextField(validator=twc.RegexValidator(regex=G.pattern_tags))


class FormTagConfirm(RestForm):
    """Generic tag confirmation form."""
    tag_id = twf.HiddenField()


class FormTagRemove(RestForm):
    """Remove tag form."""
    custom_method = 'REMOVE'
    taggable_id = twf.HiddenField()
github lento / spam / spam / lib / widgets.py View on Github external
# Tag
class FormTagNew(RestForm):
    """New tag form."""
    taggable_id = twf.HiddenField()
    current_tags_ = twf.LabelField()
    tagids = twf.MultipleSelectField(label='Tags', options=[], size=SEL_SIZE)
    new_tags = twf.TextField(validator=twc.RegexValidator(regex=G.pattern_tags))


class FormTagConfirm(RestForm):
    """Generic tag confirmation form."""
    tag_id = twf.HiddenField()


class FormTagRemove(RestForm):
    """Remove tag form."""
    custom_method = 'REMOVE'
    taggable_id = twf.HiddenField()
    tagids = twf.MultipleSelectField(label='Tags', options=[], size=SEL_SIZE)


# Note
class FormNoteNew(RestForm):
    """New note form."""
    proj = twf.HiddenField()
    annotable_id = twf.HiddenField()
    text = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS,
                                                        validator=twc.Required)
        

class FormNoteConfirm(RestForm):
github lento / spam / spam / lib / widgets.py View on Github external
category_id = twf.HiddenField()
    id_ = twf.LabelField()
    ordering_ = twf.LabelField()
    naming_convention_ = twf.LabelField()


# Tag
class FormTagNew(RestForm):
    """New tag form."""
    taggable_id = twf.HiddenField()
    current_tags_ = twf.LabelField()
    tagids = twf.MultipleSelectField(label='Tags', options=[], size=SEL_SIZE)
    new_tags = twf.TextField(validator=twc.RegexValidator(regex=G.pattern_tags))


class FormTagConfirm(RestForm):
    """Generic tag confirmation form."""
    tag_id = twf.HiddenField()


class FormTagRemove(RestForm):
    """Remove tag form."""
    custom_method = 'REMOVE'
    taggable_id = twf.HiddenField()
    tagids = twf.MultipleSelectField(label='Tags', options=[], size=SEL_SIZE)


# Note
class FormNoteNew(RestForm):
    """New note form."""
    proj = twf.HiddenField()
    annotable_id = twf.HiddenField()