forked from pythonprobr/pythonpro-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtopics_views.py
More file actions
29 lines (22 loc) · 1.04 KB
/
topics_views.py
File metadata and controls
29 lines (22 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from django.contrib.auth.decorators import login_required
from django.shortcuts import redirect, render
from django.urls import reverse
from rolepermissions.checkers import has_object_permission
from pythonpro.modules import facade
from pythonpro.modules.models import Content
def content_landing_page(content: Content):
if content.module_slug() in {'pytools', 'django', 'entrevistas-tecnicas'}:
redirect_path = reverse('checkout:webdev_landing_page')
else:
redirect_path = reverse('checkout:bootcamp_lp')
return redirect(redirect_path, permanent=False)
@login_required
def old_detail(request, slug):
topic = facade.get_topic_with_contents(slug=slug)
return redirect(topic.get_absolute_url(), permanent=True)
@login_required
def detail(request, module_slug, topic_slug): # noqa
topic = facade.get_topic_with_contents(slug=topic_slug)
if has_object_permission('access_content', request.user, topic):
return render(request, 'topics/topic_detail.html', {'topic': topic})
return content_landing_page(topic)