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

gcivil-nyu-org / INT2-Monday-Spring2024-Team-2 / 497

25 Mar 2024 10:26PM UTC coverage: 90.028% (-3.4%) from 93.396%
497

cron

travis-pro

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

merge dev to master

257 of 410 new or added lines in 15 files covered. (62.68%)

78 existing lines in 5 files now uncovered.

957 of 1063 relevant lines covered (90.03%)

1.65 hits per line

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

97.06
/TutorFilter/forms.py
1
from django import forms
2✔
2
from django.forms import ModelForm
2✔
3
from TutorRegister.models import ProfileT, Expertise, TutoringSession
2✔
4
from Dashboard.choices import EXPERTISE_CHOICES
2✔
5
from django.utils import timezone
2✔
6

7

8
class TutorFilterForm(forms.Form):
2✔
9
    # username = forms.CharField(required=False)
10
    # email = forms.EmailField(required=False)
11
    MODE_CHOICES = [
2✔
12
        ("..", ".."),
13
        ("inperson", "In-person"),
14
        ("remote", "Remote"),
15
        ("both", "Both"),
16
    ]
17

18
    GRADE_CHOICE = [
2✔
19
        ("..", ".."),
20
        ("freshman", "Freshman"),
21
        ("sophomore", "Sophomore"),
22
        ("junior", "Junior"),
23
        ("senior", "Senior"),
24
        ("grad", "Graduate Student"),
25
        ("phd", "PhD Student"),
26
    ]
27

28
    EXPERTISE_CHOICES = [
2✔
29
        ("..", ".."),
30
        ("math", "Mathematics"),
31
        ("algebra", "Algebra"),
32
        ("calculus", "Calculus"),
33
        ("computer_sci", "Computer Science"),
34
        ("elementary_math", "Elementary Math"),
35
        ("geometry", "Geometry"),
36
        ("high_school_math", "High School Math"),
37
        ("regents_math", "Regents Math"),
38
        ("act", "ACT"),
39
        ("gmat", "GMAT"),
40
        ("gre", "GRE"),
41
        ("ielts", "IELTS"),
42
        ("lsat", "LSAT"),
43
        ("sat", "SAT"),
44
        ("toefl", "TOEFL"),
45
        ("esl", "ESL"),
46
        ("economics", "Economics"),
47
        ("elementry_reading", "Elementary Reading"),
48
        ("history", "History"),
49
        ("english", "English"),
50
        ("social_studies", "Social Studies"),
51
        ("writing", "Writing"),
52
        ("biology", "Biology"),
53
        ("physics", "Physics"),
54
        ("arabic", "Arabic"),
55
        ("chinese", "Chinese"),
56
        ("french", "French"),
57
        ("italian", "Italian"),
58
        ("german", "German"),
59
        ("russian", "Russian"),
60
        ("spanish", "Spanish"),
61
        ("cello", "Cello"),
62
        ("piano", "Piano"),
63
        ("singing", "Singing"),
64
        ("violin", "Violin"),
65
    ]
66

67
    preferred_mode = forms.ChoiceField(
2✔
68
        choices=MODE_CHOICES,
69
        widget=forms.Select(
70
            attrs={"class": "form-select", "style": "margin-bottom: 10px;"}
71
        ),
72
        required=False,
73
    )
74
    grade = forms.ChoiceField(
2✔
75
        choices=GRADE_CHOICE,
76
        widget=forms.Select(
77
            attrs={"class": "form-select", "style": "margin-bottom: 10px;"}
78
        ),
79
        required=False,
80
    )
81

82
    expertise = forms.ChoiceField(
2✔
83
        choices=EXPERTISE_CHOICES,
84
        widget=forms.Select(
85
            attrs={"class": "form-select", "style": "margin-bottom: 10px;"}
86
        ),
87
        required=False,
88
    )
89

90
    zipcode = forms.CharField(
2✔
91
        max_length=255,
92
        widget=forms.TextInput(
93
            attrs={"class": "form-control", "style": "margin-bottom: 10px;"}
94
        ),
95
        required=False,
96
    )
97
    salary_max = forms.IntegerField(
2✔
98
        widget=forms.NumberInput(
99
            attrs={"class": "form-control", "style": "margin-bottom: 10px;"}
100
        ),
101
        required=False,
102
    )
103

104

105
class TutoringSessionRequestForm(forms.ModelForm):
2✔
106
    subject = forms.ChoiceField(
2✔
107
        choices=[], widget=forms.Select(attrs={"class": "form-select"})
108
    )
109
    tutoring_mode = forms.ChoiceField(
2✔
110
        choices=[], widget=forms.Select(attrs={"class": "form-select"})
111
    )
112

113
    def __init__(self, *args, tutor_user=None, **kwargs):
2✔
114
        super().__init__(*args, **kwargs)
2✔
115

116
        available_subject_choices = []
2✔
117
        if tutor_user:
2✔
118
            tutor_profile = ProfileT.objects.filter(user=tutor_user).first()
2✔
119
            expert_subjects = Expertise.objects.filter(user=tutor_user).values_list(
2✔
120
                "subject", flat=True
121
            )
122
            available_subject_choices = [
2✔
123
                choice for choice in EXPERTISE_CHOICES if choice[0] in expert_subjects
124
            ]
125

126
            self.fields["subject"].choices = available_subject_choices
2✔
127
            if tutor_profile:
2✔
128
                if tutor_profile.preferred_mode == "both":
2✔
NEW
129
                    mode_choices = [
×
130
                        ("inperson", "In Person"),
131
                        ("remote", "Remote"),
132
                        ("both", "Both"),
133
                    ]
134
                else:
135
                    mode_choices = [
2✔
136
                        (
137
                            tutor_profile.preferred_mode,
138
                            tutor_profile.preferred_mode.capitalize(),
139
                        ),
140
                    ]
141

142
                self.fields["tutoring_mode"].choices = mode_choices
2✔
143

144
    class Meta:
2✔
145
        model = TutoringSession
2✔
146
        fields = ["tutoring_mode", "subject", "date", "offering_rate", "message"]
2✔
147
        widgets = {
2✔
148
            "date": forms.DateInput(
149
                attrs={
150
                    "type": "date",
151
                    "min": timezone.localdate(),
152
                    "class": "form-control",
153
                    "id": "date_selector",
154
                }
155
            ),
156
            "offering_rate": forms.NumberInput(attrs={"class": "form-control"}),
157
            "message": forms.Textarea(
158
                attrs={"class": "form-control", "rows": 3, "placeholder": "Message"}
159
            ),
160
        }
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