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

1 from django.http import HttpRequest, HttpResponse

2 from django.shortcuts import render, get_object_or_404

3

4 from .models import Resume

5 from .plugins import plugin_registry

6

7

8 def 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

30 def index(request):

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