diff --git a/tasktracking/tasks/models.py b/tasktracking/tasks/models.py index e9bb52d..b2bae1d 100644 --- a/tasktracking/tasks/models.py +++ b/tasktracking/tasks/models.py @@ -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): diff --git a/tasktracking/tasks/templates/base.html b/tasktracking/tasks/templates/base.html index 8cbdecc..fa7b445 100644 --- a/tasktracking/tasks/templates/base.html +++ b/tasktracking/tasks/templates/base.html @@ -23,7 +23,7 @@
  • Tarefas
  • Tags
  • Links
  • -
  • Usuario
  • +
  • Usuário
  • Execuções
  • diff --git a/tasktracking/tasks/urls.py b/tasktracking/tasks/urls.py index 7e30864..0dfaecb 100644 --- a/tasktracking/tasks/urls.py +++ b/tasktracking/tasks/urls.py @@ -5,4 +5,5 @@ urlpatterns = [ path('', views.index, name='index'), path('cadastrar_tarefa', views.cadastrar_tarefa, name='cadastrar_tarefa'), -] \ No newline at end of file + path('cadastrar_link', views.cadastrar_link, name='cadastrar_link'), +] diff --git a/tasktracking/tasks/views.py b/tasktracking/tasks/views.py index 996eb81..fbd6537 100644 --- a/tasktracking/tasks/views.py +++ b/tasktracking/tasks/views.py @@ -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 @@ -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) +