Skip to content

Commit ea95b11

Browse files
renzonrenzon
authored andcommitted
Added workflow email to help students complete Python Birds module
close #1212
1 parent 8d6b1c6 commit ea95b11

5 files changed

Lines changed: 88 additions & 44 deletions

File tree

‎pythonpro/modules/module_urls.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
urlpatterns = [
77
path('', modules_views.index, name='index'),
88
path('<slug:slug>/', modules_views.detail, name='detail'),
9+
path('enrol/<slug:slug>/', modules_views.enrol, name='enrol'),
910
path('<slug:module_slug>/topicos/<slug:topic_slug>', topics_views.detail, name='topic_detail'),
1011
]

‎pythonpro/modules/modules_views.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.contrib.auth.decorators import login_required
22
from django.shortcuts import render
33

4+
from pythonpro.mailchimp.facade import tag_as
45
from pythonpro.modules.facade import get_all_modules, get_module_with_contents
56

67

@@ -12,3 +13,10 @@ def detail(request, slug):
1213

1314
def index(request):
1415
return render(request, 'modules/module_index.html', context={'modules': get_all_modules()})
16+
17+
18+
@login_required
19+
def enrol(request, slug):
20+
module = get_module_with_contents(slug)
21+
tag_as(request.user.email, slug)
22+
return render(request, 'modules/module_enrol.html', {'module': module})

‎pythonpro/modules/templates/modules/module_detail.html‎

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,59 @@
22
{% load static %}
33

44
{% block title %}{{ module.title }}{% endblock %}
5+
{% block description %}{{ module.description }}{% endblock %}
56

67
{% block body %}
7-
<div class="container">
8-
<div class="row">
9-
<div class="col">
10-
<h1 class="mt-4 mb-3">{{ module.title }}</h1>
11-
<dt>Objetivo</dt>
12-
<dd>
13-
<ul>
14-
<li>{{ module.objective }}</li>
15-
</ul>
16-
</dd>
17-
<dt>Público</dt>
18-
<dd>
19-
<ul>
20-
<li>{{ module.target }}</li>
21-
</ul>
22-
</dd>
23-
<dt>Descrição</dt>
24-
<dd>
25-
<ul>
26-
<li>{{ module.description|linebreaks }}</li>
27-
</ul>
28-
</dd>
29-
<dt>Conteúdo</dt>
30-
<dd>
31-
<ol>
32-
{% for section in module.sections %}
33-
<li><a href="{{ section.get_absolute_url }}">{{ section.title }}</a></li>
34-
<dd>
35-
<ol>
36-
{% for chapter in section.chapters %}
37-
<li><a href="{{chapter.get_absolute_url}}">{{ chapter.title }}</a></li>
38-
{% empty %}
39-
<li>Nenhum Capítulo definido ainda</li>
40-
{% endfor %}
41-
</ol>
42-
</dd>
43-
{% empty %}
44-
<li>Nenhuma seção definida ainda</li>
45-
{% endfor %}
46-
</li>
47-
</ol>
48-
</dd>
49-
</div>
8+
<div class="container">
9+
<div class="row">
10+
<div class="col">
11+
<h1 class="mt-4 mb-3">{{ module.title }}</h1>
12+
<dt>Objetivo</dt>
13+
<dd>
14+
<ul>
15+
<li>{{ module.objective }}</li>
16+
</ul>
17+
</dd>
18+
{% if module.slug == 'python-birds' %}
19+
<dt>Começar meta de 4 semanas</dt>
20+
<dd>
21+
<ul>
22+
<li><a class="btn-success btn" href="{% url 'modules:enrol' slug=module.slug %}">Quero receber email semanal com metas para ajudar a terminar o módulo &raquo;</a></li>
23+
</ul>
24+
</dd>
25+
{% endif %}
26+
<dt>Público</dt>
27+
<dd>
28+
<ul>
29+
<li>{{ module.target }}</li>
30+
</ul>
31+
</dd>
32+
<dt>Descrição</dt>
33+
<dd>
34+
<ul>
35+
<li>{{ module.description|linebreaks }}</li>
36+
</ul>
37+
</dd>
38+
<dt>Conteúdo</dt>
39+
<dd>
40+
<ol>
41+
{% for section in module.sections %}
42+
<li><a href="{{ section.get_absolute_url }}">{{ section.title }}</a></li>
43+
<dd>
44+
<ol>
45+
{% for chapter in section.chapters %}
46+
<li><a href="{{ chapter.get_absolute_url }}">{{ chapter.title }}</a></li>
47+
{% empty %}
48+
<li>Nenhum Capítulo definido ainda</li>
49+
{% endfor %}
50+
</ol>
51+
</dd>
52+
{% empty %}
53+
<li>Nenhuma seção definida ainda</li>
54+
{% endfor %}
55+
</ol>
56+
</dd>
57+
</div>
58+
</div>
5059
</div>
51-
</div>
5260
{% endblock body %}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% extends 'core/base.html' %}
2+
{% load static %}
3+
4+
{% block title %}Começar metas do módulo {{ module.title }}{% endblock %}
5+
{% block description %}Expliação de sistema de metas do módulo {{ topic.description }}{% endblock %}
6+
{% block body %}
7+
<div class="container">
8+
<div class="row">
9+
<div class="col">
10+
<h1 class="mt-4 mb-3">Metas ativadas para o módulo {{ module.title }}</h1>
11+
<p>Você receberá emails semanais para te ajudar a terminar esse módulo. Serão 4 semanas no total</p>
12+
<p>Em instantes você já receberá o primeiro. Confira sua caixa de spam</p>
13+
</div>
14+
</div>
15+
</div>
16+
{% endblock body %}

‎pythonpro/modules/tests/test_module_detail_view.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,14 @@ def test_chapter_titles(resp_with_chapters, chapters):
122122
def test_chapter_urls(resp_with_chapters, chapters):
123123
for chapter in chapters:
124124
dj_assert_contains(resp_with_chapters, chapter.get_absolute_url())
125+
126+
127+
def test_python_birds_enrol_link(resp_with_sections, python_birds):
128+
dj_assert_contains(resp_with_sections, reverse('modules:enrol', kwargs={'slug': python_birds.slug}))
129+
130+
131+
def test_enrol_user_tags(python_birds, client_with_lead, mocker, logged_user):
132+
tag_as = mocker.patch('pythonpro.modules.modules_views.tag_as')
133+
resp = client_with_lead.get(reverse('modules:enrol', kwargs={'slug': python_birds.slug}), secure=True)
134+
tag_as.assert_called_once_with(logged_user.email, python_birds.slug)
135+
assert resp.status_code == 200

0 commit comments

Comments
 (0)