'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'))
from c2corg_api.models.document import ArchiveDocumentLocale from c2corg_api.views.document_info import DocumentInfoRest from c2corg_api.views.document_version import DocumentVersionRest from c2corg_common.fields_book import fields_book from cornice.resource import resource, view from cornice.validators import colander_body_validator from c2corg_api.views.document_schemas import book_documents_config 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_associations, validate_lang, validate_version_id validate_book_create = make_validator_create(fields_book.get('required')) validate_book_update = make_validator_update(fields_book.get('required')) validate_associations_create = functools.partial(validate_associations, BOOK_TYPE, True) validate_associations_update = functools.partial(validate_associations, BOOK_TYPE, False) @resource(collection_path='/books', path='/books/{id}', cors_policy=cors_policy) class BookRest(DocumentRest): @view(validators=[validate_pagination, validate_preferred_lang_param]) def collection_get(self): return self._collection_get(BOOK_TYPE, book_documents_config)
from c2corg_api.models.document import ArchiveDocumentLocale from c2corg_api.views.document_info import DocumentInfoRest from c2corg_api.views.document_version import DocumentVersionRest from c2corg_common.fields_book import fields_book from cornice.resource import resource, view from cornice.validators import colander_body_validator from c2corg_api.views.document_schemas import book_documents_config 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_associations, validate_lang, validate_version_id validate_book_create = make_validator_create(fields_book.get('required')) validate_book_update = make_validator_update(fields_book.get('required')) validate_associations_create = functools.partial( validate_associations, BOOK_TYPE, True) validate_associations_update = functools.partial( validate_associations, BOOK_TYPE, False) @resource(collection_path='/books', path='/books/{id}', cors_policy=cors_policy) class BookRest(DocumentRest): @view(validators=[validate_pagination, validate_preferred_lang_param]) def collection_get(self): return self._collection_get(BOOK_TYPE, book_documents_config)
'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'))