Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ raven = "*"
Pillow = "*"
ipython = "*"
django-sitemaps = "*"
django-role-permissions = "*"

[dev-packages]
faker = "*"
Expand Down
53 changes: 37 additions & 16 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
release: python manage.py sync_roles
release: python manage.py migrate --noinput
web: gunicorn pythonpro.wsgi --log-file -
3 changes: 3 additions & 0 deletions pythonpro/cohorts/templates/cohorts/cohort_detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'core/base.html' %}
{% load static %}
{% load permission_tags %}

{% block title %}Turma {{ cohort.title }}{% endblock %}

Expand Down Expand Up @@ -29,6 +30,7 @@ <h1 class="mt-4 mb-3">Turma {{ cohort.title }}</h1>
</dd>
</div>
</div>
{% if user|can:'access_cohorts' %}
<div class="row">
<div class="col">
<h2 class="mt-5">Instruções</h2>
Expand All @@ -42,6 +44,7 @@ <h2 class="mt-5">Instruções</h2>
</dd>
</div>
</div>
{% endif %}
<div class="row">
<div class="col">
<h2 class="mt-5">Webinários</h2>
Expand Down
16 changes: 16 additions & 0 deletions pythonpro/cohorts/templates/cohorts/live_class_landing_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends 'core/base.html' %}
{% load static %}

{% block title %}Inscrição Curso Python Pro{% endblock %}

{% block body %}
<div class="container">
<div class="row">
<div class="col">
<h1 class="mt-4 mb-3">Gravação de aula ao vivo Exclusivo para Membros</h1>
<p>Explicar aqui</p>
</div>
</div>
</div>

{% endblock body %}
16 changes: 16 additions & 0 deletions pythonpro/cohorts/templates/cohorts/webinar_landing_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends 'core/base.html' %}
{% load static %}

{% block title %}Inscrição Curso Python Pro{% endblock %}

{% block body %}
<div class="container">
<div class="row">
<div class="col">
<h1 class="mt-4 mb-3">Webinário Exclusivo para Membros</h1>
<p>Explicar aqui</p>
</div>
</div>
</div>

{% endblock body %}
1 change: 0 additions & 1 deletion pythonpro/cohorts/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
@pytest.fixture
def cohort(client, django_user_model):
user = mommy.make(django_user_model)
client.force_login(user)
image = SimpleUploadedFile(name='renzo-nuccitelli.png', content=open(img_path, 'rb').read(),
content_type='image/png')
cohort = mommy.make(Cohort, slug='guido-van-rossum', title='Guido van Rossum', students=[user], image=image)
Expand Down
12 changes: 6 additions & 6 deletions pythonpro/cohorts/tests/test_cohorts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


@pytest.fixture
def resp(client, cohort):
return client.get(reverse('cohorts:detail', kwargs={'slug': cohort.slug}), secure=True)
def resp(client_with_member, cohort):
return client_with_member.get(reverse('cohorts:detail', kwargs={'slug': cohort.slug}), secure=True)


@pytest.fixture
Expand Down Expand Up @@ -89,8 +89,8 @@ def live_classes(cohort, fake):


@pytest.fixture
def resp_with_classes(live_classes, cohort, client):
return client.get(reverse('cohorts:detail', kwargs={'slug': cohort.slug}), secure=True)
def resp_with_classes(live_classes, cohort, client_with_member):
return client_with_member.get(reverse('cohorts:detail', kwargs={'slug': cohort.slug}), secure=True)


def test_live_classes_are_sorted(live_classes: list, cohort):
Expand All @@ -115,8 +115,8 @@ def test_live_classes_urls(resp_with_classes, live_classes):


@pytest.fixture
def resp_with_webinars(webinars, cohort, client):
return client.get(reverse('cohorts:detail', kwargs={'slug': cohort.slug}), secure=True)
def resp_with_webinars(webinars, cohort, client_with_member):
return client_with_member.get(reverse('cohorts:detail', kwargs={'slug': cohort.slug}), secure=True)


def test_webinars_are_sorted(webinars: list, cohort):
Expand Down
26 changes: 22 additions & 4 deletions pythonpro/cohorts/tests/test_live_class_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from django.urls import reverse
from model_mommy import mommy

from pythonpro.cohorts.models import Cohort, LiveClass, Webinar
from pythonpro.django_assertions import dj_assert_contains
from pythonpro.cohorts.models import Cohort, LiveClass
from pythonpro.django_assertions import dj_assert_contains, dj_assert_template_used


@pytest.fixture
Expand All @@ -21,8 +21,8 @@ def live_class(db, cohort, fake) -> LiveClass:


@pytest.fixture
def resp(client_with_user, live_class: Webinar):
return client_with_user.get(reverse('cohorts:live_class', kwargs={'pk': live_class.id}), secure=True)
def resp(client_with_member, live_class: LiveClass):
return client_with_member.get(reverse('cohorts:live_class', kwargs={'pk': live_class.id}), secure=True)


def test_logged_user(resp):
Expand All @@ -43,5 +43,23 @@ def test_cohort_title(cohort, resp):
dj_assert_contains(resp, cohort.title)


@pytest.fixture
def resp_client(client_with_client, live_class: LiveClass):
return client_with_client.get(reverse('cohorts:live_class', kwargs={'pk': live_class.id}), secure=True)


def test_live_class_landing_for_client(cohort, resp_client):
dj_assert_template_used(resp_client, 'cohorts/live_class_landing_page.html')


@pytest.fixture
def resp_lead(client_with_lead, live_class: LiveClass):
return client_with_lead.get(reverse('cohorts:live_class', kwargs={'pk': live_class.id}), secure=True)


def test_live_class_landing_for_lead(cohort, resp_lead):
dj_assert_template_used(resp_lead, 'cohorts/live_class_landing_page.html')


def test_cohort_url(cohort: Cohort, resp):
dj_assert_contains(resp, cohort.get_absolute_url())
24 changes: 21 additions & 3 deletions pythonpro/cohorts/tests/test_webinar_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from pythonpro.cohorts.models import Webinar
from pythonpro.cohorts.tests.conftest import img_path
from pythonpro.django_assertions import dj_assert_contains
from pythonpro.django_assertions import dj_assert_contains, dj_assert_template_used


@pytest.fixture
Expand All @@ -16,8 +16,8 @@ def webinar(cohort) -> Webinar:


@pytest.fixture
def resp(client_with_user, webinar: Webinar):
return client_with_user.get(reverse('cohorts:webinar', kwargs={'slug': webinar.slug}), secure=True)
def resp(client_with_member, webinar: Webinar):
return client_with_member.get(reverse('cohorts:webinar', kwargs={'slug': webinar.slug}), secure=True)


def test_logged_user(resp):
Expand All @@ -32,3 +32,21 @@ def test_link_unavailable_for_non_users(client):
@pytest.mark.parametrize('property_name', 'speaker speaker_title title description vimeo_id discourse_topic_id'.split())
def test_basic_contents(resp, webinar, property_name):
dj_assert_contains(resp, getattr(webinar, property_name))


@pytest.fixture
def resp_client(client_with_client, webinar: Webinar):
return client_with_client.get(reverse('cohorts:webinar', kwargs={'slug': webinar.slug}), secure=True)


def test_webinar_landing_for_client(cohort, resp_client):
dj_assert_template_used(resp_client, 'cohorts/webinar_landing_page.html')


@pytest.fixture
def resp_lead(client_with_lead, webinar: Webinar):
return client_with_lead.get(reverse('cohorts:webinar', kwargs={'slug': webinar.slug}), secure=True)


def test_webinar_landing_for_lead(cohort, resp_lead):
dj_assert_template_used(resp_lead, 'cohorts/webinar_landing_page.html')
6 changes: 6 additions & 0 deletions pythonpro/cohorts/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
from rolepermissions.checkers import has_permission

from pythonpro.cohorts import facade
from pythonpro.core.roles import access_cohorts


@login_required
Expand All @@ -16,9 +18,13 @@ def webinars(request):

@login_required
def webinar(request, slug):
if not has_permission(request.user, access_cohorts):
return render(request, 'cohorts/webinar_landing_page.html')
return render(request, 'cohorts/webinar_detail.html', {'webinar': facade.find_webinar(slug=slug)})


@login_required
def live_class(request, pk):
if not has_permission(request.user, access_cohorts):
return render(request, 'cohorts/live_class_landing_page.html')
return render(request, 'cohorts/live_class_detail.html', {'live_class': facade.find_live_class(pk=pk)})
25 changes: 25 additions & 0 deletions pythonpro/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from faker import Faker
from model_mommy import mommy
from rolepermissions.roles import assign_role


@pytest.fixture
Expand All @@ -13,3 +14,27 @@ def client_with_user(client, django_user_model):
user = mommy.make(django_user_model)
client.force_login(user)
return client


@pytest.fixture
def client_with_lead(client, django_user_model):
user = mommy.make(django_user_model)
assign_role(user, 'lead')
client.force_login(user)
return client


@pytest.fixture
def client_with_member(client, django_user_model):
user = mommy.make(django_user_model)
assign_role(user, 'member')
client.force_login(user)
return client


@pytest.fixture
def client_with_client(client, django_user_model):
user = mommy.make(django_user_model)
assign_role(user, 'client')
client.force_login(user)
return client
Loading