• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

liqd / adhocracy-plus / 18908688697

29 Oct 2025 12:59PM UTC coverage: 44.622% (-44.5%) from 89.135%
18908688697

Pull #2986

github

web-flow
Merge 1dfde8ee7 into 445e1d498
Pull Request #2986: Draft: Speed up Github Ci Tests

3012 of 6750 relevant lines covered (44.62%)

0.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.4
/apps/documents/views.py
1
from django.http import Http404
1✔
2
from django.urls import reverse
1✔
3
from django.utils.functional import cached_property
1✔
4
from django.utils.translation import gettext_lazy as _
1✔
5
from django.views import generic
1✔
6
from django_ckeditor_5.widgets import CKEditor5Widget
1✔
7

8
from adhocracy4.dashboard import mixins as dashboard_mixins
1✔
9
from adhocracy4.exports.views import DashboardExportView
1✔
10
from adhocracy4.projects.mixins import DisplayProjectOrModuleMixin
1✔
11
from adhocracy4.projects.mixins import ProjectMixin
1✔
12
from adhocracy4.rules import mixins as rules_mixins
1✔
13

14
from . import models
1✔
15

16

17
class DocumentDashboardView(
1✔
18
    ProjectMixin,
19
    dashboard_mixins.DashboardBaseMixin,
20
    dashboard_mixins.DashboardComponentMixin,
21
    generic.TemplateView,
22
):
23
    template_name = "a4_candy_documents/document_dashboard.html"
1✔
24
    permission_required = "a4projects.change_project"
1✔
25

26
    def get_permission_object(self):
1✔
27
        return self.project
×
28

29
    def get_context_data(self, **kwargs):
1✔
30
        context = super().get_context_data(**kwargs)
×
31
        widget = CKEditor5Widget(config_name="image-editor")
×
32
        context["ckeditor_media"] = widget.media
×
33
        return context
×
34

35

36
class ChapterDetailView(
1✔
37
    ProjectMixin,
38
    rules_mixins.PermissionRequiredMixin,
39
    generic.DetailView,
40
    DisplayProjectOrModuleMixin,
41
):
42
    model = models.Chapter
1✔
43
    permission_required = "a4_candy_documents.view_chapter"
1✔
44
    get_context_from_object = True
1✔
45

46
    def get_context_data(self, **kwargs):
1✔
47
        context = super().get_context_data(**kwargs)
×
48
        context["chapter_list"] = self.chapter_list
×
49
        return context
×
50

51
    @cached_property
1✔
52
    def extends(self):
1✔
53
        if self.url_name == "module-detail":
×
54
            return "a4modules/module_detail.html"
×
55
        if self.url_name == "chapter-detail":
×
56
            if self.module.is_in_module_cluster:
×
57
                return "a4modules/module_detail.html"
×
58
        return "a4projects/project_detail.html"
×
59

60
    @property
1✔
61
    def chapter_list(self):
1✔
62
        return models.Chapter.objects.filter(module=self.module)
×
63

64

65
class DocumentDetailView(ChapterDetailView):
1✔
66
    get_context_from_object = False
1✔
67

68
    def get_object(self):
1✔
69
        first_chapter = models.Chapter.objects.filter(module=self.module).first()
×
70

71
        if not first_chapter:
×
72
            raise Http404(_("Document has no chapters defined."))
×
73
        return first_chapter
×
74

75

76
class ParagraphDetailView(
1✔
77
    ProjectMixin, rules_mixins.PermissionRequiredMixin, generic.DetailView
78
):
79
    model = models.Paragraph
1✔
80
    permission_required = "a4_candy_documents.view_paragraph"
1✔
81

82

83
class DocumentDashboardExportView(DashboardExportView):
1✔
84
    template_name = "a4exports/export_dashboard.html"
1✔
85

86
    def get_context_data(self, **kwargs):
1✔
87
        context = super().get_context_data(**kwargs)
×
88
        context["comment_export"] = reverse(
×
89
            "a4dashboard:document-comment-export",
90
            kwargs={
91
                "organisation_slug": self.module.project.organisation.slug,
92
                "module_slug": self.module.slug,
93
            },
94
        )
95
        return context
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc