Skip to content

Commit 572713b

Browse files
renzonrenzon
renzon
authored andcommitted
Removed cohort links
part of #4776
1 parent ff4de4e commit 572713b

File tree

8 files changed

+2
-300
lines changed

8 files changed

+2
-300
lines changed

pythonpro/cohorts/context_processors.py

-11
This file was deleted.

pythonpro/cohorts/templates/cohorts/cohort_detail.html

-145
This file was deleted.

pythonpro/cohorts/tests/test_cohorts.py

+1-108
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,18 @@
33

44
import pytest
55
from django.core.files.uploadedfile import SimpleUploadedFile
6-
from django.template.defaultfilters import date
7-
from django.urls import reverse
86
from django.utils import timezone
97
from model_bakery import baker
108

119
from pythonpro.cohorts import facade
12-
from pythonpro.cohorts.models import Cohort, LiveClass, Webinar
10+
from pythonpro.cohorts.models import LiveClass, Webinar
1311
from pythonpro.cohorts.tests.conftest import img_path
14-
from pythonpro.django_assertions import dj_assert_contains, dj_assert_not_contains
15-
16-
17-
@pytest.fixture
18-
def resp(client_with_member, cohort):
19-
return client_with_member.get(reverse('cohorts:detail', kwargs={'slug': cohort.slug}))
20-
21-
22-
@pytest.fixture
23-
def resp_without_user(client, db):
24-
image = SimpleUploadedFile(name='renzo-nuccitelli.jpeg', content=open(img_path, 'rb').read(),
25-
content_type='image/png')
26-
cohort = baker.make(Cohort, slug='guido-van-rossum', image=image)
27-
resp = client.get(reverse('cohorts:detail', kwargs={'slug': cohort.slug}))
28-
return resp
29-
30-
31-
def test_no_access(resp_without_user):
32-
"""Assert only logged user can acess cohort pages"""
33-
assert 302 == resp_without_user.status_code
34-
35-
36-
def test_cohort_links_for_logged_user(client, django_user_model):
37-
user = baker.make(django_user_model)
38-
client.force_login(user)
39-
image = SimpleUploadedFile(name='renzo-nuccitelli.jpeg', content=open(img_path, 'rb').read(),
40-
content_type='image/png')
41-
cohorts = baker.make(Cohort, 4, image=image)
42-
resp = client.get(reverse('dashboard:home'))
43-
for c in cohorts:
44-
dj_assert_contains(resp, c.get_absolute_url())
45-
46-
47-
def test_status_code(resp):
48-
assert 200 == resp.status_code
4912

5013

5114
def test_str(cohort):
5215
assert str(cohort) == f'Turma: {cohort.title}'
5316

5417

55-
@pytest.mark.parametrize('property_name', 'title forum_post'.split())
56-
def test_cohort_properties(cohort, resp, property_name):
57-
dj_assert_contains(resp, getattr(cohort, property_name))
58-
59-
60-
def test_cohort_img(cohort: Cohort, resp):
61-
dj_assert_contains(resp, cohort.image.url)
62-
63-
64-
def test_cohort_start(cohort: Cohort, resp):
65-
dj_assert_contains(resp, date(cohort.start))
66-
67-
68-
def test_cohort_end(cohort: Cohort, resp):
69-
dj_assert_contains(resp, date(cohort.end))
70-
71-
7218
@pytest.fixture
7319
def recorded_live_classes(cohort, fake):
7420
now = timezone.now()
@@ -103,38 +49,12 @@ def future_live_classes(cohort, fake):
10349
]
10450

10551

106-
@pytest.fixture
107-
def resp_with_classes(recorded_live_classes, future_live_classes, cohort, client_with_member):
108-
return client_with_member.get(reverse('cohorts:detail', kwargs={'slug': cohort.slug}))
109-
110-
11152
def test_live_classes_are_sorted(recorded_live_classes, cohort):
11253
recorded_live_classes.sort(key=operator.attrgetter('start'))
11354
db_cohort = facade.find_cohort(slug=cohort.slug)
11455
assert recorded_live_classes == db_cohort.classes
11556

11657

117-
@pytest.mark.freeze_time('2019-01-01 18:00:00')
118-
def test_live_classes_datetime(resp_with_classes, recorded_live_classes):
119-
for live_class in recorded_live_classes:
120-
dj_assert_contains(resp_with_classes, date(live_class.start))
121-
122-
123-
def test_live_classes_descriptions(resp_with_classes, recorded_live_classes):
124-
for live_class in recorded_live_classes:
125-
dj_assert_contains(resp_with_classes, live_class.description)
126-
127-
128-
def test_recorded_live_classes_urls_are_present(resp_with_classes, recorded_live_classes):
129-
for live_class in recorded_live_classes:
130-
dj_assert_contains(resp_with_classes, live_class.get_absolute_url())
131-
132-
133-
def test_future_live_classes_urls_are_absent(resp_with_classes, future_live_classes):
134-
for live_class in future_live_classes:
135-
dj_assert_not_contains(resp_with_classes, live_class.get_absolute_url())
136-
137-
13858
@pytest.fixture
13959
def recorded_webinars(cohort):
14060
now = timezone.now()
@@ -167,34 +87,7 @@ def test_future_webinars_in_cohort(recorded_webinars, future_webinars, cohort):
16787
assert cohort.future_webinars == future_webinars
16888

16989

170-
@pytest.fixture
171-
def resp_with_webnars(recorded_webinars, future_webinars, cohort, client_with_member):
172-
return client_with_member.get(reverse('cohorts:detail', kwargs={'slug': cohort.slug}))
173-
174-
17590
def test_webnars_are_sorted(recorded_webinars: list, cohort):
17691
recorded_webinars.sort(key=operator.attrgetter('start'))
17792
db_cohort = facade.find_cohort(slug=cohort.slug)
17893
assert recorded_webinars == db_cohort.webinars
179-
180-
181-
@pytest.mark.freeze_time('2019-01-01 18:00:00')
182-
def test_webnars_datetime(resp_with_webnars, recorded_webinars):
183-
for webnar in recorded_webinars:
184-
dj_assert_contains(resp_with_webnars, date(webnar.start))
185-
186-
187-
@pytest.mark.parametrize('property_name', 'speaker speaker_title title'.split())
188-
def test_webnars_vimeo(resp_with_webnars, recorded_webinars, property_name):
189-
for webnar in recorded_webinars:
190-
dj_assert_contains(resp_with_webnars, getattr(webnar, property_name))
191-
192-
193-
def test_recorded_webnars_url_are_present(resp_with_webnars, recorded_webinars):
194-
for webnar in recorded_webinars:
195-
dj_assert_contains(resp_with_webnars, webnar.get_absolute_url())
196-
197-
198-
def test_future_webnars_url_are_absent(resp_with_webnars, future_webinars):
199-
for webnar in future_webinars:
200-
dj_assert_not_contains(resp_with_webnars, webnar.get_absolute_url())

pythonpro/cohorts/urls.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
path('webinarios/', views.webinars, name='webinars'),
88
path('webinarios/<slug:slug>/', views.webinar, name='webinar'),
99
path('aulas/<int:pk>/', views.live_class, name='live_class'),
10-
path('<slug:slug>/', views.detail, name='detail'),
1110
]

pythonpro/cohorts/views.py

-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
from pythonpro.memberkit import facade as memberkit_facade
77

88

9-
@login_required
10-
def detail(request, slug):
11-
return render(request, 'cohorts/cohort_detail.html', {'cohort': facade.find_cohort(slug=slug)})
12-
13-
149
@login_required
1510
def webinars(request):
1611
return render(request, 'cohorts/webinars.html', {'webinars': facade.find_recorded_webinars()})

pythonpro/core/templates/core/base.html

+1-17
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,8 @@
5959
<div class="collapse navbar-collapse" id="navbarSupportedContent">
6060
<ul class="navbar-nav mr-auto">
6161
{% if user.is_authenticated %}
62-
<li class="nav-item dropdown">
63-
<a class="nav-link dropdown-toggle" href="#" id="navbarCohorts" role="button"
64-
data-toggle="dropdown"
65-
aria-haspopup="true" aria-expanded="false">
66-
Turmas
67-
</a>
68-
<div class="dropdown-menu bg-dark border-light" aria-labelledby="navbarCohorts">
69-
{% for cohort in ALL_COHORTS %}
70-
<a class="dropdown-item text-light"
71-
href="{{ cohort.get_absolute_url }}">{{ cohort.title }}</a>
72-
{% if not forloop.last %}
73-
<div class="dropdown-divider"></div>
74-
{% endif %}
75-
{% endfor %}
76-
</div>
77-
</li>
7862
<li class="nav-item">
79-
<a class="nav-link" href="https://plataforma.dev.pro.br">Curso</a>
63+
<a class="nav-link" href="https://plataforma.dev.pro.br">Cursos</a>
8064
</li>
8165
<li class="nav-item">
8266
<a class="nav-link" href="{% url 'cohorts:webinars' %}">Webinários</a>

pythonpro/modules/tests/test_module_index_view.py

-12
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ def test_status_code_not_logged(resp_not_logged):
3838
assert resp_not_logged.status_code == 200
3939

4040

41-
def test_module_index_link_not_logged(resp_not_logged):
42-
""" Assert module index link is present when user is not logged """
43-
url = reverse('modules:index')
44-
dj_assert_contains(resp_not_logged, f'href="{url}"')
45-
46-
4741
def test_module_link_not_logged(modules, resp_not_logged):
4842
""" Assert module links are not present when user is not logged """
4943
for module in modules:
@@ -53,12 +47,6 @@ def test_module_link_not_logged(modules, resp_not_logged):
5347
dj_assert_not_contains(resp_not_logged, f'href="{module.get_absolute_url()}"')
5448

5549

56-
def test_module_index_link_logged(resp):
57-
""" Assert module index link is present when user is logged """
58-
url = reverse('modules:index')
59-
dj_assert_contains(resp, f'href="{url}"')
60-
61-
6250
def test_present_attrs(modules, resp_not_logged):
6351
for module in modules:
6452
dj_assert_contains(resp_not_logged, module.title)

pythonpro/settings.py

-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@
151151
'django.contrib.messages.context_processors.messages',
152152
'pythonpro.core.context_processors.global_settings',
153153
'pythonpro.modules.context_processors.global_settings',
154-
'pythonpro.cohorts.context_processors.global_settings',
155154
'pythonpro.analytics.context_processors.posthog_configurations',
156155
],
157156
},

0 commit comments

Comments
 (0)