# -*- coding: utf-8 -*-
from django import forms
#from django.contrib.auth.forms import UserCreationForm
#from django.contrib.auth.models import User
from catalog.models import Publisher, News
from django.db.models import Q

class SearchForm(forms.Form):
	startDate = forms.DateField(label="Fecha de Inicio", widget=forms.DateInput(attrs={'type':'date', 'class':"form-control"}), required=False)
        endDate = forms.DateField(label="Fecha de Fin", widget=forms.DateInput(attrs={'type':'date', 'class':"form-control"}), required=False)

	news = News.objects.all()
	publishersList = Publisher.objects.all().filter( Q(id__in = news.values('publisher').distinct()))
	choice =  [ (r.id,r.name) for r in publishersList ] 
	publishers = forms.MultipleChoiceField(label="Fuentes", widget=forms.SelectMultiple(attrs={'class':"form-control"}), choices=choice, required=False)
	text = forms. CharField(label="Palabras Clave", widget=forms.TextInput(attrs={'class':"form-control", "placeholder":"Palabras clave"}), required=False)

