Exemplo n.º 1
0
    aid = "aid"
    mountain = "mountain"


router, MainModel, vote_models = create_api_router(
    model_name="Climbs",
    collection_name="climbs",
    item_name="climb",
    statics=dict(
        crag_id=UUID,
        sector_id=UUID,
    ),
    voted=[
        VoteDefinition(
            model_name="ClimbNameVote",
            collection_name="name_votes",
            item_name="name_vote",
            type=constr(min_length=1, strip_whitespace=True),
        ),
        VoteDefinition(
            model_name="RatingVote",
            collection_name="rating_votes",
            item_name="rating_vote",
            type=conint(ge=0, le=5),
            aggregation=VoteAggregation(
                fn=average,
                name="average_rating",
                type=float,
            ),
        ),
        VoteDefinition(
            model_name="GradeVote",
Exemplo n.º 2
0
from uuid import UUID

from app import GeoPoint, create_api_router, VoteDefinition

router, MainModel, vote_models = create_api_router(
    model_name="Parking",
    collection_name="parkings",
    item_name="parking",
    statics=dict(crag_id=UUID, ),
    voted=[
        VoteDefinition(
            model_name="ParkingCoordinateVote",
            collection_name="coordinate_votes",
            item_name="coordinate_vote",
            type=GeoPoint,
        ),
    ])
Exemplo n.º 3
0
# TODO: check that image + climb belong to the same sector

class LineNode(BaseModel):
    x: float
    y: float


router, MainModel, vote_models = create_api_router(
    model_name="Line",
    collection_name="lines",
    item_name="line",
    statics=dict(
        climb_id=UUID,
        image_id=UUID,
        sector_id=UUID,
    ),
    voted=[
        VoteDefinition(
            model_name="LinePathVote",
            collection_name="line_path_votes",
            item_name="line_path_vote",
            type=List[LineNode],
        ),
    ]
)

mongo.db.lines.create_index([
    ("climb_id", pymongo.ASCENDING),
    ("image_id", pymongo.ASCENDING),
], unique=True)
Exemplo n.º 4
0
from pydantic.types import constr
from typing import List

from app import GeoPoint, create_api_router, VoteDefinition

# TODO: area vote?

router, MainModel, vote_models = create_api_router(
    model_name="Sector",
    collection_name="sectors",
    item_name="sector",
    statics=dict(crag_id=UUID),
    voted=[
        VoteDefinition(
            model_name="SectorNameVote",
            collection_name="name_votes",
            item_name="name_vote",
            type=constr(min_length=2, strip_whitespace=True),
        ),
        VoteDefinition(
            model_name="GuideImagesVote",
            collection_name="guide_images_votes",
            item_name="guide_images_vote",
            type=List[UUID],
        ),
        VoteDefinition(
            model_name="CoordinateVote",
            collection_name="coordinate_votes",
            item_name="coordinate_vote",
            type=GeoPoint,
        ),
        VoteDefinition(
Exemplo n.º 5
0
from uuid import UUID
from typing import Literal

from app import create_api_router, VoteDefinition

# TODO: downsize image height
# TODO: maxsize limit
# TODO: only allow jpeg

router, MainModel, vote_models = create_api_router(
    model_name="CragPhotos",
    collection_name="crag_photos",
    item_name="crag_photo",
    statics=dict(
        crag_id=UUID,
        base64_image=str,
    ),
    voted=[
        VoteDefinition(
            model_name="LikeCragPhotoVote",
            collection_name="like_votes",
            item_name="like_vote",
            type=Literal[True],
        ),
    ],
)
Exemplo n.º 6
0
from uuid import UUID
from pydantic import BaseModel
from typing import List, Tuple, Literal

from app import create_api_router, VoteDefinition


class GeoLine(BaseModel):
    type: Literal["LineString"]
    coordinates: List[Tuple[float, float]]


router, MainModel, vote_models = create_api_router(
    model_name="Approach",
    collection_name="approaches",
    item_name="approach",
    statics=dict(crag_id=UUID, ),
    voted=[
        VoteDefinition(
            model_name="ApproachPathVote",
            collection_name="path_votes",
            item_name="path_vote",
            type=GeoLine,
        ),
    ])
Exemplo n.º 7
0
from uuid import UUID
from typing import Literal
from pydantic.types import constr
from typing import Optional

from app import create_api_router, VoteDefinition

router, MainModel, vote_models = create_api_router(
    model_name="BetaVideos",
    collection_name="beta_videos",
    item_name="beta_video",
    statics=dict(
        climb_id=UUID,
        video_url=constr(min_length=1, strip_whitespace=True),
        timestamp=Optional[constr(min_length=1, strip_whitespace=True)],
    ),
    voted=[
        VoteDefinition(
            model_name="LikeBetaVideoVote",
            collection_name="like_votes",
            item_name="like_vote",
            type=Literal[True],
        ),
    ],
)
Exemplo n.º 8
0
from uuid import UUID
from pydantic.types import constr

from app import create_api_router, VoteDefinition

router, MainModel, vote_models = create_api_router(
    model_name="Crag",
    collection_name="crags",
    item_name="crag",
    voted=[
        VoteDefinition(
            model_name="CragNameVote",
            collection_name="name_votes",
            item_name="name_vote",
            type=constr(min_length=2, strip_whitespace=True),
        ),
        VoteDefinition(
            model_name="CragBannerVote",
            collection_name="banner_votes",
            item_name="banner_vote",
            type=UUID,
        ),
        VoteDefinition(
            model_name="AccessInformationVote",
            collection_name="access_information_votes",
            item_name="access_information_vote",
            type=constr(min_length=2, strip_whitespace=True),
        ),
        VoteDefinition(
            model_name="CragDescriptionVote",
            collection_name="description_votes",
from uuid import UUID
from typing import Literal
from pydantic.types import constr
from typing import Optional

from app import create_api_router, VoteDefinition

router, MainModel, vote_models = create_api_router(
    model_name="ExernalTopoLinks",
    collection_name="external_topo_links",
    item_name="external_topo_link",
    statics=dict(
        climb_id=UUID,
        external_url=constr(min_length=1, strip_whitespace=True),
    ),
    voted=[
        VoteDefinition(
            model_name="LikeExternalTopoLinkVote",
            collection_name="like_votes",
            item_name="like_vote",
            type=Literal[True],
        ),
    ],
)