Delete associated entries with an agent when it is deleted

This commit is contained in:
sabaimran
2024-10-08 15:00:21 -07:00
parent f7fc6dbdc8
commit ad716ca58d

View File

@@ -568,6 +568,10 @@ class AgentAdapters:
@staticmethod
async def adelete_agent_by_slug(agent_slug: str, user: KhojUser):
agent = await AgentAdapters.aget_agent_by_slug(agent_slug, user)
async for entry in Entry.objects.filter(agent=agent).aiterator():
await entry.adelete()
if agent:
await agent.adelete()
return True