from django import forms
from django.forms import RadioSelect

from .models import Habit


class AddHabitForm(forms.Form):
    habit_name = forms.CharField(label='Habit name', max_length=100)


class HabitTrackingForm(forms.Form):
    def __init__(self, user, *args, **kwargs):
        super().__init__(*args, **kwargs)
        habits = Habit.objects.filter(user=user)
        for i, _ in enumerate(habits):
            field_name = habits[i].habit_name
            self.fields[field_name] = forms.ChoiceField(
                widget=RadioSelect(),
                choices=[('True', 'Yes'), ('False', 'No')],
            )
