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

gcivil-nyu-org / team4-wed-fall25 / 48

01 Nov 2025 10:12PM UTC coverage: 60.699% (-2.5%) from 63.213%
48

push

travis-pro

web-flow
Merge pull request #71 from gcivil-nyu-org/fix/uploader_bugs

fixed uploader bugs

17 of 55 new or added lines in 4 files covered. (30.91%)

1 existing line in 1 file now uncovered.

434 of 715 relevant lines covered (60.7%)

0.61 hits per line

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

33.33
/note2webapp/forms.py
1
from django import forms
1✔
2
from .models import ModelUpload, ModelVersion
1✔
3

4

5
# -------------------------
6
# Upload Form (for new upload)
7
# -------------------------
8
class UploadForm(forms.ModelForm):
1✔
9
    class Meta:
1✔
10
        model = ModelUpload
1✔
11
        fields = ["name"]
1✔
12

13

14
# -------------------------
15
# Version Form (for new version)
16
# -------------------------
17
class VersionForm(forms.ModelForm):
1✔
18
    class Meta:
1✔
19
        model = ModelVersion
1✔
20
        fields = ["model_file", "predict_file", "schema_file", "tag", "category"]
1✔
21
        widgets = {
1✔
22
            "model_file": forms.FileInput(attrs={"required": False}),
23
            "predict_file": forms.FileInput(attrs={"required": False}),
24
            "schema_file": forms.FileInput(attrs={"required": False}),
25
        }
26

27
    def __init__(self, *args, **kwargs):
1✔
NEW
28
        super().__init__(*args, **kwargs)
×
29
        # Don't set required in __init__ - let JavaScript handle validation
NEW
30
        self.fields["model_file"].required = False
×
NEW
31
        self.fields["predict_file"].required = False
×
NEW
32
        self.fields["schema_file"].required = False
×
33
        # Add help text
NEW
34
        self.fields["model_file"].help_text = "Required: Upload your .pt model file"
×
NEW
35
        self.fields["predict_file"].help_text = (
×
36
            "Required: Upload your .py prediction script"
37
        )
NEW
38
        self.fields["schema_file"].help_text = "Required: Upload your .json schema file"
×
39

40
    def clean(self):
1✔
NEW
41
        cleaned_data = super().clean()
×
NEW
42
        model_file = cleaned_data.get("model_file")
×
NEW
43
        predict_file = cleaned_data.get("predict_file")
×
NEW
44
        schema_file = cleaned_data.get("schema_file")
×
45
        # Backend validation - this runs after JavaScript
NEW
46
        if not model_file:
×
NEW
47
            raise forms.ValidationError("Model file (.pt) is required")
×
NEW
48
        if not predict_file:
×
NEW
49
            raise forms.ValidationError("Predict file (.py) is required")
×
NEW
50
        if not schema_file:
×
NEW
51
            raise forms.ValidationError("Schema file (.json) is required")
×
NEW
52
        return cleaned_data
×
53

54
    def clean_model_file(self):
1✔
55
        file = self.cleaned_data.get("model_file")
×
56
        if file and not file.name.endswith(".pt"):
×
57
            raise forms.ValidationError("Only .pt files are allowed for Model File")
×
58
        return file
×
59

60
    def clean_predict_file(self):
1✔
61
        file = self.cleaned_data.get("predict_file")
×
62
        if file and not file.name.endswith(".py"):
×
63
            raise forms.ValidationError("Only .py files are allowed for Predict File")
×
64
        return file
×
65

66
    def clean_schema_file(self):
1✔
67
        file = self.cleaned_data.get("schema_file")
×
68
        if file and not file.name.endswith(".json"):
×
69
            raise forms.ValidationError("Only .json files allowed for schema")
×
70
        return file
×
71

72
    def clean_tag(self):
1✔
73
        tag = self.cleaned_data.get("tag")
×
74
        if not tag:
×
75
            raise forms.ValidationError("Tag is required")
×
76
        return tag
×
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