コード例 #1
0
class RolesSchema(ModelSchema):
    rid = base_fields.Integer()
    title = base_fields.String()
    resources = base_fields.String()

    class Meta:
        pass
コード例 #2
0
ファイル: param.py プロジェクト: yuanbaonet/baoaiback
class PagerJSONParameters(JSONParameters):
    search = base_fields.String(required=False, default='')
    sort = base_fields.String(required=False, default='')
    order = base_fields.String(required=True, default='asc')
    offset = base_fields.Integer(required=True, default=0)
    limit = base_fields.Integer(required=True, default=10)
    lang = base_fields.String(required=False, default='')
コード例 #3
0
ファイル: parameters.py プロジェクト: mt1976/catalog
class AddDatasetParameters(PostFormParameters, schemas.DatasetSchema):
    """
    New data creation parameters.
    """

    license_name = base_fields.String('license_name', required=True)
    publisher_name = base_fields.String('publisher_name')
    organization_name = base_fields.String('organization_name')
    keywords = base_fields.List(base_fields.String, required=False)

    class Meta(schemas.DatasetSchema.Meta):
        fields = schemas.DatasetSchema.Meta.fields + (
            'license_name',
            'organization_name',
            'publisher_name',
        )

    @validates('temporal')
    def validate_temporal_field(self):
        # TODO: support field validation
        pass

    @validates('spatial')
    def validate_spatial_field(self):
        # TODO: support field validation
        pass
コード例 #4
0
ファイル: schema.py プロジェクト: yuanbaonet/baoaiback
class CategoryFieldSchema(ModelSchema):
    """
    Category Field schema
    """
    title = base_fields.String() 
    field = base_fields.String() 
    class Meta:
        pass
コード例 #5
0
class AttachmentsCKeditorUploadSchema(ModelSchema):
    uploaded = base_fields.Integer()
    fileName = base_fields.String()
    url = base_fields.String()
    error = base_fields.Nested(CKeditorUploadErrorSchema)

    class Meta:
        pass
コード例 #6
0
class AddCommentParameters(parameters.PostFormParameters,
                           schemas.CommentSchema):
    target_id = base_fields.String(required=False)
    target_type = base_fields.String(required=False)
    user_id = base_fields.String(required=False)

    class Meta(schemas.CommentSchema.Meta):
        fields = schemas.CommentSchema.Meta.fields
コード例 #7
0
ファイル: parameters.py プロジェクト: mt1976/catalog
class UpdateStoryParameters(PostFormParameters, schemas.StorySchema):
    """
    Story updating parameters.
    """
    title = base_fields.String(required=False)
    web = base_fields.String(required=False)

    class Meta(schemas.StorySchema.Meta):
        fields = schemas.StorySchema.Meta.fields
コード例 #8
0
ファイル: parameters.py プロジェクト: mt1976/catalog
class UpdateSourceParameters(PostFormParameters, schemas.SourceSchema):
    """
    Update a source
    """
    title = base_fields.String(required=False)
    url = base_fields.String(required=False)

    class Meta(schemas.SourceSchema.Meta):
        fields = schemas.SourceSchema.Meta.fields
コード例 #9
0
ファイル: parameters.py プロジェクト: mt1976/catalog
class UpdateLicenseParameters(PostFormParameters, schemas.LicenseSchema):
    """
    Update a license
    """
    name = base_fields.String(required=False)
    url = base_fields.String(required=False)

    class Meta(schemas.LicenseSchema.Meta):
        fields = schemas.LicenseSchema.Meta.fields
コード例 #10
0
class RolesDetailSchema(ModelSchema):
    uid = base_fields.Integer()
    rids = base_fields.List(base_fields.Integer())
    rids_str = base_fields.String()
    resources_ids = base_fields.List(base_fields.Integer())
    resources_ids_str = base_fields.String()
    titles = base_fields.String()
    roles = base_fields.Nested(RolesSchema, many=True)

    class Meta:
        pass
コード例 #11
0
class F14Schema(Schema):
    response = base_fields.Dict()
    interest_rate = base_fields.Float()
    lifetime = base_fields.Integer()

    ##Information from selected area
    nuts0 = base_fields.String()
    nuts3 = base_fields.String()
    population = base_fields.Integer()

    #user input
    building_energy_demand = base_fields.Float()
    building_heat_load = base_fields.Float()
コード例 #12
0
class CreateUserParameters(Parameters):
    """
    Helper parameters to create user.
    """
    name = base_fields.String(
        description="the users name"
    )
    email = base_fields.Email(
        description="the users email"
    )
    password = base_fields.String(
        description="the users password"
    )
コード例 #13
0
class RelatedJiraParameters(PaginationParameters):
    """
    Find Related JIRA parameters.
    """

    jira_id = base_fields.String(description="Jira ID", required=False)
    jira_query = base_fields.String(
        description="Find similar Jira's for Jira Query", required=False)
    model_name = base_fields.String(description="Trained Model Name",
                                    required=False)
    num_of_related_jira_return = base_fields.String(
        description="Return No. of Related JIRA ",
        required=False,
        default="10")
コード例 #14
0
class AddUserParameters(schemas.BaseUserSchema):
    """
    New user creation (sign up) parameters.
    """

    username = base_fields.String(description="Example: root", required=True)
    email = base_fields.Email(description="Example: [email protected]",
                              required=True)
    password = base_fields.String(description="No rules yet", required=True)

    class Meta(schemas.BaseUserSchema.Meta):
        fields = schemas.BaseUserSchema.Meta.fields + (
            'email',
            'password',
        )
コード例 #15
0
class CreateReviewParameters(Parameters):
    description = base_fields.String(description="the users review")
    rating = base_fields.Integer(
        description="the users rating of a ride",
        validate=validate.Range(min=1,
                                max=5,
                                error="Invalid rating. Must be between 1-5"))
コード例 #16
0
class GeocodeParameters(Parameters):
    """
    Helper Parameters class to reuse geocoding.
    """
    search = base_fields.String(
        description="the type of query we want to search",
    )
    filters = base_fields.Raw()
    coordinates = base_fields.List(
        cls_or_instance=base_fields.List(
            cls_or_instance=base_fields.Float()
        ),
        allow_none=True,
    )
    latitude = base_fields.Float(
        allow_none=True,
        description="the latitude to search in",
        validate=validate.Range(min=-90.0, max=90.0, error="Invalid latitude parameters. Must be between -90 and 90.")
    )
    longitude = base_fields.Float(
        allow_none=True,
        description="the latitude to search in",
        validate=validate.Range(min=-180.0, max=180.0,
                                error="Invalid longitude parameters. Must be between -180 and 180.")
    )
    radius = base_fields.Float(
        description="the radius to search in",
        missing=5,
        validate=validate.Range(min=0)
    )
コード例 #17
0
class ListUserParameters(PaginationParameters):
    """
    New user creation (sign up) parameters.
    """

    search = base_fields.String(description='Example: [email protected]',
                                required=False)
コード例 #18
0
class AdminUserInitializedParameters(Parameters):
    """
    New user creation (sign up) parameters.
    """

    email = base_fields.Email(description='Example: [email protected]',
                              required=True)
    password = base_fields.String(description='No rules yet', required=True)
コード例 #19
0
class DefaultHTTPErrorSchema(Schema):

    errors = base_fields.Dict()
    data = base_fields.Dict()
    message = base_fields.String()

    def __init__(self, **kwargs):
        super(DefaultHTTPErrorSchema, self).__init__(**kwargs)
コード例 #20
0
ファイル: schema.py プロジェクト: yuanbaonet/baoaiback
class IrisFigureSchema(ModelSchema):
    """
    IRIS pager schema
    """
    figure_name = base_fields.String()

    class Meta:
        pass
コード例 #21
0
ファイル: parameters.py プロジェクト: mt1976/catalog
class UpdatePublisherParameters(PostFormParameters, schemas.PublisherSchema):
    """
    Update a publisher
    """
    name = base_fields.String(required=False)

    class Meta(schemas.PublisherSchema.Meta):
        fields = schemas.PublisherSchema.Meta.fields
コード例 #22
0
ファイル: parameters.py プロジェクト: mt1976/catalog
class UpdateOrganizationParameters(PostFormParameters,
                                   schemas.OrganizationSchema):
    """
    Update a organization
    """
    name = base_fields.String(required=False)

    class Meta(schemas.OrganizationSchema.Meta):
        fields = schemas.OrganizationSchema.Meta.fields
コード例 #23
0
ファイル: param.py プロジェクト: yuanbaonet/baoaiback
class IrisClassifyPredictParameters(Parameters):
    sepal_length_logic = base_fields.Float(required=False)
    sepal_width_logic = base_fields.Float(required=False)
    petal_length_logic = base_fields.Float(required=False)
    petal_width_logic = base_fields.Float(required=False)
    logic_select = base_fields.String(required=False)


    
コード例 #24
0
class CreateUserParameters(Parameters, schemas.BaseUserSchema):
    """
    New user creation (sign up) parameters.
    """

    email = base_fields.Email(description='Example: [email protected]',
                              required=True)
    password = base_fields.String(description='No rules yet', required=True)

    recaptcha_key = base_fields.String(
        description=
        ('See `/<prefix>/auth/recaptcha` for details. It is required for everybody, except admins'
         ),
        required=False,
    )

    class Meta(schemas.BaseUserSchema.Meta):
        fields = schemas.BaseUserSchema.Meta.fields + (
            'email',
            'password',
            'recaptcha_key',
        )

    @validates_schema
    def validate_captcha(self, data):
        """ "
        Check reCAPTCHA if necessary.

        NOTE: we remove 'recaptcha_key' from data once checked because we don't need it
        in the resource
        """
        recaptcha_key = data.pop('recaptcha_key', None)

        captcha_is_valid = False
        if not recaptcha_key:
            no_captcha_permission = permissions.AdminRolePermission()
            if no_captcha_permission.check():
                captcha_is_valid = True
        elif recaptcha_key == current_app.config.get('RECAPTCHA_BYPASS', None):
            captcha_is_valid = True

        if not captcha_is_valid:
            abort(code=HTTPStatus.FORBIDDEN,
                  message='CAPTCHA key is incorrect.')
コード例 #25
0
class CreateReviewParameters(Parameters):
    ride_id = base_fields.Integer(description="the ride our user is reviewing",
                                  validate=validate.Range(min=0, error="Invalid ride id"))
    user_id = base_fields.Integer(description="the user id who is reviewing",
                                  validate=validate.Range(min=0, error="Invalid user id"))
    description = base_fields.String(description="the users review")
    rating = base_fields.Integer(
        description="the users rating of a ride",
        validate=validate.Range(min=1, max=5, error="Invalid rating. Must be between 1-5")
    )
コード例 #26
0
class LoginParameters(Parameters):
    """
    Helper parameters to login user.
    """
    email = base_fields.Email(
        description="the users email"
    )
    password = base_fields.String(
        description="the users password"
    )
コード例 #27
0
ファイル: schema.py プロジェクト: yuanbaonet/baoaiback
class IrisPredictSchema(ModelSchema):
    """
    IRIS pager schema
    """
    linear_result = base_fields.Float()
    classify_result = base_fields.String()
    metric = base_fields.Float()

    class Meta:
        pass
コード例 #28
0
class AddUserParameters(PostFormParameters, schemas.BaseUserSchema):
    """
    New user creation (sign up) parameters.
    """

    username = base_fields.String(description="Example: root", required=True)
    email = base_fields.Email(description="Example: [email protected]", required=True)
    password = base_fields.String(description="No rules yet", required=True)
    recaptcha_key = base_fields.String(
        description=(
            "See `/users/signup_form` for details. It is required for everybody, except admins"
        ),
        required=False
    )

    class Meta(schemas.BaseUserSchema.Meta):
        fields = schemas.BaseUserSchema.Meta.fields + (
            'email',
            'password',
            'recaptcha_key',
        )

    @validates_schema
    def validate_captcha(self, data):
        """"
        Check reCAPTCHA if necessary.

        NOTE: we remove 'recaptcha_key' from data once checked because we don't need it
        in the resource
        """
        recaptcha_key = data.pop('recaptcha_key', None)
        captcha_is_valid = False
        if not recaptcha_key:
            no_captcha_permission = permissions.AdminRolePermission()
            if no_captcha_permission.check():
                captcha_is_valid = True
        # NOTE: This hardcoded CAPTCHA key is just for demo purposes.
        elif recaptcha_key == 'secret_key':
            captcha_is_valid = True

        if not captcha_is_valid:
            abort(code=HTTPStatus.FORBIDDEN, message="CAPTCHA key is incorrect.")
コード例 #29
0
class GetAssetParameters(Parameters):
    asset_id = fields.String(description="A public key representing the asset")

    @validates('asset_id')
    def validate_id(self, asset_id):
        """
        Validate the format of the asset id. must be a public key
        :param str asset_id: the id to be validated
        :raises: ValidationError
        """
        validate_public_key(asset_id)
コード例 #30
0
class FilteringParameters(Parameters):
    """
    Helper Parameters class to reuse filtering.
    """

    operator = base_fields.String(
        allow_none=True
    )
    ride_type = base_fields.List(
        cls_or_instance=base_fields.String(),
        allow_none=True
    )
    min_height_in_cm = base_fields.Integer(
        allow_none=True,
        validate=validate.Range(min=0)
    )
    admission_price = base_fields.Integer(
        allow_none=True,
        validate=validate.Range(min=0)
    )