# (c) cavaliba.com - data - forms.py

from django import forms
from django.utils.translation import gettext as _

CSV_ENCODING_CHOICES = (
    ("utf-8", "utf-8"),
    ("iso-8859-1", "iso-8859-1"),
    ("iso-8859-15", "iso-8859-15"),
    ("ascii", "ascii"),
)

CSV_SEPARATOR_CHOICES = (
    (",", ","),
    (";", ";"),
    ("|", "|"),
)


class DataUploadForm(forms.Form):
    file = forms.FileField(
        widget=forms.ClearableFileInput(attrs=None),
        # widget=forms.FileInput(attrs={'class': 'form-control-file'}),
        label=_("File"),
        help_text=_("Choose a file (csv,yaml,json)"),
    )


class CSVImportForm(forms.Form):
    file = forms.FileField(
        widget=forms.ClearableFileInput(attrs=None),
        label=_("File"),
        help_text=_("Choose a CSV file"),
    )
    encoding = forms.ChoiceField(
        choices=CSV_ENCODING_CHOICES,
        required=False,
        initial="utf-8",
        label=_("Encoding"),
    )
    separator = forms.ChoiceField(
        choices=CSV_SEPARATOR_CHOICES,
        required=False,
        initial=",",
        label=_("Separator"),
    )
