from base.forms import ModelForm, forms
from horilla_meet.models import *
from recruitment.models import Candidate


class GoogleCloudCredentialForm(ModelForm):
    class Meta:
        model = GoogleCloudCredential
        fields = "__all__"
        widgets = {
            'project_id': forms.TextInput(attrs={'class': 'oh-input'}),
            'client_id': forms.TextInput(attrs={'class': 'oh-input'}),
            'client_secret': forms.TextInput(attrs={'class': 'oh-input'}),
            'redirect_uris': forms.Textarea(attrs={'class': 'oh-input', 'rows': 3}),
            'company_id': forms.Select(attrs={'class': 'oh-select oh-select_2'}),
        }


class GoogleMeetingForm(ModelForm):
    attendees = forms.MultipleChoiceField(choices=[], widget=forms.SelectMultiple)

    class Meta:
        model = GoogleMeeting
        fields = ["title", "description", "start_time", "duration", "attendees"]
        widgets = {
            "start_time": forms.DateTimeInput(
                attrs={"type": "datetime-local", "class": "form-control oh-input"}
            )
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        employees = [
            (emp.get_mail(), emp.get_full_name()) for emp in Employee.objects.all()
        ]
        candidates = [(cand.get_mail(), cand.name) for cand in Candidate.objects.all()]

        self.fields["attendees"].choices = [
            ("Employees", employees),
            ("Candidates", candidates),
        ]
