Exemplo n.º 1
0
Arquivo: views.py Projeto: Bl3f/tdlst
def home(request):
    template_name = "todo/home.html"

    if request.method == 'POST':
        task = Task()
        task.active = True
        task.text = request.POST.get('task')
        task.todo = Todo.objects.get(pk=request.POST.get('todo_id'))
        task.save()

    todo = Todo.objects.all()[0]

    return render(request, template_name, {'todo': todo})
Exemplo n.º 2
0
Arquivo: events.py Projeto: Bl3f/tdlst
def add_task_handler(request, socket, context, message):
    """
    Handler for add task on a todo
    """
    if message.get("action") == "add_task":
        todo = Todo.objects.get(pk=message.get("todo"))

        task = Task()
        task.todo = todo
        task.active = True
        task.text = message.get("task")
        task.save()

        joined = {
            "action": "new_task",
            "task": task.text,
            "task_id": task.pk,
            "active": task.active,
            "archived": task.archived,
            "todo_id": todo.pk,
        }
        socket.send_and_broadcast_channel(joined)