Example #1
0
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_image_locale]
        },
        'geometry': get_geometry_schema_overrides(['POINT'])
    })

schema_create_image = get_create_schema(schema_image)
schema_update_image = get_update_schema(schema_image)
schema_listing_image = restrict_schema(
    schema_image, fields_image.get('listing'))
schema_association_image = restrict_schema(schema_image, [
    'filename', 'locales.title', 'geometry.geom'
])


class SchemaImageList(MappingSchema):
    images = SchemaNode(
        Sequence(), schema_create_image, missing=None)
schema_create_image_list = SchemaImageList()


def is_personal(image_id):
    image_type = DBSession.query(Image.image_type). \
Example #2
0
            'missing': None
        },
        'locales': {
            'children': [schema_xreport_locale],
        },
        'activities': {
            'validator': colander.Length(min=1)
        },
        'geometry': geometry_schema_overrides
    })

# schema that hides personal information of a xreport
schema_xreport_without_personal = SQLAlchemySchemaNode(
    Xreport,
    # whitelisted attributes
    includes=schema_attributes + attributes_without_personal,
    overrides={
        'locales': {
            'children': [schema_xreport_locale],
        },
        'geometry': geometry_schema_overrides
    })


schema_create_xreport = get_create_schema(schema_xreport)
schema_update_xreport = get_update_schema(schema_xreport)
schema_listing_xreport = restrict_schema(
    schema_xreport,
    fields_xreport.get('listing')
)
Example #3
0
        'polymorphic_identity': BOOK_TYPE,
        'inherit_condition': ArchiveDocument.id == id
    }

    __table_args__ = Base.__table_args__

schema_book_locale = schema_document_locale
schema_book_attributes = list(schema_attributes)
schema_book_attributes.remove('geometry')

schema_book = SQLAlchemySchemaNode(
    Book,
    # whitelisted attributes
    includes=schema_book_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_book_locale]
        },
    })

schema_create_book = get_create_schema(schema_book)
schema_update_book = get_update_schema(schema_book)
schema_listing_book = restrict_schema(
    schema_book, fields_book.get('listing'))
Example #4
0
    __mapper_args__ = {
        'polymorphic_identity': AREA_TYPE,
        'inherit_condition': ArchiveDocument.id == id
    }

    __table_args__ = Base.__table_args__


schema_area = SQLAlchemySchemaNode(
    Area,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_document_locale]
        },
        'geometry': get_geometry_schema_overrides(['POLYGON', 'MULTIPOLYGON'])
    })

schema_create_area = get_create_schema(schema_area)
schema_update_area = get_update_schema(schema_area)
schema_listing_area = restrict_schema(
    schema_area, fields_area.get('listing'))
Example #5
0
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_document_locale]
        },
        'geometry': geometry_schema_overrides
    })

schema_update_topo_map = get_update_schema(schema_topo_map)
schema_listing_topo_map = restrict_schema(schema_topo_map,
                                          fields_topo_map.get('listing'))


# TODO cache on document_id and lang (empty the cache if the document geometry
# has changed or any maps was updated/created)
def get_maps(document, lang):
    """Load and return maps that intersect with the document geometry.
    """
    if document.geometry is None:
        return []

    document_geom = select([DocumentGeometry.geom]). \
        where(DocumentGeometry.document_id == document.document_id)
    document_geom_detail = select([DocumentGeometry.geom_detail]). \
Example #6
0
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_user_profile_locale]
        },
        'geometry': geometry_schema_overrides
    })

schema_internal_user_profile = SQLAlchemySchemaNode(
    UserProfile,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_document_locale]
        },
        'geometry': geometry_schema_overrides
    })

schema_update_user_profile = get_update_schema(schema_user_profile)
schema_listing_user_profile = restrict_schema(
    schema_user_profile, fields_user_profile.get('listing'))
Example #7
0
        'inherit_condition': ArchiveDocument.id == id
    }

    __table_args__ = Base.__table_args__


schema_book_locale = schema_document_locale
schema_book_attributes = list(schema_attributes)
schema_book_attributes.remove('geometry')

schema_book = SQLAlchemySchemaNode(
    Book,
    # whitelisted attributes
    includes=schema_book_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_book_locale]
        },
    })

schema_create_book = get_create_schema(schema_book)
schema_update_book = get_update_schema(schema_book)
schema_listing_book = restrict_schema(
    schema_book, fields_book.get('listing'))
Example #8
0

class ArchiveArea(_AreaMixin, ArchiveDocument):
    """
    """

    __tablename__ = "areas_archives"

    id = Column(Integer, ForeignKey(schema + ".documents_archives.id"), primary_key=True)

    __mapper_args__ = {"polymorphic_identity": AREA_TYPE, "inherit_condition": ArchiveDocument.id == id}

    __table_args__ = Base.__table_args__


schema_area = SQLAlchemySchemaNode(
    Area,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        "document_id": {"missing": None},
        "version": {"missing": None},
        "locales": {"children": [schema_document_locale]},
        "geometry": geometry_schema_overrides,
    },
)

schema_create_area = get_create_schema(schema_area)
schema_update_area = get_update_schema(schema_area)
schema_listing_area = restrict_schema(schema_area, fields_area.get("listing"))
Example #9
0
    includes=schema_locale_attributes + attributes_locales,
    overrides={'version': {
        'missing': None
    }})

schema_outing = SQLAlchemySchemaNode(
    Outing,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_outing_locale]
        },
        'activities': {
            'validator': colander.Length(min=1)
        },
        'geometry':
        get_geometry_schema_overrides(['LINESTRING', 'MULTILINESTRING'])
    })

schema_create_outing = get_create_schema(schema_outing)
schema_update_outing = get_update_schema(schema_outing)
schema_association_outing = restrict_schema(
    schema_outing, ['locales.title', 'activities', 'date_start', 'date_end'])
Example #10
0
        ForeignKey(schema + '.documents_archives.id'), primary_key=True)

    __mapper_args__ = {
        'polymorphic_identity': MAP_TYPE,
        'inherit_condition': ArchiveDocument.id == id
    }

    __table_args__ = Base.__table_args__


schema_topo_map = SQLAlchemySchemaNode(
    TopoMap,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_document_locale]
        },
        'geometry': geometry_schema_overrides
    })

schema_update_topo_map = get_update_schema(schema_topo_map)
schema_listing_topo_map = restrict_schema(
    schema_topo_map, fields_topo_map.get('listing'))
Example #11
0
schema_article_attributes.remove('geometry')

schema_article = SQLAlchemySchemaNode(
    Article,
    # whitelisted attributes
    includes=schema_article_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_article_locale]
        },
    })

schema_create_article = get_create_schema(schema_article)
schema_update_article = get_update_schema(schema_article)
schema_listing_article = restrict_schema(
    schema_article, fields_article.get('listing'))


def is_personal(article_id):
    article_type = DBSession.query(Article.article_type). \
        select_from(Article.__table__). \
        filter(Article.document_id == article_id). \
        scalar()
    return article_type == 'personal'
Example #12
0
    Route,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_route_locale]
        },
        'activities': {
            'validator': colander.Length(min=1)
        },
        'geometry': get_geometry_schema_overrides(
            ['LINESTRING', 'MULTILINESTRING'])
    })

schema_create_route = get_create_schema(schema_route)
schema_update_route = get_update_schema(schema_route)
schema_association_route = restrict_schema(schema_route, [
    'locales.title', 'locales.title_prefix', 'elevation_min', 'elevation_max',
    'activities'
])
schema_association_waypoint_route = restrict_schema(schema_route, [
    'locales.title', 'locales.title_prefix', 'elevation_min', 'elevation_max',
    'activities', 'geometry.geom_detail'
])
Example #13
0
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_user_profile_locale]
        },
        'geometry': geometry_schema_overrides
    })


schema_internal_user_profile = SQLAlchemySchemaNode(
    UserProfile,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_document_locale]
        },
        'geometry': geometry_schema_overrides
    })

schema_update_user_profile = get_update_schema(schema_user_profile)
schema_listing_user_profile = restrict_schema(
    schema_user_profile, fields_user_profile.get('listing'))
Example #14
0
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_xreport_locale],
        },
        'geometry': get_geometry_schema_overrides(['POINT'])
    })

# schema that hides personal information of a xreport
schema_xreport_without_personal = SQLAlchemySchemaNode(
    Xreport,
    # whitelisted attributes
    includes=schema_attributes + attributes_without_personal,
    overrides={
        'locales': {
            'children': [schema_xreport_locale],
        },
        'geometry': get_geometry_schema_overrides(['POINT'])
    })

schema_create_xreport = get_create_schema(schema_xreport)
schema_update_xreport = get_update_schema(schema_xreport)
schema_listing_xreport = restrict_schema(schema_xreport,
                                         fields_xreport.get('listing'))
Example #15
0
schema_waypoint_locale = SQLAlchemySchemaNode(
    WaypointLocale,
    # whitelisted attributes
    includes=schema_locale_attributes + attributes_locales,
    overrides={'version': {
        'missing': None
    }})

schema_waypoint = SQLAlchemySchemaNode(
    Waypoint,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_waypoint_locale]
        },
        'geometry': geometry_schema_overrides
    })

schema_create_waypoint = get_create_schema(schema_waypoint)
schema_update_waypoint = get_update_schema(schema_waypoint)
schema_association_waypoint = restrict_schema(schema_waypoint,
                                              ['elevation', 'locales.title'])
Example #16
0
        'version': {
            'missing': None
        }
    })

schema_outing = SQLAlchemySchemaNode(
    Outing,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_outing_locale]
        },
        'activities': {
            'validator': colander.Length(min=1)
        },
        'geometry': geometry_schema_overrides
    })

schema_create_outing = get_create_schema(schema_outing)
schema_update_outing = get_update_schema(schema_outing)
schema_association_outing = restrict_schema(schema_outing, [
    'locales.title', 'activities', 'date_start', 'date_end'
])
Example #17
0
schema_article_attributes.remove('geometry')

schema_article = SQLAlchemySchemaNode(
    Article,
    # whitelisted attributes
    includes=schema_article_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_article_locale]
        },
    })

schema_create_article = get_create_schema(schema_article)
schema_update_article = get_update_schema(schema_article)
schema_listing_article = restrict_schema(schema_article,
                                         fields_article.get('listing'))


def is_personal(article_id):
    article_type = DBSession.query(Article.article_type). \
        select_from(Article.__table__). \
        filter(Article.document_id == article_id). \
        scalar()
    return article_type == 'personal'
Example #18
0
    includes=schema_locale_attributes + attributes_locales,
    overrides={
        'version': {
            'missing': None
        }
    })


schema_waypoint = SQLAlchemySchemaNode(
    Waypoint,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_waypoint_locale]
        },
        'geometry': geometry_schema_overrides
    })

schema_create_waypoint = get_create_schema(schema_waypoint)
schema_update_waypoint = get_update_schema(schema_waypoint)
schema_association_waypoint = restrict_schema(schema_waypoint, [
    'elevation', 'locales.title'
])
Example #19
0
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_image_locale]
        },
        'geometry': geometry_schema_overrides
    })

schema_create_image = get_create_schema(schema_image)
schema_update_image = get_update_schema(schema_image)
schema_listing_image = restrict_schema(
    schema_image, fields_image.get('listing'))
schema_association_image = restrict_schema(schema_image, [
    'filename', 'locales.title', 'geometry.geom'
])


class SchemaImageList(MappingSchema):
    images = SchemaNode(
        Sequence(), schema_create_image, missing=None)
schema_create_image_list = SchemaImageList()


def is_personal(image_id):
    image_type = DBSession.query(Image.image_type). \
Example #20
0
schema_route = SQLAlchemySchemaNode(
    Route,
    # whitelisted attributes
    includes=schema_attributes + attributes,
    overrides={
        'document_id': {
            'missing': None
        },
        'version': {
            'missing': None
        },
        'locales': {
            'children': [schema_route_locale]
        },
        'activities': {
            'validator': colander.Length(min=1)
        },
        'geometry': geometry_schema_overrides
    })

schema_create_route = get_create_schema(schema_route)
schema_update_route = get_update_schema(schema_route)
schema_association_route = restrict_schema(schema_route, [
    'locales.title', 'locales.title_prefix', 'elevation_min', 'elevation_max',
    'activities'
])
schema_association_waypoint_route = restrict_schema(schema_route, [
    'locales.title', 'locales.title_prefix', 'elevation_min', 'elevation_max',
    'activities', 'geometry.geom_detail'
])