• 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

0.0
/apps/newsletters/forms.py
1
from django import forms
×
2
from django.apps import apps
×
3
from django.conf import settings
×
4
from django.utils.translation import gettext_lazy as _
×
5

6
from adhocracy4.projects.models import Project
×
7

8
from . import models
×
9

10
Organisation = apps.get_model(settings.A4_ORGANISATIONS_MODEL)
×
11

12

13
class RestrictedNewsletterForm(forms.ModelForm):
×
14
    """Hide receiver choices - only show project follows."""
15

16
    class Meta:
×
17
        model = models.Newsletter
×
18
        fields = [
×
19
            "sender_name",
20
            "sender",
21
            "project",
22
            "receivers",
23
            "organisation",
24
            "subject",
25
            "body",
26
        ]
27
        help_texts = {
×
28
            "body": _(
29
                "If you add an image, please ensure to set the width "
30
                "no larger than 650px and to provide an alternate text "
31
                "of the image. An alternate text serves as a textual "
32
                "description of the image content and is read out by "
33
                "screen readers. Describe the image in approx. 80 characters. "
34
                "Example: A busy square with people in summer."
35
            ),
36
        }
37

38
    def __init__(self, user=None, organisation=None, *args, **kwargs):
×
39
        super().__init__(*args, **kwargs)
×
40

41
        self.fields["receivers"].widget = forms.HiddenInput()
×
42

43
        project_qs = Project.objects
×
44
        if organisation:
×
45
            project_qs = Project.objects.filter(organisation=organisation.id)
×
46

47
        self.fields["project"] = forms.ModelChoiceField(
×
48
            label=_("Project"), queryset=project_qs, required=False, empty_label=None
49
        )
50
        self.fields["project"].label = _(
×
51
            "Receivers are all users " "which follow the following project:"
52
        )
53

54
        self.fields["organisation"] = forms.ModelChoiceField(
×
55
            label=_("Organisation"),
56
            queryset=Organisation.objects,
57
            required=False,
58
            empty_label=None,
59
        )
60

61
    def clean(self):
×
62
        cleaned_data = super().clean()
×
63
        if int(
×
64
            cleaned_data.get("receivers")
65
        ) == models.PROJECT and not cleaned_data.get("project"):
66
            self.add_error("project", _("Select a Project"))
×
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