class RecordServiceConfig(RecordServiceConfigBase): """Draft Service configuration.""" # Service configuration permission_policy_cls = RecordPermissionPolicy # WHY: We want to force user input choice here. draft_cls = None schema = RecordSchema schema_parent = ParentSchema search = SearchOptions search_drafts = SearchDraftsOptions search_versions = SearchVersionsOptions components = [ DraftMetadataComponent, PIDComponent, ] links_item = { "self": ConditionalLink( cond=is_record, if_=RecordLink("{+api}/records/{id}"), else_=RecordLink("{+api}/records/{id}/draft"), ), "self_html": ConditionalLink( cond=is_record, if_=RecordLink("{+ui}/records/{id}"), else_=RecordLink("{+ui}/uploads/{id}"), ), "latest": RecordLink("{+api}/records/{id}/versions/latest"), "latest_html": RecordLink("{+ui}/records/{id}/latest"), "draft": RecordLink("{+api}/records/{id}/draft", when=is_record), "record": RecordLink("{+api}/records/{id}", when=is_draft), "publish": RecordLink("{+api}/records/{id}/draft/actions/publish", when=is_draft), "versions": RecordLink("{+api}/records/{id}/versions"), } links_search = pagination_links("{+api}/records{?args*}") links_search_drafts = pagination_links("{+api}/user/records{?args*}") links_search_versions = pagination_links( "{+api}/records/{id}/versions{?args*}")
class VocabulariesServiceConfig(RecordServiceConfig): """Vocabulary service configuration.""" permission_policy_cls = PermissionPolicy record_cls = Vocabulary schema = VocabularySchema search = VocabularySearchOptions components = [ # Order of components are important! VocabularyTypeComponent, DataComponent, PIDComponent, ] links_item = { "self": Link("{+api}/vocabularies/{type}/{id}", vars=lambda record, vars: vars.update({ "id": record.pid.pid_value, "type": record.type.id, })), } links_search = pagination_links("{+api}/vocabularies/{type}{?args*}")
class Marc21RecordServiceConfig(RecordServiceConfig): """Marc21 record service config.""" # Record class record_cls = Marc21Record # Draft class draft_cls = Marc21Draft # Parent class parent_record_cls = Marc21Parent # Schemas schema = Marc21RecordSchema schema_parent = Marc21ParentSchema # TODO: ussing from invenio-permissions permission_policy_cls = Marc21RecordPermissionPolicy links_search = pagination_links("{+api}/marc21{?args*}") links_search_drafts = pagination_links("{+api}/marc21/draft{?args*}") links_search_versions = pagination_links("{+api}/marc21/{id}/versions{?args*}") components = [ MetadataComponent, AccessComponent, PIDComponent, ] links_item = { "self": ConditionalLink( cond=is_record, if_=RecordLink("{+api}/marc21/{id}"), else_=RecordLink("{+api}/marc21/{id}/draft"), ), "self_html": ConditionalLink( cond=is_record, if_=RecordLink("{+ui}/marc21/{id}"), else_=RecordLink("{+ui}/uploads/{id}"), ), }