• 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

68.42
/apps/projects/forms.py
1
from django import forms
1✔
2
from django.conf import settings
1✔
3
from django.contrib.auth import get_user_model
1✔
4
from django.core.exceptions import ValidationError
1✔
5
from django.utils.translation import gettext_lazy as _
1✔
6

7
from adhocracy4.dashboard.forms import ProjectDashboardForm
1✔
8
from adhocracy4.maps import widgets as maps_widgets
1✔
9
from adhocracy4.maps.mixins import PointFormMixin
1✔
10
from adhocracy4.projects.models import Project
1✔
11
from apps.users import fields as user_fields
1✔
12

13
from .models import ModeratorInvite
1✔
14
from .models import ParticipantInvite
1✔
15

16
User = get_user_model()
1✔
17

18

19
class InviteForm(forms.ModelForm):
1✔
20
    accept = forms.CharField(required=False)
1✔
21
    reject = forms.CharField(required=False)
1✔
22

23
    def clean(self):
1✔
24
        data = self.data
×
25
        if "accept" not in data and "reject" not in data:
×
26
            raise ValidationError("Reject or accept")
×
27
        return data
×
28

29
    def is_accepted(self):
1✔
30
        data = self.data
×
31
        return "accept" in data and "reject" not in data
×
32

33

34
class ParticipantInviteForm(InviteForm):
1✔
35
    class Meta:
1✔
36
        model = ParticipantInvite
1✔
37
        fields = ["accept", "reject"]
1✔
38

39

40
class ModeratorInviteForm(InviteForm):
1✔
41
    class Meta:
1✔
42
        model = ModeratorInvite
1✔
43
        fields = ["accept", "reject"]
1✔
44

45

46
class InviteUsersFromEmailForm(forms.Form):
1✔
47
    add_users = user_fields.CommaSeparatedEmailField(
1✔
48
        required=False, label=_("Invite users via email")
49
    )
50

51
    add_users_upload = user_fields.EmailFileField(
1✔
52
        required=False,
53
        label=_("Invite users via file upload"),
54
        help_text=_("Upload a csv file containing email addresses."),
55
    )
56

57
    def __init__(self, *args, **kwargs):
1✔
58
        labels = kwargs.pop("labels", None)
×
59
        super().__init__(*args, **kwargs)
×
60

61
        if labels:
×
62
            self.fields["add_users"].label = labels[0]
×
63
            self.fields["add_users_upload"].label = labels[1]
×
64

65
    def clean(self):
1✔
66
        cleaned_data = super().clean()
×
67
        add_users = self.data.get("add_users")
×
68
        add_users_upload = self.files.get("add_users_upload")
×
69
        if not self.errors and not add_users and not add_users_upload:
×
70
            raise ValidationError(_("Please enter email addresses or upload a file"))
×
71
        return cleaned_data
×
72

73

74
class PointForm(PointFormMixin, ProjectDashboardForm):
1✔
75
    class Meta:
1✔
76
        model = Project
1✔
77
        geo_field = "point"
1✔
78
        fields = [
1✔
79
            "administrative_district",
80
            "point",
81
            "street_name",
82
            "house_number",
83
            "zip_code",
84
        ]
85
        required_for_project_publish = []
1✔
86
        widgets = {
1✔
87
            "point": maps_widgets.MapChoosePointWidget(polygon=settings.BERLIN_POLYGON),
88
        }
89

90
        def get_geojson_properties(self):
1✔
91
            return {"strname": "street_name", "hsnr": "house_number", "plz": "zip_code"}
×
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