remove ResourceToListItemMixin to fix tests
@@ -39,46 +39,6 @@ logger = logging.getLogger(__name__)
# Mixins
-class ResourceToListItemMixin(object):
- 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
-
-
class ResourceFileToListItemMixin(object):
def resourceFileToListItem(self, f):
# URLs in metadata should be fully qualified.
@@ -147,7 +107,7 @@ class CheckTaskStatus(generics.RetrieveAPIView):
return HttpResponseRedirect(url)
-class ResourceReadUpdateDelete(ResourceToListItemMixin, generics.RetrieveUpdateDestroyAPIView):
+class ResourceReadUpdateDelete(generics.RetrieveUpdateDestroyAPIView):
# pagination doesn't make sense as there is only one resource
pagination_class = None
@@ -311,7 +271,7 @@ class ResourceListCreate(generics.ListCreateAPIView):
return serializers.ResourceCreatedSerializer
-class SystemMetadataRetrieve(ResourceToListItemMixin, APIView):
+class SystemMetadataRetrieve(APIView):
allowed_methods = ('GET',)
@@ -321,7 +281,7 @@ class SystemMetadataRetrieve(ResourceToListItemMixin, APIView):
def get(self, request, pk):
res, _, _ = view_utils.authorize(request, pk,
needed_permission=ACTION_TO_AUTHORIZE.VIEW_METADATA)
- ser = self.get_serializer_class()(self.resourceToResourceListItem(res))
+ ser = self.get_serializer_class()(res)
return Response(data=ser.data, status=status.HTTP_200_OK)
