from django import forms


class BaseFileForm(forms.Form):
    # we try to minify the file to only submit the data
    points_file = forms.FileField(
        required=False,
        widget=forms.FileInput(attrs={'required': 'required'}),
        label="Location History File (.json)"
    )
    points_data = forms.CharField(widget=forms.HiddenInput(), required=False)

    def clean(self):
        points_file = self.cleaned_data.get('points_file')
        points_data = self.cleaned_data.get('points_data')

        if not points_file and not points_data:
            raise forms.ValidationError({'points_file': 'File is required.'})

        return self.cleaned_data


class ReportForm(BaseFileForm):
    symptoms_at = forms.DateField(widget=forms.TextInput(attrs={
        'placeholder': 'YYYY-MM-DD',
        'pattern': '[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}',
        'title': 'YYYY-MM-DD'
    }))
    is_verified = forms.BooleanField(required=False)


class CheckForm(BaseFileForm):
    pass


class DeleteForm(forms.Form):
    delete_token = forms.CharField(label="Delete token")

[((29, 18, 29, 52), 'django.forms.BooleanField', 'forms.BooleanField', (), '', False, 'from django import forms\n'), ((37, 19, 37, 56), 'django.forms.CharField', 'forms.CharField', (), '', False, 'from django import forms\n'), ((8, 15, 8, 62), 'django.forms.FileInput', 'forms.FileInput', (), '', False, 'from django import forms\n'), ((11, 41, 11, 60), 'django.forms.HiddenInput', 'forms.HiddenInput', ({}, {}), '()', False, 'from django import forms\n'), ((18, 18, 18, 77), 'django.forms.ValidationError', 'forms.ValidationError', ({(18, 40, 18, 76): "{'points_file': 'File is required.'}"}, {}), "({'points_file': 'File is required.'})", False, 'from django import forms\n'), ((24, 41, 28, 6), 'django.forms.TextInput', 'forms.TextInput', (), '', False, 'from django import forms\n')]