Exemple #1
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'))
Exemple #2
0
from c2corg_api.views.document_schemas import area_documents_config
from c2corg_api.views.document_version import DocumentVersionRest

from c2corg_common.fields_area import fields_area
from cornice.resource import resource, view
from cornice.validators import colander_body_validator

from c2corg_api.views.document import DocumentRest, make_validator_create, \
    make_validator_update
from c2corg_api.views import cors_policy, restricted_json_view
from c2corg_api.views.validation import validate_id, validate_pagination, \
    validate_lang_param, validate_preferred_lang_param, validate_lang, \
    validate_associations, validate_version_id, validate_cook_param
from pyramid.httpexceptions import HTTPBadRequest

validate_area_create = make_validator_create(fields_area.get('required'))
validate_area_update = make_validator_update(fields_area.get('required'))
validate_associations_create = functools.partial(validate_associations,
                                                 AREA_TYPE, True)
validate_associations_update = functools.partial(validate_associations,
                                                 AREA_TYPE, False)


@resource(collection_path='/areas',
          path='/areas/{id}',
          cors_policy=cors_policy)
class AreaRest(DocumentRest):
    @view(validators=[validate_pagination, validate_preferred_lang_param])
    def collection_get(self):
        return self._collection_get(AREA_TYPE, area_documents_config)
Exemple #3
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"))
Exemple #4
0
from c2corg_api.models.area import schema_area, Area, schema_update_area, \
    schema_listing_area, AREA_TYPE
from c2corg_api.models.area_association import update_area
from c2corg_api.models.document import UpdateType
from c2corg_common.fields_area import fields_area
from cornice.resource import resource, view

from c2corg_api.views.document import DocumentRest, make_validator_create, \
    make_validator_update
from c2corg_api.views import cors_policy, restricted_json_view
from c2corg_api.views.validation import validate_id, validate_pagination, \
    validate_lang_param, validate_preferred_lang_param
from pyramid.httpexceptions import HTTPBadRequest

validate_area_create = make_validator_create(fields_area.get('required'))
validate_area_update = make_validator_update(fields_area.get('required'))


@resource(collection_path='/areas', path='/areas/{id}',
          cors_policy=cors_policy)
class AreaRest(DocumentRest):

    @view(validators=[validate_pagination, validate_preferred_lang_param])
    def collection_get(self):
        return self._collection_get(
            Area, schema_listing_area, AREA_TYPE, include_areas=False)

    @view(validators=[validate_id, validate_lang_param])
    def get(self):
        return self._get(Area, schema_area, include_areas=False)
Exemple #5
0
                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_update_area = get_update_schema(schema_area)
schema_listing_area = restrict_schema(schema_area, fields_area.get('listing'))
Exemple #6
0
        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_update_area = get_update_schema(schema_area)
schema_listing_area = restrict_schema(
    schema_area, fields_area.get('listing'))