예제 #1
0
    def create(rec_id, prov_bundle, owner, public=False):
        pdbundle = PDBundle.create(rec_id)
        pdbundle.save_bundle(prov_bundle)
        container = Container.objects.create(owner=owner, content=pdbundle, public=public)

        assign('view_container', owner, container)
        assign('change_container', owner, container)
        assign('delete_container', owner, container)
        assign('admin_container', owner, container)
        assign('ownership_container', owner, container)
        if public == True:
            assign('view_container', Group.objects.get(name='public'), container)
        return container
예제 #2
0
 def setUp(self):
     logging.debug('Setting up user and checking the URL file...')
     self.check_u = User.objects.get_or_create(username='******')
     self.user = self.check_u[0]
     self.check_k = ApiKey.objects.get_or_create(user=self.user)
     self.key = self.check_k[0]
     self.auth = 'ApiKey' + self.user.username + ':' + self.key.key
     self.check_u = self.check_u[1]
     self.check_k = self.check_k[1]
     self.url = 'http://users.ecs.soton.ac.uk/ab9g10/test.json'
     source = urlopen(self.url)
     url_content = ProvBundle()
     url_content._decode_JSON_container(json.loads(source.read()))
     source.close()
     self.content = PDBundle.create('url_test')
     self.content.save_bundle(url_content)
     self.content = self.content.get_prov_bundle()