How to use the schematics.Model function in schematics

To help you get started, we’ve selected a few schematics 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 hotosm / tasking-manager / server / models / dtos / user_dto.py View on Github external
class UserSearchQuery(Model):
    """ Describes a user search query, that a user may submit to filter the list of users """

    username = StringType()
    role = StringType(validators=[is_known_role])
    mapping_level = StringType(
        serialized_name="mappingLevel", validators=[is_known_mapping_level]
    )
    page = IntType()

    def __hash__(self):
        """ Make object hashable so we can cache user searches"""
        return hash((self.username, self.role, self.mapping_level, self.page))


class UserContributionDTO(Model):
    date = StringType()
    count = IntType()


class UserContributionsDTO(Model):
    """ DTO for projects a user has mapped """

    def __init__(self):
        super().__init__()
        self.contributions = []

    contributions = ListType(
        ModelType(UserContributionDTO), serialized_name="contributions"
    )
github hotosm / tasking-manager / server / models / dtos / validator_dto.py View on Github external
task_ids = ListType(IntType, required=True, serialized_name="taskIds")
    user_id = IntType(required=True)
    preferred_locale = StringType(default="en")


class ValidationMappingIssue(Model):
    """ Describes one or more occurences of an identified mapping problem during validation """

    mapping_issue_category_id = IntType(
        required=True, serialized_name="mappingIssueCategoryId"
    )
    issue = StringType(required=True)
    count = IntType(required=True)


class ValidatedTask(Model):
    """ Describes the model used to update the status of one task after validation """

    task_id = IntType(required=True, serialized_name="taskId")
    status = StringType(required=True, validators=[is_valid_validated_status])
    comment = StringType()
    issues = ListType(
        ModelType(ValidationMappingIssue), serialized_name="validationIssues"
    )


class ResetValidatingTask(Model):
    """ Describes the model used to stop validating and reset the status of one task """

    task_id = IntType(required=True, serialized_name="taskId")
    comment = StringType()
    issues = ListType(
github hotosm / tasking-manager / server / models / dtos / mapping_dto.py View on Github external
project_id = IntType(required=True)
    preferred_locale = StringType(default="en")


class MappedTaskDTO(Model):
    """ Describes the model used to update the status of one task after mapping """

    user_id = IntType(required=True)
    status = StringType(required=True, validators=[is_valid_mapped_status])
    comment = StringType()
    task_id = IntType(required=True)
    project_id = IntType(required=True)
    preferred_locale = StringType(default="en")


class StopMappingTaskDTO(Model):
    """ Describes the model used to stop mapping and reset the status of one task """

    user_id = IntType(required=True)
    comment = StringType()
    task_id = IntType(required=True)
    project_id = IntType(required=True)
    preferred_locale = StringType(default="en")


class TaskHistoryDTO(Model):
    """ Describes an individual action that was performed on a mapping task"""

    history_id = IntType(serialized_name="historyId")
    task_id = StringType(serialized_name="taskId")
    action = StringType()
    action_text = StringType(serialized_name="actionText")
github hotosm / tasking-manager / server / models / dtos / message_dto.py View on Github external
read = BooleanType()


class MessagesDTO(Model):
    """ DTO used to return all user messages """

    def __init__(self):
        """ DTO constructor initialise all arrays to empty"""
        super().__init__()
        self.user_messages = []

    pagination = ModelType(Pagination)
    user_messages = ListType(ModelType(MessageDTO), serialized_name="userMessages")


class ChatMessageDTO(Model):
    """ DTO describing an individual project chat message """

    message = StringType(required=True)
    user_id = IntType(required=True, serialize_when_none=False)
    project_id = IntType(required=True, serialize_when_none=False)
    timestamp = DateTimeType()
    username = StringType()


class ProjectChatDTO(Model):
    """ DTO describing all chat messages on one project """

    def __init__(self):
        """ DTO constructor initialise all arrays to empty"""
        super().__init__()
        self.chat = []
github hotosm / tasking-manager / server / models / dtos / mapping_issues_dto.py View on Github external
from schematics import Model
from schematics.types import IntType, StringType, BooleanType, ModelType
from schematics.types.compound import ListType


class MappingIssueCategoryDTO(Model):
    """ DTO used to define a mapping-issue category """

    category_id = IntType(serialized_name="categoryId")
    name = StringType(required=True)
    description = StringType(required=False)
    archived = BooleanType(required=False)


class MappingIssueCategoriesDTO(Model):
    """ DTO for all mapping-issue categories """

    def __init__(self):
        super().__init__()
        self.categories = []

    categories = ListType(ModelType(MappingIssueCategoryDTO))


class TaskMappingIssueDTO(Model):
    """ DTO used to define a single mapping issue recorded with a task invalidation """

    category_id = IntType(serialized_name="categoryId")
    name = StringType(required=True)
    count = IntType(required=True)
github hotosm / tasking-manager / server / models / dtos / mapping_dto.py View on Github external
serialized_name="perTaskInstructions", serialize_when_none=False
    )
    is_undoable = BooleanType(serialized_name="isUndoable", default=False)
    auto_unlock_seconds = IntType(serialized_name="autoUnlockSeconds")
    last_updated = DateTimeType(
        serialized_name="lastUpdated", serialize_when_none=False
    )


class TaskDTOs(Model):
    """ Describes an array of Task DTOs"""

    tasks = ListType(ModelType(TaskDTO))


class TaskCommentDTO(Model):
    """ Describes the model used to add a standalone comment to a task outside of mapping/validation """

    user_id = IntType(required=True)
    comment = StringType(required=True)
    task_id = IntType(required=True)
    project_id = IntType(required=True)
    preferred_locale = StringType(default="en")
github hotosm / tasking-manager / server / models / dtos / project_dto.py View on Github external
mapper_level = StringType(required=True, serialized_name="mapperLevel")
    priority = StringType(required=True)
    organisation_name = StringType(serialized_name="organisationName")
    organisation_logo = StringType(serialized_name="organisationLogo")
    campaign = StringType()
    percent_mapped = IntType(serialized_name="percentMapped")
    percent_validated = IntType(serialized_name="percentValidated")
    status = StringType(serialized_name="status")
    active_mappers = IntType(serialized_name="activeMappers")
    last_updated = DateTimeType(serialized_name="lastUpdated")
    due_date = DateTimeType(serialized_name="dueDate")
    total_contributors = IntType(serialized_name="totalContributors")
    country = StringType(serialize_when_none=False)


class ProjectSearchResultsDTO(Model):
    """ Contains all results for the search criteria """

    def __init__(self):
        """ DTO constructor initialise all arrays to empty"""
        super().__init__()
        self.results = []
        self.map_results = []

    map_results = BaseType(serialized_name="mapResults")
    results = ListType(ModelType(ListSearchResultDTO))
    pagination = ModelType(Pagination)


class LockedTasksForUser(Model):
    """ Describes all tasks locked by an individual user"""
github onicagroup / runway / runway / embedded / stacker / config / __init__.py View on Github external
s3 = ListType(ModelType(S3PackageSource))


class Hook(Model):
    path = StringType(required=True)

    required = BooleanType(default=True)

    enabled = BooleanType(default=True)

    data_key = StringType(serialize_when_none=False)

    args = DictType(AnyType)


class Target(Model):
    name = StringType(required=True)

    requires = ListType(StringType, serialize_when_none=False)

    required_by = ListType(StringType, serialize_when_none=False)


class Stack(Model):
    name = StringType(required=True)

    stack_name = StringType(serialize_when_none=False)

    region = StringType(serialize_when_none=False)

    profile = StringType(serialize_when_none=False)
github hotosm / tasking-manager / server / models / dtos / user_dto.py View on Github external
centroid = BaseType()


class UserRecommendedProjectsDTO(Model):
    """ DTO for projects recommended for an user """

    def __init__(self):
        super().__init__()
        self.recommended_projects = []

    recommended_projects = ListType(
        ModelType(RecommendedProject), serialized_name="recommendedProjects"
    )


class UserSearchQuery(Model):
    """ Describes a user search query, that a user may submit to filter the list of users """

    username = StringType()
    role = StringType(validators=[is_known_role])
    mapping_level = StringType(
        serialized_name="mappingLevel", validators=[is_known_mapping_level]
    )
    page = IntType()

    def __hash__(self):
        """ Make object hashable so we can cache user searches"""
        return hash((self.username, self.role, self.mapping_level, self.page))


class UserContributionDTO(Model):
    date = StringType()
github onicagroup / runway / runway / cfngin / config / __init__.py View on Github external
class PackageSources(Model):
    """Package sources model.

    Attributes:
        git (GitPackageSource): Package source located in a git repo.
        local (LocalPackageSource): Package source located on a local disk.
        s3 (S3PackageSource): Package source located in AWS S3.

    """

    git = ListType(ModelType(GitPackageSource))
    local = ListType(ModelType(LocalPackageSource))
    s3 = ListType(ModelType(S3PackageSource))


class Hook(Model):
    """Hook module.

    Attributes:
        args (DictType)
        data_key (StringType)
        enabled (BooleanType)
        path (StringType)
        required (BooleanType)

    """

    args = DictType(AnyType)
    data_key = StringType(serialize_when_none=False)
    enabled = BooleanType(default=True)
    path = StringType(required=True)
    required = BooleanType(default=True)