• 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

78.87
/apps/budgeting/views.py
1
import django_filters
1✔
2
from django.urls import reverse
1✔
3
from django.utils.translation import gettext_lazy as _
1✔
4

5
from adhocracy4.categories import filters as category_filters
1✔
6
from adhocracy4.exports.views import DashboardExportView
1✔
7
from adhocracy4.filters import filters as a4_filters
1✔
8
from adhocracy4.filters.widgets import DropdownLinkWidget
1✔
9
from adhocracy4.projects.mixins import DisplayProjectOrModuleMixin
1✔
10
from apps.contrib.widgets import AplusOrderingWidget
1✔
11
from apps.ideas import views as idea_views
1✔
12
from apps.organisations.mixins import UserFormViewMixin
1✔
13

14
from . import forms
1✔
15
from . import models
1✔
16

17

18
def get_ordering_choices(view):
1✔
19
    choices = (("-created", _("Most recent")),)
×
20
    if view.module.has_feature("rate", models.Proposal):
×
21
        choices += (("-positive_rating_count", _("Most popular")),)
×
22
    choices += (("-comment_count", _("Most commented")),)
×
23
    return choices
×
24

25

26
class ArchivedWidget(DropdownLinkWidget):
1✔
27
    label = _("Archived")
1✔
28

29
    def __init__(self, attrs=None):
1✔
30
        choices = (
×
31
            ("", _("All")),
32
            ("false", _("No")),
33
            ("true", _("Yes")),
34
        )
35
        super().__init__(attrs, choices)
×
36

37

38
class ProposalFilterSet(a4_filters.DefaultsFilterSet):
1✔
39
    defaults = {"ordering": "-created", "is_archived": "false"}
1✔
40
    category = category_filters.CategoryFilter()
1✔
41
    ordering = a4_filters.DynamicChoicesOrderingFilter(
1✔
42
        choices=get_ordering_choices, widget=AplusOrderingWidget
43
    )
44
    is_archived = django_filters.BooleanFilter(widget=ArchivedWidget)
1✔
45

46
    class Meta:
1✔
47
        model = models.Proposal
1✔
48
        fields = ["category", "is_archived"]
1✔
49

50

51
class ProposalListView(idea_views.AbstractIdeaListView, DisplayProjectOrModuleMixin):
1✔
52
    model = models.Proposal
1✔
53
    filter_set = ProposalFilterSet
1✔
54

55
    def dispatch(self, request, **kwargs):
1✔
56
        self.mode = request.GET.get("mode", "map")
×
57
        if self.mode == "map":
×
58
            self.paginate_by = 0
×
59
        return super().dispatch(request, **kwargs)
×
60

61

62
class ProposalDetailView(idea_views.AbstractIdeaDetailView):
1✔
63
    model = models.Proposal
1✔
64
    queryset = (
1✔
65
        models.Proposal.objects.annotate_positive_rating_count().annotate_negative_rating_count()
66
    )
67
    permission_required = "a4_candy_budgeting.view_proposal"
1✔
68

69

70
class ProposalCreateView(idea_views.AbstractIdeaCreateView, UserFormViewMixin):
1✔
71
    model = models.Proposal
1✔
72
    form_class = forms.ProposalForm
1✔
73
    permission_required = "a4_candy_budgeting.add_proposal"
1✔
74
    template_name = "a4_candy_budgeting/proposal_create_form.html"
1✔
75

76

77
class ProposalUpdateView(idea_views.AbstractIdeaUpdateView, UserFormViewMixin):
1✔
78
    model = models.Proposal
1✔
79
    form_class = forms.ProposalForm
1✔
80
    permission_required = "a4_candy_budgeting.change_proposal"
1✔
81
    template_name = "a4_candy_budgeting/proposal_update_form.html"
1✔
82

83

84
class ProposalDeleteView(idea_views.AbstractIdeaDeleteView):
1✔
85
    model = models.Proposal
1✔
86
    success_message = _("Your budget request has been deleted")
1✔
87
    permission_required = "a4_candy_budgeting.change_proposal"
1✔
88
    template_name = "a4_candy_budgeting/proposal_confirm_delete.html"
1✔
89

90

91
class ProposalModerateView(idea_views.AbstractIdeaModerateView):
1✔
92
    model = models.Proposal
1✔
93
    permission_required = "a4_candy_budgeting.moderate_proposal"
1✔
94
    template_name = "a4_candy_budgeting/proposal_moderate_form.html"
1✔
95
    moderateable_form_class = forms.ProposalModerateForm
1✔
96

97

98
class ProposalDashboardExportView(DashboardExportView):
1✔
99
    template_name = "a4exports/export_dashboard.html"
1✔
100

101
    def get_context_data(self, **kwargs):
1✔
102
        context = super().get_context_data(**kwargs)
×
103
        context["export"] = reverse(
×
104
            "a4dashboard:budgeting-export",
105
            kwargs={
106
                "organisation_slug": self.module.project.organisation.slug,
107
                "module_slug": self.module.slug,
108
            },
109
        )
110
        context["comment_export"] = reverse(
×
111
            "a4dashboard:budgeting-comment-export",
112
            kwargs={
113
                "organisation_slug": self.module.project.organisation.slug,
114
                "module_slug": self.module.slug,
115
            },
116
        )
117
        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