diff --git a/designsafe/apps/workspace/tasks.py b/designsafe/apps/workspace/tasks.py index 7d578282c3..869fa2c9a7 100644 --- a/designsafe/apps/workspace/tasks.py +++ b/designsafe/apps/workspace/tasks.py @@ -205,7 +205,8 @@ def index_job_outputs(user, job): fo = AgaveFolderFile.from_path(ag, system_id, path) logger.debug('Indexing: {}'.format(fo.full_path)) o = Object().get_exact_path(system_id = system_id, - username = user, path = fo.path, name = fo.name) + username = user.username, path = fo.path, + name = fo.name) if o is None: o = Object(**fo.to_dict()) o.save() @@ -215,7 +216,8 @@ def index_job_outputs(user, job): fo = agave_utils.get_folder_obj(agave_client = ag, file_obj = f) logger.debug('Indexing: {}'.format(fo.full_path)) o = Object().get_exact_path(system_id = system_id, - username = user, path = fo.path, name = fo.name) + username = user.username, path = fo.path, + name = fo.name) if o is None: o = Object(**fo.to_dict()) o.save() diff --git a/designsafe/libs/elasticsearch/api.py b/designsafe/libs/elasticsearch/api.py index 343ab359e1..cf3631c24f 100644 --- a/designsafe/libs/elasticsearch/api.py +++ b/designsafe/libs/elasticsearch/api.py @@ -453,6 +453,14 @@ def save(self, **kwargs): o = self.__class__.get(id = self._id, ignore = 404) if o is not None: return self.update(**self.to_dict()) + pems = getattr(self, 'permissions', None) + if pems: + username = pems[0]['username'] + o = self.get_exact_path(system_id = self.systemId, + username = username, path = self.path, + name = self.name) + if o is not None: + return o.save() return super(Object, self).save(**kwargs) def to_dict(self, get_id = False, *args, **kwargs):