Skip to content

Commit 325229b

Browse files
renzonrenzon
authored andcommitted
Showing only recorded webinars on index page
part of #1681
1 parent 8092a6f commit 325229b

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

pythonpro/cohorts/facade.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,20 @@ def calculate_most_recent_cohort_path() -> str:
4646
def find_webinars():
4747
"""
4848
Retrieve Webinars from database ordered by date desc
49-
:return: List of webinars
49+
:return: Tuple of webinars
5050
"""
5151
return tuple(_Webinar.objects.order_by('-start'))
5252

5353

54+
def find_recorded_webinars():
55+
"""
56+
Retrieve recorded Webinars from database ordered by date desc.
57+
A recorded Webinar has vimeo_id not empty
58+
:return: Tuple of webinars
59+
"""
60+
return tuple(_Webinar.objects.order_by('-start').exclude(vimeo_id__exact=''))
61+
62+
5463
def find_webinar(slug):
5564
"""
5665
Retrieve Webinar by its slug

pythonpro/cohorts/tests/test_live_class_detail.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ def test_pending_live_class_msg(resp_video_not_recorded):
5757
'Ainda não temos máquina do tempo, essa aula ainda não foi gravada'
5858
)
5959

60-
61-
dj_assert_contains(
62-
resp_video_not_recorded,
63-
'Retornar à página da turma'
64-
)
60+
dj_assert_contains(
61+
resp_video_not_recorded,
62+
'Retornar à página da turma'
63+
)
6564

6665

6766
def test_vimeo_player_not_present(resp_video_not_recorded):

pythonpro/cohorts/tests/test_webinar_detail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def webinar(cohort) -> Webinar:
1313
image = SimpleUploadedFile(name='renzo-nuccitelli.jpeg', content=open(img_path, 'rb').read(),
1414
content_type='image/png')
15-
return mommy.make(Webinar, cohort=cohort, image=image)
15+
return mommy.make(Webinar, cohort=cohort, image=image, vimeo_id='1')
1616

1717

1818
@pytest.fixture

pythonpro/cohorts/tests/test_webinars.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,22 @@ def test_basic_contents(resp, webinars, property_name):
3232
def test_absolute_url(resp, webinars):
3333
for webinar in webinars:
3434
dj_assert_contains(resp, webinar.get_absolute_url())
35+
36+
37+
@pytest.fixture
38+
def not_recorded_webinars(webinars):
39+
first_two_webinars = webinars[:2]
40+
for w in first_two_webinars:
41+
w.vimeo_id = ''
42+
w.save()
43+
return first_two_webinars
44+
45+
46+
@pytest.fixture
47+
def resp_not_recorded_webinars(client_with_user, not_recorded_webinars):
48+
return client_with_user.get(reverse('cohorts:webinars'), secure=True)
49+
50+
51+
def test_not_recorded_webinar_url_not_present(resp_not_recorded_webinars, not_recorded_webinars):
52+
for webinar in not_recorded_webinars:
53+
dj_assert_not_contains(resp_not_recorded_webinars, webinar.get_absolute_url())

pythonpro/cohorts/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def detail(request, slug):
1414

1515
@login_required
1616
def webinars(request):
17-
return render(request, 'cohorts/webinars.html', {'webinars': facade.find_webinars()})
17+
return render(request, 'cohorts/webinars.html', {'webinars': facade.find_recorded_webinars()})
1818

1919

2020
@login_required

0 commit comments

Comments
 (0)