• 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.7
/apps/debate/models.py
1
from autoslug import AutoSlugField
1✔
2
from django.contrib.contenttypes.fields import GenericRelation
1✔
3
from django.db import models
1✔
4
from django.urls import reverse
1✔
5
from django.utils.functional import cached_property
1✔
6
from django.utils.translation import gettext_lazy as _
1✔
7

8
from adhocracy4.comments import models as comment_models
1✔
9
from adhocracy4.models import query
1✔
10
from adhocracy4.modules import models as module_models
1✔
11

12

13
class SubjectQuerySet(query.CommentableQuerySet):
1✔
14
    pass
1✔
15

16

17
class Subject(module_models.Item):
1✔
18
    slug = AutoSlugField(populate_from="name", unique=True)
1✔
19
    name = models.CharField(
1✔
20
        max_length=120, verbose_name=_("Title"), help_text=_("max 120 characters")
21
    )
22
    description = models.CharField(
1✔
23
        max_length=350,
24
        blank=True,
25
        verbose_name=_("Description"),
26
        help_text=_(
27
            "In addition to the title, you can insert an optional "
28
            "explanatory text (max. 350 char.). This field is only "
29
            "shown in the participation if it is filled out."
30
        ),
31
    )
32

33
    comments = GenericRelation(
1✔
34
        comment_models.Comment,
35
        related_query_name="subject",
36
        object_id_field="object_pk",
37
    )
38

39
    objects = SubjectQuerySet.as_manager()
1✔
40

41
    class Meta:
1✔
42
        ordering = ["-created"]
1✔
43

44
    @property
1✔
45
    def reference_number(self):
1✔
46
        return "{:d}-{:05d}".format(self.created.year, self.pk)
×
47

48
    def __str__(self):
1✔
49
        return self.name
×
50

51
    def get_absolute_url(self):
1✔
52
        return reverse(
×
53
            "a4_candy_debate:subject-detail",
54
            kwargs=dict(
55
                organisation_slug=self.project.organisation.slug,
56
                pk="{:05d}".format(self.pk),
57
                year=self.created.year,
58
            ),
59
        )
60

61
    @cached_property
1✔
62
    def comment_creator_count(self):
1✔
63
        creators = self.comments.values_list("creator", flat=True)
×
64
        comment_creator_count = len(list(set(creators)))
×
65
        return comment_creator_count
×
66

67
    @cached_property
1✔
68
    def comment_creator_count_minus_three(self):
1✔
69
        if self.comment_creator_count <= 3:
×
70
            return None
×
71
        else:
72
            return self.comment_creator_count - 3
×
73

74
    @cached_property
1✔
75
    def last_three_creators(self):
1✔
76
        comments = (
×
77
            self.comments.filter(
78
                is_censored=False,
79
                is_removed=False,
80
            )
81
            .select_related("creator")
82
            .order_by("-created")
83
        )
84

85
        last_three_creators = []
×
86
        if comments:
×
87
            for comment in comments:
×
88
                if comment.creator not in last_three_creators:
×
89
                    last_three_creators.append(comment.creator)
×
90
                if len(last_three_creators) >= 3:
×
91
                    break
×
92

93
        return last_three_creators
×
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