def resourceToResourceListItem(self, r):
     site_url = hydroshare.utils.current_site_url()
     bag_url = site_url + r.bag_url
     science_metadata_url = site_url + reverse(
         'get_update_science_metadata', args=[r.short_id])
     resource_map_url = site_url + reverse('get_resource_map',
                                           args=[r.short_id])
     resource_url = site_url + r.get_absolute_url()
     coverages = [{
         "type": v['type'],
         "value": json.loads(v['_value'])
     } for v in r.metadata.coverages.values()]
     doi = None
     if r.raccess.published:
         doi = "10.4211/hs.{}".format(r.short_id)
     resource_list_item = serializers.ResourceListItem(
         resource_type=r.resource_type,
         resource_id=r.short_id,
         resource_title=r.metadata.title.value,
         abstract=r.metadata.description,
         creator=r.first_creator.name,
         doi=doi,
         public=r.raccess.public,
         discoverable=r.raccess.discoverable,
         shareable=r.raccess.shareable,
         immutable=r.raccess.immutable,
         published=r.raccess.published,
         date_created=r.created,
         date_last_updated=r.updated,
         bag_url=bag_url,
         coverages=coverages,
         science_metadata_url=science_metadata_url,
         resource_map_url=resource_map_url,
         resource_url=resource_url)
     return resource_list_item
Beispiel #2
0
 def resourceToResourceListItem(self, r):
     site_url = hydroshare.utils.current_site_url()
     bag_url = site_url + AbstractResource.bag_url(r.short_id)
     science_metadata_url = site_url + reverse(
         'get_update_science_metadata', args=[r.short_id])
     resource_map_url = site_url + reverse('get_resource_map',
                                           args=[r.short_id])
     resource_url = site_url + r.get_absolute_url()
     resource_list_item = serializers.ResourceListItem(
         resource_type=r.resource_type,
         resource_id=r.short_id,
         resource_title=r.metadata.title.value,
         creator=r.first_creator.name,
         public=r.raccess.public,
         discoverable=r.raccess.discoverable,
         shareable=r.raccess.shareable,
         immutable=r.raccess.immutable,
         published=r.raccess.published,
         date_created=r.created,
         date_last_updated=r.updated,
         bag_url=bag_url,
         science_metadata_url=science_metadata_url,
         resource_map_url=resource_map_url,
         resource_url=resource_url)
     return resource_list_item
Beispiel #3
0
 def resourceToResourceListItem(self, r):
     # URLs in metadata should be fully qualified.
     # ALWAYS qualify them with www.hydroshare.org, rather than the local server name.
     site_url = hydroshare.utils.current_site_url()
     bag_url = site_url + r.bag_url
     science_metadata_url = site_url + reverse(
         'get_update_science_metadata', args=[r.short_id])
     resource_map_url = site_url + reverse('get_resource_map',
                                           args=[r.short_id])
     resource_url = site_url + r.get_absolute_url()
     coverages = [{
         "type": v['type'],
         "value": json.loads(v['_value'])
     } for v in list(r.metadata.coverages.values())]
     authors = []
     for c in r.metadata.creators.all():
         authors.append(c.name)
     doi = None
     if r.raccess.published:
         doi = "10.4211/hs.{}".format(r.short_id)
     resource_list_item = serializers.ResourceListItem(
         resource_type=r.resource_type,
         resource_id=r.short_id,
         resource_title=r.metadata.title.value,
         abstract=r.metadata.description,
         authors=authors,
         creator=r.first_creator.name,
         doi=doi,
         public=r.raccess.public,
         discoverable=r.raccess.discoverable,
         shareable=r.raccess.shareable,
         immutable=r.raccess.immutable,
         published=r.raccess.published,
         date_created=r.created,
         date_last_updated=r.last_updated,
         bag_url=bag_url,
         coverages=coverages,
         science_metadata_url=science_metadata_url,
         resource_map_url=resource_map_url,
         resource_url=resource_url,
         content_types=r.aggregation_types)
     return resource_list_item