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')),
                ('analysis_result', _('Result'))]

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'}))
    order_by = forms.ChoiceField(choices=SORT_OPTIONS, widget=Select(attrs={'data-transform': 'input-control'}))