Skip to content

Commit e1d1829

Browse files
renzonrenzon
authored andcommitted
Removed enrol button for Leads
close #1227
1 parent 9488a69 commit e1d1829

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

pythonpro/modules/templates/modules/module_detail.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% extends 'core/base.html' %}
22
{% load static %}
3-
3+
{% load permission_tags %}
44
{% block title %}{{ module.title }}{% endblock %}
55
{% block description %}{{ module.description }}{% endblock %}
66

@@ -15,7 +15,7 @@ <h1 class="mt-4 mb-3">{{ module.title }}</h1>
1515
<li>{{ module.objective }}</li>
1616
</ul>
1717
</dd>
18-
{% if module.slug == 'python-birds' %}
18+
{% if module.slug == 'python-birds' and user|has_role:'client,member' %}
1919
<dt>Duração: 4 semanas</dt>
2020
<dd>
2121
<ul>

pythonpro/modules/tests/test_module_detail_view.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.urls import reverse
44
from model_mommy import mommy
55

6-
from pythonpro.django_assertions import dj_assert_contains, dj_assert_template_used
6+
from pythonpro.django_assertions import dj_assert_contains, dj_assert_not_contains, dj_assert_template_used
77
from pythonpro.modules import facade
88
from pythonpro.modules.models import Chapter, Module, Section
99

@@ -41,6 +41,21 @@ def test_lead_content(content, client_with_lead, modules):
4141
dj_assert_contains(resp, content)
4242

4343

44+
def test_lead_has_no_automation_button(client_with_lead, modules, python_birds):
45+
resp = generate_resp('python-birds', client_with_lead)
46+
dj_assert_not_contains(resp, reverse('modules:enrol', kwargs={'slug': python_birds.slug}))
47+
48+
49+
def test_client_has_no_automation_button(client_with_client, modules, python_birds):
50+
resp = generate_resp('python-birds', client_with_client)
51+
dj_assert_contains(resp, reverse('modules:enrol', kwargs={'slug': python_birds.slug}))
52+
53+
54+
def test_member_has_no_automation_button(client_with_member, modules, python_birds):
55+
resp = generate_resp('python-birds', client_with_member)
56+
dj_assert_contains(resp, reverse('modules:enrol', kwargs={'slug': python_birds.slug}))
57+
58+
4459
@pytest.mark.parametrize(
4560
'content',
4661
[
@@ -124,10 +139,6 @@ def test_chapter_urls(resp_with_chapters, chapters):
124139
dj_assert_contains(resp_with_chapters, chapter.get_absolute_url())
125140

126141

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-
131142
def test_enrol_user_tags(python_birds, client_with_lead, mocker, logged_user):
132143
tag_as = mocker.patch('pythonpro.modules.modules_views.tag_as')
133144
resp = client_with_lead.get(reverse('modules:enrol', kwargs={'slug': python_birds.slug}), secure=True)

0 commit comments

Comments
 (0)