Skip to content

Commit

Permalink
Criado página de detalhamento do módulo
Browse files Browse the repository at this point in the history
close #82
  • Loading branch information
thiago-garcia committed Apr 12, 2024
1 parent ec70e1e commit 62aa201
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pypro/modulos/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ def listar_modulos_ordenados() -> List[Modulo]:
"""

return list(Modulo.objects.order_by('order').all())


def encontrar_modulo(slug: str) -> Modulo:
return Modulo.objects.get(slug=slug)
18 changes: 18 additions & 0 deletions pypro/modulos/templates/modulos/modulo_detalhe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends 'base/base.html' %}
{% block title %}{{ modulo.titulo }}{% endblock title %}
{% block description %}Página com detalhes do módulo {{ modulo.titulo }}{% endblock description %}
{% block body %}
<div class="container">
<div class="row">
<div class="col-md-12">
<h1 class="mt-4 mb-3">{{ modulo.titulo }}</h1>
<dl>
<dt>Público</dt>
<dd>{{ modulo.publico }}</dd>
<dt>Descrição</dt>
<dd>{{ modulo.descricao }}</dd>
</dl>
</div>
</div>
</div>
{% endblock body %}
29 changes: 29 additions & 0 deletions pypro/modulos/tests/test_modulo_detalhe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.urls import reverse
import pytest
from pypro.django_assertions import assert_contains
from model_bakery import baker

from pypro.modulos.models import Modulo


@pytest.fixture
def modulo(db):
return baker.make(Modulo)


@pytest.fixture
def resp(client, modulo):
resp = client.get(reverse('modulos:detalhe', kwargs={'slug': modulo.slug}))
return resp


def test_titulo(resp, modulo: Modulo):
assert_contains(resp, modulo.titulo)


def test_descricao(resp, modulo: Modulo):
assert_contains(resp, modulo.descricao)


def test_publico(resp, modulo: Modulo):
assert_contains(resp, modulo.publico)
5 changes: 4 additions & 1 deletion pypro/modulos/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from django.shortcuts import render

from pypro.modulos import facade


def detalhe(request, slug):
pass
modulo = facade.encontrar_modulo(slug)
return render(request, 'modulos/modulo_detalhe.html', {'modulo': modulo})

0 comments on commit 62aa201

Please sign in to comment.