Ejemplo n.º 1
0
class RoleUpdateSchema(marshmallow.Schema):
    role = marshmallow.fields.String(
        required=True,
        example='contributor',
        validate=OneOf(UserRoleInWorkspace.get_all_role_slug()))

    @post_load
    def make_role(self, data: typing.Dict[str, typing.Any]) -> object:
        return RoleUpdate(**data)
Ejemplo n.º 2
0
class WorkspaceMemberSchema(marshmallow.Schema):
    role = marshmallow.fields.String(
        example='contributor',
        validate=OneOf(UserRoleInWorkspace.get_all_role_slug()))
    user_id = marshmallow.fields.Int(
        example=3,
        validate=Range(min=1, error="Value must be greater than 0"),
    )
    workspace_id = marshmallow.fields.Int(
        example=4,
        validate=Range(min=1, error="Value must be greater than 0"),
    )
    user = marshmallow.fields.Nested(UserDigestSchema())
    workspace = marshmallow.fields.Nested(
        WorkspaceDigestSchema(exclude=('sidebar_entries', )))
    is_active = marshmallow.fields.Bool()
    do_notify = marshmallow.fields.Bool(
        description='has user enabled notification for this workspace',
        example=True,
    )

    class Meta:
        description = 'Workspace Member information'
Ejemplo n.º 3
0
class WorkspaceMemberInviteSchema(marshmallow.Schema):
    role = marshmallow.fields.String(
        example='contributor',
        validate=OneOf(UserRoleInWorkspace.get_all_role_slug()),
        required=True)
    user_id = marshmallow.fields.Int(
        example=5,
        default=None,
        allow_none=True,
    )
    user_email = marshmallow.fields.Email(
        example='*****@*****.**',
        default=None,
        allow_none=True,
    )
    user_public_name = marshmallow.fields.String(
        example='John',
        default=None,
        allow_none=True,
    )

    @post_load
    def make_role(self, data: typing.Dict[str, typing.Any]) -> object:
        return WorkspaceMemberInvitation(**data)
Ejemplo n.º 4
0
positive_int_validator = Range(min=0, error="Value must be positive or 0")

# String
# string matching list of int separated by ','
regex_string_as_list_of_int = Regexp(regex=(re.compile('^(\d+(,\d+)*)?$')))
acp_validator = Length(min=2)
not_empty_string_validator = Length(min=1)
action_description_validator = OneOf(ActionDescription.allowed_values())
content_global_status_validator = OneOf(
    [status.value for status in GlobalStatus])
content_status_validator = OneOf(content_status_list.get_all_slugs_values())
user_profile_validator = OneOf(Profile._NAME)
user_timezone_validator = Length(max=User.MAX_TIMEZONE_LENGTH)
user_email_validator = Length(min=User.MIN_EMAIL_LENGTH,
                              max=User.MAX_EMAIL_LENGTH)
user_password_validator = Length(min=User.MIN_PASSWORD_LENGTH,
                                 max=User.MAX_PASSWORD_LENGTH)
user_public_name_validator = Length(min=User.MIN_PUBLIC_NAME_LENGTH,
                                    max=User.MAX_PUBLIC_NAME_LENGTH)
user_lang_validator = Length(min=User.MIN_LANG_LENGTH,
                             max=User.MAX_LANG_LENGTH)
user_role_validator = OneOf(UserRoleInWorkspace.get_all_role_slug())

# Dynamic validator #
all_content_types_validator = OneOf(choices=[])


def update_validators():
    all_content_types_validator.choices = content_type_list.endpoint_allowed_types_slug(
    )  # nopep8
Ejemplo n.º 5
0
not_empty_string_validator = Length(min=1)
action_description_validator = OneOf(ActionDescription.allowed_values())
content_global_status_validator = OneOf([status.value for status in GlobalStatus])
content_status_validator = OneOf(content_status_list.get_all_slugs_values())
user_profile_validator = OneOf(Profile._NAME)
user_timezone_validator = Length(max=User.MAX_TIMEZONE_LENGTH)
user_email_validator = Length(
    min=User.MIN_EMAIL_LENGTH,
    max=User.MAX_EMAIL_LENGTH
)
user_password_validator = Length(
    min=User.MIN_PASSWORD_LENGTH,
    max=User.MAX_PASSWORD_LENGTH
)
user_public_name_validator = Length(
    min=User.MIN_PUBLIC_NAME_LENGTH,
    max=User.MAX_PUBLIC_NAME_LENGTH
)
user_lang_validator = Length(
    min=User.MIN_LANG_LENGTH,
    max=User.MAX_LANG_LENGTH
)
user_role_validator = OneOf(UserRoleInWorkspace.get_all_role_slug())

# Dynamic validator #
all_content_types_validator = OneOf(choices=[])


def update_validators():
    all_content_types_validator.choices = content_type_list.endpoint_allowed_types_slug()  # nopep8