Skip to content

Commit

Permalink
fmt to follow DJ style guide
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Oct 19, 2024
1 parent 507222f commit 46d81d0
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tin/apps/assignments/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,6 @@ class Meta:
class FileActionForm(forms.ModelForm):
"""A form to create (or edit) a :class:`.FileAction`."""

def clean(self):
cleaned_data = super().clean()
if cleaned_data is None:
cleaned_data = self.cleaned_data
cmd = cleaned_data.get("command", "")

if "$FILE" in cmd or "$FILES" in cmd:
if not cleaned_data.get("match_type"):
self.add_error("match_type", "required if command uses $FILE or $FILES")
if not cleaned_data.get("match_value"):
self.add_error("match_value", "required if command uses $FILE or $FILES")

return cleaned_data

class Meta:
model = FileAction
fields = [
Expand All @@ -274,6 +260,20 @@ class Meta:
"description": forms.Textarea(attrs={"cols": 32, "rows": 2}),
}

def clean(self):
cleaned_data = super().clean()
if cleaned_data is None:
cleaned_data = self.cleaned_data
cmd = cleaned_data.get("command", "")

if "$FILE" in cmd or "$FILES" in cmd:
if not cleaned_data.get("match_type"):
self.add_error("match_type", "required if command uses $FILE or $FILES")
if not cleaned_data.get("match_value"):
self.add_error("match_value", "required if command uses $FILE or $FILES")

return cleaned_data


class ChooseFileActionForm(forms.Form):
"""A form to choose a file action.
Expand Down

0 comments on commit 46d81d0

Please sign in to comment.