Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not allow deletion of entry node #583

Merged
merged 8 commits into from
Oct 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion caster-back/gencaster/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,15 @@ async def delete_edge(self, info, edge_uuid: uuid.UUID) -> None:
async def delete_node(self, info, node_uuid: uuid.UUID) -> None:
"""Deletes a given :class:`~story_graph.models.Node`."""
await graphql_check_authenticated(info)
await story_graph_models.Node.objects.filter(uuid=node_uuid).adelete()
node = await story_graph_models.Node.objects.aget(uuid=node_uuid)
if node is None:
raise Exception(f"Could not find node {node_uuid}")
if node.is_entry_node:
raise Exception(
f"Node {node_uuid} is an entry node which can not be deleted"
)
await node.adelete()
return None

@strawberry.mutation
async def create_script_cells(
Expand Down
Loading