import logging
from django import forms
from django.core.mail import EmailMessage

from core.models import Order
from accounts import STATE_CHOICES

logger = logging.getLogger(__name__)

class AddToCartForm(forms.Form):
    WHOLE = 'Whole Beans'
    ESPRESSO = 'Espresso'
    CONE_DRIP = 'Cone Drip'
    BASKET_DRIP = 'Basket Drip'
    FRENCH_PRESS = 'French Press'
    STOVETOP_ESPRESSO = 'Stovetop Espresso (Moka Pot)'
    AEROPRESS = 'AeroPress'
    PERCOLATOR = 'Percolator'
    OTHER = 'Other'
    ROAST_CHOICES = [
        (WHOLE, 'Whole Beans'),
        (ESPRESSO, 'Espresso'),
        (CONE_DRIP, 'Cone Drip'),
        (BASKET_DRIP, 'Basket Drip'),
        (FRENCH_PRESS, 'French Press'),
        (STOVETOP_ESPRESSO, 'Stovetop Espresso (Moka Pot)'),
        (AEROPRESS, 'AeroPress'),
        (PERCOLATOR, 'Percolator'),
        (OTHER, 'Other (enter below)')
    ]
    quantity = forms.IntegerField(min_value=1, initial=1)
    roast = forms.ChoiceField(choices=ROAST_CHOICES)
    other = forms.CharField(required=False)
    update = forms.BooleanField(required=False, initial=False, widget=forms.HiddenInput)


class AddressForm(forms.Form):
    first_name = forms.CharField()
    last_name = forms.CharField()
    email = forms.EmailField()
    street_address_1 = forms.CharField()
    street_address_2 = forms.CharField(required=False)
    city = forms.CharField()
    state = forms.ChoiceField(
        choices=STATE_CHOICES
    )
    postal_code = forms.CharField()

class OrderCreateForm(forms.ModelForm):
    email = forms.CharField(widget=forms.HiddenInput())
    first_name = forms.CharField(widget=forms.HiddenInput())
    last_name = forms.CharField(widget=forms.HiddenInput())

    class Meta:
        model = Order
        fields = (
            'total_net_amount',
        )
        widgets = {
            'total_net_amount': forms.HiddenInput()
        }
