-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementação do listar e cadastrar tarefas #18
- Loading branch information
1 parent
24ee350
commit 4e46daa
Showing
4 changed files
with
66 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tasktracking/tasks/templates/tasks/tarefa/cadastrar_tarefa.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block titulo %} | ||
<title>PWeb 2020.6 - Adicionar Tarefa</title> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<form method="post"> | ||
{% csrf_token %} | ||
|
||
<table class="table table-sm table-responsive-sm"> | ||
{% for field in form_tarefa.visible_fields %} | ||
<tr> | ||
<th class="align-middle"> | ||
<label>{{ field.label_tag }}</label> | ||
</th> | ||
<td class="align-middle">{{ field }} | ||
{% if field.help_text %} | ||
<small style="color: grey">{{ field.help_text }}</small> | ||
{% endif %} | ||
{% for error in field.errors %} | ||
<p style="color: red">{{ error }}</p> | ||
{% endfor %} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
|
||
<div> | ||
<input type="submit" value="Salvar"> | ||
</div> | ||
</form> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
from django.shortcuts import render | ||
from django.http import request | ||
from django.shortcuts import redirect, render | ||
from tasks.forms import TarefaForm | ||
|
||
from tasks.models import Tarefa | ||
|
||
def index(request): | ||
"""View function for home page of site.""" | ||
|
||
lista_tarefas = Tarefa.objects.all() | ||
|
||
context = { | ||
'lista_tarefas': lista_tarefas | ||
} | ||
|
||
return render(request, 'tasks/index.html', context=context) | ||
|
||
|
||
def cadastrar_tarefa(request): | ||
if request.method == 'POST': | ||
form_tarefa = TarefaForm(request.POST) | ||
if form_tarefa.is_valid(): | ||
form_tarefa.save() | ||
return redirect('index') | ||
else: | ||
form_tarefa = TarefaForm() | ||
|
||
context = { | ||
'form_tarefa': form_tarefa | ||
} | ||
return render(request, 'tasks/tarefa/cadastrar_tarefa.html', context=context) |