示例#1
0
def delete_object(request):
    print 'BEGIN def delete_object(request)'
    object_id = request.POST['objectID']
    object_type = request.POST['objectType']

    listObject = ''
    if object_type == "Template":
        listObject = delete_template(object_id)

    elif object_type == "Type":
        listObject = delete_type(object_id)

    else:
        url = request.POST['url']
        bh_factory = BLOBHosterFactory(BLOB_HOSTER, BLOB_HOSTER_URI,
                                       BLOB_HOSTER_USER, BLOB_HOSTER_PSWD,
                                       MDCS_URI)
        blob_hoster = bh_factory.createBLOBHoster()
        blob_hoster.delete(url + "/rest/blob?id=" + object_id)
        messages.add_message(request, messages.INFO,
                             'File deleted with success.')
        print 'END def delete_object(request)'
        return HttpResponse(json.dumps({}),
                            content_type='application/javascript')

    if listObject is not None and listObject != '':
        response_dict = {object_type: listObject}
        return HttpResponse(json.dumps(response_dict),
                            content_type='application/javascript')
    else:
        messages.add_message(request, messages.INFO,
                             object_type + ' deleted with success.')

    print 'END def delete_object(request)'
    return HttpResponse(json.dumps({}), content_type='application/javascript')
 def test_delete_type_with_dependencies(self):
     type = self.createType()
     Type(title='testType', filename='filename', content='content', hash='hash', dependencies=[str(type.id)]).save()
     Template(title='testTemplate', filename='filename', content='content', hash='hash', dependencies=[str(type.id)]).save()
     listDependencies = delete_type(str(type.id))
     self.assertEquals(len(Type.objects()), 2)
     self.assertEquals(len(TypeVersion.objects()), 1)
     self.assertEquals(listDependencies, 'testType, testTemplate')
示例#3
0
 def test_delete_type_with_dependencies(self):
     type = self.createType()
     Type(title='testType',
          filename='filename',
          content='content',
          hash='hash',
          dependencies=[str(type.id)]).save()
     Template(title='testTemplate',
              filename='filename',
              content='content',
              hash='hash',
              dependencies=[str(type.id)]).save()
     listDependencies = delete_type(str(type.id))
     self.assertEquals(len(Type.objects()), 2)
     self.assertEquals(len(TypeVersion.objects()), 1)
     self.assertEquals(listDependencies, 'testType, testTemplate')
示例#4
0
 def test_delete_type_no_dependencies(self):
     type = self.createType()
     delete_type(str(type.id))
     self.assertEquals(len(Type.objects()), 0)
     self.assertEquals(len(TypeVersion.objects()), 0)
 def test_delete_type_no_dependencies(self):
     type = self.createType()
     delete_type(str(type.id))
     self.assertEquals(len(Type.objects()), 0)
     self.assertEquals(len(TypeVersion.objects()), 0)