from django import forms

from userapp.models import Order
from .models import AdType, Category, AdTemplate

class CategoryForm(forms.ModelForm):
    class Meta:
        model = Category
        fields = ['name', 'image']  # Include image field

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['image'].widget.attrs.update({'class': 'form-control-file'})  # Bootstrap styling


class AdTypeForm(forms.ModelForm):
    class Meta:
        model = AdType
        fields = ['name']

class AdTemplateForm(forms.ModelForm):
    class Meta:
        model = AdTemplate
        fields = ['name', 'description', 'category', 'ad_type', 'image', 'price']  # ✅ Included 'ad_type'

    category = forms.ModelChoiceField(
        queryset=Category.objects.all(),
        empty_label="Select Category",
        widget=forms.Select(attrs={'class': 'form-select'})  # Bootstrap styling
    )

    ad_type = forms.ModelChoiceField(  # ✅ Added Ad Type Field
        queryset=AdType.objects.all(),
        empty_label="Select Ad Type",
        widget=forms.Select(attrs={'class': 'form-select'})  # Bootstrap styling
    )

    price = forms.DecimalField(
        max_digits=10,
        decimal_places=2,
        min_value=0.00,
        widget=forms.NumberInput(attrs={'class': 'form-control', 'placeholder': 'Enter price'})  # Bootstrap styling
    )


class OrderStatusForm(forms.ModelForm):
    class Meta:
        model = Order
        fields = ['status']
        
        
        
# Ask the user to enter their name and print a personalized greeting message.
# Ask the user to input two numbers and display their sum
# Ask the user to enter the radius of a circle and calculate its area.
# Ask the user to input their age and display how old they will be after 10 years.
# Ask the user to input the principal amount, rate of interest, and time, then calculate the simple interest.