Esempio n. 1
0
 def delete_container(self, path):
     collection = Collection.find(path)
     if not collection:
         self.logger.info(u"Fail to delete collection at '{}'".format(path))
         return Response(status=HTTP_404_NOT_FOUND)
     if not collection.user_can(self.user, "delete"):
         self.logger.warning(u"User {} tried to delete container '{}'".format(self.user, path))
         return Response(status=HTTP_403_FORBIDDEN)
     Collection.delete_all(collection.path)
     self.logger.info(u"The container '{}' was successfully deleted".format(path))
     return Response(status=HTTP_204_NO_CONTENT)
Esempio n. 2
0
def delete_collection(request, path):
    "delete_coll"
    coll = Collection.find(path)
    if not coll:
        raise Http404

    if not coll.user_can(request.user, "delete"):
        raise PermissionDenied

    if request.method == "POST":
        parent_coll = Collection.find(coll.path)
        if parent_coll:
            parent_path = parent_coll.container
        else:
            # Just in case
            parent_path = ''
        Collection.delete_all(coll.path, username=request.user.name)
        messages.add_message(request, messages.INFO,
                             u"The collection '{}' has been deleted".format(coll.name))
        return redirect('archive:view', path=parent_path)

    return render(request, 'archive/delete.html', {'collection': coll})
Esempio n. 3
0
 def delete_collection(self, path):
     Collection.delete_all(path)