Skip to content

Commit

Permalink
Add cadastrar execucao #22
Browse files Browse the repository at this point in the history
  • Loading branch information
tacianosilva committed Nov 26, 2020
1 parent 9219f62 commit 82e6337
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions tasktracking/tasks/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
path('cadastrar_link', views.cadastrar_link, name='cadastrar_link'),
path('cadastrar_tag', views.cadastrar_tag, name='cadastrar_tag'),
path('pesquisar_tarefas', views.buscar_tarefas, name='buscar_tarefas'),
path('cadastrar_execucao', views.cadastrar_execucao, name='cadastrar_execucao'),
]
28 changes: 26 additions & 2 deletions tasktracking/tasks/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.http import request
from django.http.response import JsonResponse
from django.shortcuts import redirect, render
from django.views.generic import DetailView
from datetime import datetime
from tasks.forms import LinkForm, TarefaForm, TagForm

from tasks.models import Tarefa
from tasks.models import Execucao, Tarefa
from tasks.models import Link
from tasks.models import Tag

Expand Down Expand Up @@ -80,4 +82,26 @@ def buscar_tarefas(request):
context = {
'lista_tarefas': lista_tarefas
}
return render(request, 'tasks/index.html', context=context)
return render(request, 'tasks/index.html', context=context)


def cadastrar_execucao(request):
tarefa_pk = request.GET.get('tarefa_pk')
print('Passando na View!' + tarefa_pk)

tarefa = Tarefa.objects.get(pk=tarefa_pk)
inicio = datetime.now()
Execucao.objects.create(
inicio=inicio, tarefa=tarefa,
status=Execucao.EXECUTANDO,
usuario=tarefa.usuario)

data = dict()
return JsonResponse(data)


def stop_execucao(request):
# Buscar uma execução da tarefa selecionda que esteja EXECUTANDO
# Colocar o status PARADA e a data de fim.
data = dict()
return JsonResponse(data)

0 comments on commit 82e6337

Please sign in to comment.