def canonical_url(self): return url_for( f'invenio_records_rest.draft-datasets_item', pid_value=CommunityPIDValue( self['id'], current_oarepo_communities.get_primary_community_field(self)), _external=True)
def canonical_url(self): return url_for( 'invenio_records_rest.draft-common-community_item', pid_value=CommunityPIDValue( self['control_number'], current_oarepo_communities.get_primary_community_field(self)), _external=True)
def canonical_url(self): if not self.get('oarepo:draft'): endpoint = 'invenio_records_rest.nresults-community_item' else: endpoint = 'invenio_records_rest.draft-nresults-community_item' return url_for(endpoint, pid_value=CommunityPIDValue( self['control_number'], current_oarepo_communities.get_primary_community_field(self)), _external=True)
def community_record_links_factory(pid, record=None, original_links_factory=None, **kwargs): """Ensures that primary community is set in self link.""" if not isinstance(pid.pid_value, CommunityPIDValue): if record: primary_community = current_oarepo_communities.get_primary_community_field(record) elif 'record_hit' in kwargs: primary_community = current_oarepo_communities.get_primary_community_field(kwargs['record_hit']['_source']) else: raise AttributeError('Record or record hit is missing') if isinstance(pid, FetchedPID): pid = FetchedPID(pid.provider, pid.pid_type, CommunityPIDValue(pid.pid_value, primary_community)) elif isinstance(pid, PersistentIdentifier): pid.pid_value = CommunityPIDValue(pid.pid_value, primary_community) else: raise NotImplementedError links = record_fsm_links_factory( pid, record, original_links_factory=original_links_factory, **kwargs) return links
def nr_id_generic_fetcher(record_uuid, data): """Fetch a record's identifiers. :param record_uuid: The record UUID. :param data: The record metadata. :returns: A :data:`invenio_pidstore.fetchers.FetchedPID` instance. """ id_field = "control_number" return FetchedPID( provider=NRIdGenericProvider, pid_type=NRIdGenericProvider.pid_type, pid_value=CommunityPIDValue( str(data[id_field]), current_oarepo_communities.get_primary_community_field(data)))