from django import forms

class ProductOneTimeOrderForm(forms.Form):
    """
    For products that only contain onetimeresoures
    """

    product = forms.SlugField(required=True, disabled=True)

    def __init__(self, resources, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for res in resources:
            print(res)
            field_name = f"{res.slug}"
            self.fields[field_name] = forms.FloatField(required=True, label=res.name)

    def clean(self):
        cleaned_data = super().clean()
        print("Cleaning form myself ...")


class ProductOrderForm(ProductOneTimeOrderForm):
    """
    For recurring products (might also have OneTime items
    """

    timeframe = forms.SlugField(required=False, disabled=True)
