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

gcivil-nyu-org / team4-wed-spring25 / 459

09 Apr 2025 11:04PM UTC coverage: 97.595% (+0.9%) from 96.678%
459

cron

travis-pro

web-flow
Merge pull request #226 from gcivil-nyu-org/develop

Develop

202 of 208 new or added lines in 16 files covered. (97.12%)

1 existing line in 1 file now uncovered.

974 of 998 relevant lines covered (97.6%)

0.98 hits per line

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

95.45
/profiles/forms.py
1
from django import forms
1✔
2
import re
1✔
3
from .models import UserProfile, PetProfile
1✔
4

5

6
class UserProfileForm(forms.ModelForm):
1✔
7
    website = forms.URLField(
1✔
8
        required=False,
9
        widget=forms.URLInput(
10
            attrs={"class": "form-control", "placeholder": "https://..."}
11
        ),
12
    )
13
    phone_number = forms.CharField(
1✔
14
        required=False,
15
        max_length=15,
16
        widget=forms.TextInput(
17
            attrs={
18
                "class": "form-control",
19
                "placeholder": "Optional",
20
                "id": "phone_number",
21
            }
22
        ),
23
    )
24

25
    class Meta:
1✔
26
        model = UserProfile
1✔
27
        fields = [
1✔
28
            "profile_picture",
29
            "location",
30
            "phone_number",
31
            "website",
32
            "bio",
33
            "signature",
34
        ]
35
        widgets = {
1✔
36
            "location": forms.TextInput(attrs={"class": "form-control"}),
37
            "bio": forms.Textarea(attrs={"class": "form-control", "rows": 3}),
38
            "signature": forms.TextInput(attrs={"class": "form-control"}),
39
            "profile_picture": forms.ClearableFileInput(
40
                attrs={"class": "form-control"}
41
            ),
42
        }
43

44
    def clean_phone_number(self):
1✔
45
        phone_number = self.cleaned_data.get("phone_number")
1✔
46
        if phone_number and phone_number.strip():
1✔
47
            if not re.fullmatch(r"^\d+$", phone_number.strip()):
1✔
NEW
48
                raise forms.ValidationError("Phone numbers can only contain numbers!")
×
49
        return phone_number
1✔
50

51

52
class PetProfileForm(forms.ModelForm):
1✔
53
    age = forms.IntegerField(
1✔
54
        min_value=0,
55
        required=False,
56
        widget=forms.NumberInput(attrs={"class": "form-control"}),
57
    )
58

59
    class Meta:
1✔
60
        model = PetProfile
1✔
61
        fields = ["name", "breed", "age", "pet_picture", "personality", "favorite_food"]
1✔
62
        widgets = {
1✔
63
            "name": forms.TextInput(attrs={"class": "form-control"}),
64
            "breed": forms.TextInput(attrs={"class": "form-control"}),
65
            "personality": forms.Textarea(attrs={"class": "form-control", "rows": 3}),
66
            "favorite_food": forms.TextInput(attrs={"class": "form-control"}),
67
            "pet_picture": forms.ClearableFileInput(attrs={"class": "form-control"}),
68
        }
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