Skip to content

Commit

Permalink
Update the test application
Browse files Browse the repository at this point in the history
  • Loading branch information
edelvalle committed Jul 19, 2023
1 parent 03f50e3 commit 62d7af0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
17 changes: 14 additions & 3 deletions tests/fision/todo/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from reactor.component import Component
from reactor.schemas import DomAction, ModelAction

from .models import Item, ItemQS
from .models import Item


class Showing(StrEnum):
Expand All @@ -17,7 +17,6 @@ class XTodoList(Component):
_subscriptions = {"item"}

showing: Showing = Showing.ALL
new_item: str = ""

@property
def queryset(self):
Expand All @@ -34,6 +33,18 @@ def items(self):
qs = self.queryset.filter(completed=False)
return qs

async def mutation(
self,
channel: str,
action: ModelAction,
instance: Item,
):
if action == ModelAction.CREATED:
await self.dom(
DomAction.APPEND, "todo-list", XTodoItem, item=instance
)
self.skip_render()

@property
async def all_items_are_completed(self):
return (await self.items.acount()) == (
Expand All @@ -45,7 +56,7 @@ async def toggle_all(self, toggle_all: bool):

async def add(self, new_item: str):
await Item.objects.acreate(text=new_item)
self.new_item = ""
self.skip_render()

async def show(self, showing: Showing):
self.showing = showing
Expand Down
1 change: 0 additions & 1 deletion tests/fision/todo/templates/todo/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ <h1>todos</h1>
<input class="new-todo"
placeholder="What needs to be done?"
name="new_item"
value="{{ this.new_item }}"
autofocus
{% on 'keypress.enter' 'add' %} />
</header>
Expand Down
1 change: 0 additions & 1 deletion tests/fision/todo/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.shortcuts import redirect, render
from fision.todo.models import Item


def index(request):
Expand Down

0 comments on commit 62d7af0

Please sign in to comment.