def get_identifiers(self, obj): """Get identifiers.""" items = [ DocumentRecord.get_permanent_link(request.host_url, obj['metadata']['pid']) ] # If files on the document if '_files' in obj['metadata']: # Extraction of files only with a type file files = filter(lambda f: ('type' in f and f['type'] == 'file'), obj['metadata']['_files']) # Files sorting files = sorted(files, key=lambda file: file.get('order', 100)) # Remove / at the end of host_url host = request.host_url[:-1] # Add file only the the link is defined in download for file in files: links = file.get('links', {}) if 'download' in links and links.get('download'): items.append(host + links.get('download')) return items
def get_identifiers(self, obj): """Get identifiers.""" return [ DocumentRecord.get_permanent_link(request.host_url, obj['metadata']['pid']) ]
def add_permalink(self, item, **kwargs): """Add permanent link to document.""" item['permalink'] = DocumentRecord.get_permanent_link( request.host_url, item['pid']) return item