diff --git a/cookies/templates/fragment_resource_list.html b/cookies/templates/fragment_resource_list.html index 4237184..8e0e8cf 100644 --- a/cookies/templates/fragment_resource_list.html +++ b/cookies/templates/fragment_resource_list.html @@ -66,7 +66,12 @@ {% for resource in resources %}
{% if user.is_authenticated %}{% endif %} + {% if resource.primary.id %} {{ resource.primary.name }} {{ resource.primary.entity_type }} + {% else %} + Invalid entry + + {% endif %}
Added by {{ resource.primary.created_by }} on {{ resource.primary.created }} Last updated on {{ resource.primary.updated }} diff --git a/cookies/templates/resources.html b/cookies/templates/resources.html index 522c58b..a71b565 100644 --- a/cookies/templates/resources.html +++ b/cookies/templates/resources.html @@ -6,6 +6,7 @@ {% load addcss %} + {% block breadcrumbs %}
- + + + {% endblock %} diff --git a/cookies/views/resource.py b/cookies/views/resource.py index f13ef7e..beff733 100644 --- a/cookies/views/resource.py +++ b/cookies/views/resource.py @@ -939,3 +939,13 @@ def create_dataset(request): 'collection_count': collections.count(), } return render(request, 'create_dataset.html', context) + + +@login_required +@auth.authorization_required(CollectionAuthorization.REMOVE, _get_resource_by_id) +def delete_resource(request, resource_id): + # Extra check to ensure that only resources which do not have primary id get deleted. + resource_container = ResourceContainer.objects.get(pk=resource_id) + if resource_container.primary_id is None and request.user.id == resource_container.created_by_id: + ResourceContainer.objects.filter(id=resource_id).delete() + return HttpResponseRedirect(reverse('resources')) diff --git a/jars/urls.py b/jars/urls.py index 6517163..8c92145 100644 --- a/jars/urls.py +++ b/jars/urls.py @@ -52,6 +52,7 @@ url(r'^resource/create/giles/process/([0-9]+)/$', views.giles.set_giles_upload_collection, name="create-process-giles"), url(r'^resource/create/details/([0-9]+)/$', views.resource.create_resource_details, name="create-resource-details"), url(r'^resource/create/bulk/$', views.resource.create_resource_bulk, name="create-resource-bulk"), + url(r'^resource/([0-9]+)/delete/$', views.resource.delete_resource, name="delete-resource"), url(r'^collection/([0-9]+)/$', views.collection.collection, name="collection"), url(r'^collection/([0-9]+)/edit/$', views.collection.collection_edit, name="collection-edit"), url(r'^collection/([0-9]+)/authorizations/$', views.collection.collection_authorizations, name="collection-authorizations"),