Coverage for src/django_resume/views.py: 94%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-10-11 11:20 +0200

1from django.http import HttpRequest, HttpResponse 

2from django.shortcuts import render, get_object_or_404 

3 

4from .models import Resume 

5from .plugins import plugin_registry 

6 

7 

8def cv(request: HttpRequest, slug: str) -> HttpResponse: 

9 resume = get_object_or_404(Resume.objects.select_related("owner"), slug=slug) 

10 edit = bool(dict(request.GET).get("edit", False)) 

11 show_edit_button = True if request.user.is_authenticated and edit else False 

12 context = { 

13 "resume": resume, 

14 "timelines": [], 

15 "projects": [], 

16 # needed to include edit styles in the base template 

17 "show_edit_button": show_edit_button, 

18 } 

19 for plugin in plugin_registry.get_all_plugins(): 

20 context[plugin.name] = plugin.get_context( 

21 request, 

22 plugin.get_data(resume), 

23 resume.pk, 

24 context={}, 

25 edit=show_edit_button, 

26 ) 

27 return render(request, "django_resume/plain/cv.html", context=context) 

28 

29 

30def index(request): 

31 return render(request, "django_resume/index.html")