from django import forms
from django.forms.widgets import Select, CheckboxInput
from django.utils.translation import gettext as _

from .models import ReportTemplate

SORT_OPTIONS = [('sample__name', _('Sample name')),
                ('finished_at', _('Date and time')),
                ('result', _('Result'))]

SIGNATURE_CHOICE = [('None', _('None')),
                    ('user', _('from User')),
                    ('template', _('from Template'))]


class ProjectReportTemplateSelectForm(forms.Form):
    report_template = forms.ModelChoiceField(
        queryset=ReportTemplate.objects.all(), label=_('template to use'),
        initial=ReportTemplate.objects.first() or None,
        widget=Select(attrs={'data-transform': 'input-control'}),
        required=True
    )

    commentsColumn = forms.BooleanField(required=True, initial=True, label=_('include comments column'),
                                        widget=CheckboxInput(attrs={'data-transform': 'input-control'}))
    remarksColumn = forms.BooleanField(required=True, initial=True, label=_('include remarks column'),
                                       widget=CheckboxInput(attrs={'data-transform': 'input-control'}))

    signature_choice = forms.ChoiceField(choices=SIGNATURE_CHOICE,
                                         widget=Select(attrs={'data-transform': 'input-control'}))

    order_by = forms.ChoiceField(choices=SORT_OPTIONS, widget=Select(attrs={'data-transform': 'input-control'}))