• 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/account/forms.py
1
from django import forms
×
2
from django.urls import reverse
×
3
from django.utils.html import mark_safe
×
4
from django.utils.translation import gettext_lazy as _
×
5

6
from apps.organisations.models import OrganisationTermsOfUse
×
7
from apps.users.models import User
×
8

9

10
class ProfileForm(forms.ModelForm):
×
11
    class Meta:
×
12
        model = User
×
13
        fields = [
×
14
            "username",
15
            "_avatar",
16
            "bio",
17
            "homepage",
18
            "facebook_handle",
19
            "twitter_handle",
20
            "get_notifications",
21
            "get_newsletters",
22
            "language",
23
        ]
24

25
    def clean_username(self):
×
26
        username = self.cleaned_data["username"]
×
27
        try:
×
28
            user = User.objects.get(username__iexact=username)
×
29
            if user != self.instance:
×
30
                raise forms.ValidationError(
×
31
                    User._meta.get_field("username").error_messages["unique"]
32
                )
33
        except User.DoesNotExist:
×
34
            pass
×
35

36
        try:
×
37
            user = User.objects.get(email__iexact=username)
×
38
            if user != self.instance:
×
39
                raise forms.ValidationError(
×
40
                    User._meta.get_field("username").error_messages["used_as_email"]
41
                )
42
        except User.DoesNotExist:
×
43
            pass
×
44

45
        return username
×
46

47

48
class AccountDeletionForm(forms.Form):
×
49
    password = forms.CharField(
×
50
        label=_("Password"),
51
        strip=False,
52
        widget=forms.PasswordInput(attrs={"autocomplete": "new-password", "class": "password-toggle"}),
53
    )
54

55

56
class OrganisationTermsOfUseForm(forms.ModelForm):
×
57
    class Meta:
×
58
        model = OrganisationTermsOfUse
×
59
        exclude = ()
×
60

61

62
class OrganisationsTermsOfUseInlineFormSet(forms.BaseInlineFormSet):
×
63
    def __init__(self, *args, **kwargs):
×
64
        super().__init__(*args, **kwargs)
×
65
        for form in self.forms:
×
66
            organisation = form.instance.organisation
×
67
            form.fields["has_agreed"].label = self._get_terms_of_use_label(organisation)
×
68

69
    def _get_terms_of_use_label(self, organisation):
×
70
        label_text = _(
×
71
            "Yes, I have read and agree to this organisation's " "{}terms of use{}."
72
        )
73
        url = reverse(
×
74
            "organisation-terms-of-use", kwargs={"organisation_slug": organisation.slug}
75
        )
76
        label = label_text.format('<a href="' + url + '" target="_blank">', "</a>")
×
77
        return mark_safe(label)
×
78

79

80
OrganisationTermsOfUseFormSet = forms.inlineformset_factory(
×
81
    User,
82
    OrganisationTermsOfUse,
83
    form=OrganisationTermsOfUseForm,
84
    formset=OrganisationsTermsOfUseInlineFormSet,
85
    fields=["has_agreed"],
86
    can_delete=False,
87
    extra=0,
88
)
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