Merge remote-tracking branch 'origin/3.0' into rbac

This commit is contained in:
grossmj 2021-06-01 16:11:22 +09:30
commit a6d2f48df1
3 changed files with 21 additions and 13 deletions

View File

@ -81,12 +81,14 @@ class ComputesRepository(BaseRepository):
query = update(models.Compute).\ query = update(models.Compute).\
where(models.Compute.compute_id == compute_id).\ where(models.Compute.compute_id == compute_id).\
values(update_values).\ values(update_values)
execution_options(synchronize_session="fetch")
await self._db_session.execute(query) await self._db_session.execute(query)
await self._db_session.commit() await self._db_session.commit()
return await self.get_compute(compute_id) compute_db = await self.get_compute(compute_id)
if compute_db:
await self._db_session.refresh(compute_db) # force refresh of updated_at value
return compute_db
async def delete_compute(self, compute_id: UUID) -> bool: async def delete_compute(self, compute_id: UUID) -> bool:

View File

@ -70,14 +70,16 @@ class TemplatesRepository(BaseRepository):
update_values = template_update.dict(exclude_unset=True) update_values = template_update.dict(exclude_unset=True)
query = not update(models.Template). \ query = update(models.Template). \
where(models.Template.template_id == template_id). \ where(models.Template.template_id == template_id). \
values(update_values).\ values(update_values)
execution_options(synchronize_session="fetch")
await self._db_session.execute(query) await self._db_session.execute(query)
await self._db_session.commit() await self._db_session.commit()
return await self.get_template(template_id) template_db = await self.get_template(template_id)
if template_db:
await self._db_session.refresh(template_db) # force refresh of updated_at value
return template_db
async def delete_template(self, template_id: UUID) -> bool: async def delete_template(self, template_id: UUID) -> bool:

View File

@ -104,12 +104,14 @@ class UsersRepository(BaseRepository):
query = update(models.User).\ query = update(models.User).\
where(models.User.user_id == user_id).\ where(models.User.user_id == user_id).\
values(update_values).\ values(update_values)
execution_options(synchronize_session="fetch")
await self._db_session.execute(query) await self._db_session.execute(query)
await self._db_session.commit() await self._db_session.commit()
return await self.get_user(user_id) user_db = await self.get_user(user_id)
if user_db:
await self._db_session.refresh(user_db) # force refresh of updated_at value
return user_db
async def delete_user(self, user_id: UUID) -> bool: async def delete_user(self, user_id: UUID) -> bool:
""" """
@ -202,12 +204,14 @@ class UsersRepository(BaseRepository):
update_values = user_group_update.dict(exclude_unset=True) update_values = user_group_update.dict(exclude_unset=True)
query = update(models.UserGroup).\ query = update(models.UserGroup).\
where(models.UserGroup.user_group_id == user_group_id).\ where(models.UserGroup.user_group_id == user_group_id).\
values(update_values).\ values(update_values)
execution_options(synchronize_session="fetch")
await self._db_session.execute(query) await self._db_session.execute(query)
await self._db_session.commit() await self._db_session.commit()
return await self.get_user_group(user_group_id) user_group_db = await self.get_user_group(user_group_id)
if user_group_db:
await self._db_session.refresh(user_group_db) # force refresh of updated_at value
return user_group_db
async def delete_user_group(self, user_group_id: UUID) -> bool: async def delete_user_group(self, user_group_id: UUID) -> bool:
""" """