# Copyright 2011 Ryan W Sims (rwsims@gmail.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import re

from django import forms
from django.forms import formsets

import common.forms
from vendors import models


class RejectApplicationForm(forms.Form):
    required_css_class = 'required'
    error_css_class = 'error'

    reason = forms.ChoiceField(label="Reason for rejection",
            choices=(
                ('heteronormative', 'Heteronormative language'),
                ('reviews', 'Missing a wedding review'),
                ))
    comment = forms.CharField(label="Additional comment",
            widget=forms.Textarea, required=False)


class NewVendorForm(forms.Form):
    """Form for taking in basic information about a vendor."""
    required_css_class = 'required'
    error_css_class = 'error'

    social_links = common.forms.UrlListField(label="Social networking links",
                                             help_text="One per line.")
    promo_text = forms.CharField(label="Discount text",
                                 widget=forms.Textarea,
                                 required=False)
    name = forms.CharField()
    public_email = forms.EmailField(required=False)
    website = forms.URLField(required=False)
    blog_url = forms.URLField(required=False)
    description = forms.CharField(widget=forms.Textarea, required=False)
    review_links = common.forms.UrlListField(label="Links to offsite reviews",
                                             help_text="One per line.")
    lgbt_owned = common.forms.YesNoField(label="Is vendor LGBT owned?",
                                         initial=0)
    experienced = common.forms.YesNoField(label="Has vendor worked with LGBT "
                                          "weddings before?",
                                          initial=0)
    zipcode = forms.CharField(required=False)
    phone = forms.CharField(required=False)
    image_url = forms.URLField(required=False)
    awards = common.forms.NewlineSeparatedField(required=False,
                                                   help_text="One per line.")

class TrackbackForm(forms.Form):
    """Form for adding a trackback to a vendor."""
    required_css_class = 'required'
    error_css_class = 'error'

    title = forms.CharField()
    url = forms.CharField()

TrackbackFormset = formsets.formset_factory(TrackbackForm)


class LgbtReviewForm(forms.Form):
    """Form for adding a review by an LGBT couple."""
    required_css_class = 'required'
    error_css_class = 'error'

    names = forms.CharField()
    text = forms.CharField(widget=forms.Textarea)

LgbtReviewFormset = formsets.formset_factory(LgbtReviewForm)
