Skip to content

Commit

Permalink
Atualização do arquivo urls e views #20
Browse files Browse the repository at this point in the history
  • Loading branch information
wanessabezerra committed Nov 12, 2020
1 parent 8257447 commit 688f8da
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 0 additions & 1 deletion tasktracking/tasks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class Tarefa(models.Model):
fechada_em = models.DateTimeField(null=True, blank=True)
status = models.CharField(max_length=1, choices=STATUS_CHOICES)
situacao = models.CharField(max_length=1, choices=SITUACAO_CHOICES)

usuario = models.ForeignKey(Usuario, on_delete=models.PROTECT)

def __str__(self):
Expand Down
2 changes: 1 addition & 1 deletion tasktracking/tasks/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<li><a class="nav-link" href="#">Tarefas</a></li>
<li><a class="nav-link" href="#">Tags</a></li>
<li><a class="nav-link" href="link\cadastrar_link.html">Links</a></li>
<li><a class="nav-link" href="#">Usuario</a></li>
<li><a class="nav-link" href="#">Usuário</a></li>
<li><a class="nav-link" href="#">Execuções</a></li>
</ul>
</div>
Expand Down
3 changes: 2 additions & 1 deletion tasktracking/tasks/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
urlpatterns = [
path('', views.index, name='index'),
path('cadastrar_tarefa', views.cadastrar_tarefa, name='cadastrar_tarefa'),
]
path('cadastrar_link', views.cadastrar_link, name='cadastrar_link'),
]
17 changes: 17 additions & 0 deletions tasktracking/tasks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from tasks.forms import TarefaForm

from tasks.models import Tarefa
from tasks.models import Link

def index(request):
"""View function for home page of site."""

lista_tarefas = Tarefa.objects.all()
lista_link = Link.objects.all()

context = {
'lista_tarefas': lista_tarefas
Expand All @@ -29,3 +31,18 @@ def cadastrar_tarefa(request):
'form_tarefa': form_tarefa
}
return render(request, 'tasks/tarefa/cadastrar_tarefa.html', context=context)

def cadastrar_link(request):
if request.method == 'POST':
form_link = LinkForm(request.POST)
if form_link.is_valid():
form_link.save()
return redirect('index')
else:
form_link = LinkForm()

context = {
'form_link': form_link
}
return render(request, 'tasks/link/cadastrar_link.html', context=context)

0 comments on commit 688f8da

Please sign in to comment.