diff --git a/action/forms.py b/action/forms.py new file mode 100644 index 0000000..4d391f2 --- /dev/null +++ b/action/forms.py @@ -0,0 +1,22 @@ +from django import forms +from .models import State + + +class AddStateForm(forms.Form): + add_note = forms.BooleanField(required=False) + note = forms.CharField( + required=False, + widget=forms.Textarea(attrs={'rows': 4, 'maxlength': 200, 'placeholder': 'Max 200 characters'}), + ) + state_id = forms.IntegerField(required=True, widget=forms.HiddenInput()) + snapshot_uuid = forms.UUIDField(required=True, widget=forms.HiddenInput()) + + + def clean(self): + cleaned_data = super().clean() + add_note = cleaned_data.get('add_note') + note = cleaned_data.get('note') + + if add_note == True and not note: + self.add_error('note', 'Please enter a note if you checked "Add a note".') + return cleaned_data \ No newline at end of file diff --git a/device/templates/details.html b/device/templates/details.html index 3c0a185..e38e229 100644 --- a/device/templates/details.html +++ b/device/templates/details.html @@ -58,70 +58,91 @@ - -