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

liqd / adhocracy-plus / 14999335889

13 May 2025 02:31PM UTC coverage: 89.286% (+0.003%) from 89.283%
14999335889

push

github

m4ra
docs: add steps for old point to new django GIS point

6050 of 6776 relevant lines covered (89.29%)

1.79 hits per line

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

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

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

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

16
User = get_user_model()
2✔
17

18

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

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

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

33

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

39

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

45

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

51
    add_users_upload = user_fields.EmailFileField(
2✔
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):
2✔
58
        labels = kwargs.pop("labels", None)
2✔
59
        super().__init__(*args, **kwargs)
2✔
60

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

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

73

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

90
        def get_geojson_properties(self):
2✔
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

© 2026 Coveralls, Inc