Skip to content

Commit

Permalink
Merge pull request #25 from labens-ufrn/AttLink
Browse files Browse the repository at this point in the history
Implementação do Cadastrar Link e do Detalhar Tarefa.
  • Loading branch information
tacianosilva authored Nov 12, 2020
2 parents 7d41b51 + a53a719 commit ec93adf
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 28 deletions.
9 changes: 7 additions & 2 deletions tasktracking/tasks/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from django import forms
from tasks.models import Tarefa
from tasks.models import Link, Tarefa


class TarefaForm(forms.ModelForm):
class Meta:
model = Tarefa
fields = '__all__'
fields = '__all__'

class LinkForm(forms.ModelForm):
class Meta:
model = Link
fields = '__all__'
19 changes: 19 additions & 0 deletions tasktracking/tasks/migrations/0004_link_tarefa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.1.2 on 2020-11-12 11:47

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('tasks', '0003_auto_20201105_0835'),
]

operations = [
migrations.AddField(
model_name='link',
name='tarefa',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='tasks.tarefa'),
),
]
9 changes: 6 additions & 3 deletions tasktracking/tasks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class Usuario(models.Model):
null=True
)

def __str__(self):
return self.nome

class Tag(models.Model):
"""
Jonas
Expand All @@ -31,9 +34,10 @@ class Link(models.Model):
"""
nome = models.CharField(max_length=50)
url = models.URLField()
tarefa = models.ForeignKey('Tarefa', on_delete=models.CASCADE, null=True)

def __str__(self):
self.nome
self.url
return self.nome + ' ' + self.url


class Tarefa(models.Model):
Expand Down Expand Up @@ -61,7 +65,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
19 changes: 13 additions & 6 deletions tasktracking/tasks/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
padding: 0;
}


/* Barra de Navegação */

.navbar {
.navbar {
border-bottom: 1px solid #333;
margin-bottom: 20px;
}
Expand All @@ -22,6 +23,7 @@
letter-spacing: 1px;
}


/* Botão de adicionar */

.add-div {
Expand All @@ -40,6 +42,7 @@
margin-left: 5px;
}


/* Busca */

.fas.fa-search {
Expand All @@ -55,6 +58,7 @@
display: inline-block;
}


/* Lista de tarefas */

.list-div {
Expand Down Expand Up @@ -82,15 +86,18 @@
}

.fas.fa-edit {
color: #808080 ;
color: #808080;
cursor: pointer;
margin: 5px;
font-size: 20px;
float: right;
}


/* Rodapé */
footer {

footer#rodape {
clear: both;
background-color: #333;
position: absolute;
bottom: 0;
Expand All @@ -99,9 +106,9 @@ footer {
border-top: 2px solid #202020;
}

footer p {
color: #f5f5f5;
footer#rodape p {
text-align: center;
color: #f5f5f5;
top: 40%;
position: relative;
}
}
24 changes: 12 additions & 12 deletions tasktracking/tasks/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Tarefas</a>
<a class="nav-link" href="#">Tags</a>
<a class="nav-link" href="#">Links</a>
<a class="nav-link" href="#">Usuario</a>
<a class="nav-link" href="#">Execuções</a>
</li>
<ul type="disc" class="navbar-nav">
<li><a class="nav-link" href="#">Tarefas</a></li>
<li><a class="nav-link" href="#">Tags</a></li>
<li><a class="nav-link" href="/cadastrar_link">Links</a></li>
<li><a class="nav-link" href="#">Usuário</a></li>
<li><a class="nav-link" href="#">Execuções</a></li>
</ul>
</div>
</nav>

{% block content %}
{% endblock %}
<footer>
<p>Rodapé</p>

<footer id="rodape">
<p>Copyright &copy; 2020 - by Turma de Pweb 2020.6</br></p>
</footer>
</div>
</body>
</html>
</html>
9 changes: 6 additions & 3 deletions tasktracking/tasks/templates/tasks/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@

{% for tarefa in lista_tarefas %}
<li class="task-item">
<span>{{tarefa}}</span>
<span><i class="fas fa-trash"></i></span>
<span><i class="fas fa-edit"></i></span>
<a href="{% url 'detalhar_tarefa' tarefa.pk %}"
<span>{{ tarefa }}</span>
</a>
<span>Lista de Tags (tarefa.tag_set.all)</span>
<span><i class="fas fa-trash"></i></span>
<span><i class="fas fa-edit"></i></span>
</li>
{% endfor %}
</ul>
Expand Down
35 changes: 35 additions & 0 deletions tasktracking/tasks/templates/tasks/link/cadastrar_link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends "base.html" %}

{% block titulo %}
<title>PWeb 2020.6 - Adicionar Link</title>
{% endblock %}

{% block content %}
<div class="container">
<form method="post">
{% csrf_token %}

<table class="table table-sm table-responsive-sm">
{% for field in form_link.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 %}
54 changes: 54 additions & 0 deletions tasktracking/tasks/templates/tasks/tarefa/detalhar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{% extends "base.html" %}

{% block titulo %}
<title>PWeb 2020.6 - Detalhar Tarefa</title>
{% endblock %}

{% block content %}
<div class="content">
<table class="table table-striped table-sm table-bordered">
<tr>
<td class="font-weight-bold" width="20%">Identificador</td>
<td>{{ object.identificador }}</td>
</tr>
<tr>
<td class="font-weight-bold" width="20%">Nome</td>
<td>{{ object.nome }}</td>
</tr>
<tr>
<td class="font-weight-bold" width="20%">Descrição</td>
<td>{{ object.descrição }}</td>
</tr>
<tr>
<td class="font-weight-bold" width="20%">Criação</td>
<td>{{ object.criada_em }}</td>
</tr>
<tr>
<td class="font-weight-bold" width="20%">Fechamento</td>
<td>{{ object.fechada_em }}</td>
</tr>
<tr>
<td class="font-weight-bold" width="20%">Status</td>
<td>{{ object.status }}</td>
</tr>
<tr>
<td class="font-weight-bold" width="20%">Situação</td>
<td>{{ object.situacao }}</td>
</tr>
<tr>
<td class="font-weight-bold" width="20%">Criador</td>
<td>{{ object.usuario }}</td>
</tr>
<tr>
<td class="font-weight-bold" width="20%">Links</td>
<td>
<ul>
{% for link in object.link_set.all %}
<li>{{ link }}</li>
{% endfor %}
</ul>
</td>
</tr>
</table>
</div>
{% endblock%}
4 changes: 3 additions & 1 deletion tasktracking/tasks/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
urlpatterns = [
path('', views.index, name='index'),
path('cadastrar_tarefa', views.cadastrar_tarefa, name='cadastrar_tarefa'),
]
path('detalhar_tarefa/<int:pk>/', views.TarefaDetailView.as_view(), name='detalhar_tarefa'),
path('cadastrar_link', views.cadastrar_link, name='cadastrar_link'),
]
26 changes: 25 additions & 1 deletion tasktracking/tasks/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from django.http import request
from django.shortcuts import redirect, render
from tasks.forms import TarefaForm
from django.views.generic import DetailView
from tasks.forms import LinkForm, 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 +32,24 @@ def cadastrar_tarefa(request):
'form_tarefa': form_tarefa
}
return render(request, 'tasks/tarefa/cadastrar_tarefa.html', context=context)


class TarefaDetailView(DetailView):
model = Tarefa
template_name = 'tasks/tarefa/detalhar.html'


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 ec93adf

Please sign in to comment.