# -*- coding: utf-8 -*-

from django import forms
from app_academico.curso.models import *

class CursoModelForm(forms.ModelForm):

	def __init__(self, *args, **kwargs):
		super(CursoModelForm, self).__init__(*args, **kwargs)

		self.fields[u'descricao'].required = True
		self.fields[u'quant_vaga'].required = True
		self.fields[u'semestre'].required = True
		self.fields[u'turno'].required = True
		self.fields[u'pre_requisito'].required = True
		self.fields[u'ativo'].required = True

	descricao = forms.CharField(
		label = "Descrição",
		widget = forms.TextInput(
			attrs = {
				'placeholder': 'Descrição do curso',
				'class': 'form-control'
			}
		)
	)
	# quant_vaga = forms.CharField(
	# 	label = "Vagas",
	# 	widget = forms.TextInput(
	# 		attrs = {
	# 			'placeholder': 'Quantidade de vagas',
	# 			'required': 'required',
	# 			'class': 'form-control'
	# 		}
	# 	)
	# )

	# quant_vaga = forms.ChoiceField(
	# 	label="Quantidade de Vagas",
	# 	choices=CONST.QUANTIDADE_VAGA.choices,
	# )

	quant_vaga = forms.IntegerField(
		label="Quantidade de Vagas",
	)

	carga_horaria = forms.ChoiceField(
		label="Carga Horária",
		choices=CONST.CARGA_HORARIA.choices,
	)

	from app_academico.semestre.models import TblAcademicoSemestre
	semeste = forms.BaseModelFormSet(
		queryset=TblAcademicoSemestre.objects.filter(ativo=True),
	)

	from app_academico.turno.models import TblAcademicoTurno
	turno = forms.BaseModelFormSet(
		queryset=TblAcademicoTurno.objects.all(),
	)

	pre_requisito = forms.ChoiceField(
		label="Pré-Requisito",
		choices=CONST.PREREQUISITO.choices,
	)

	# pre_requisito = forms.MultipleChoiceField(
	# 	required=False,
	# 	widget=forms.CheckboxSelectMultiple,
	# 	choices=CONST.PREREQUISITO.choices,
	# )

	ativo = forms.ChoiceField(
		label="Ativo",
		choices=CONST.ATIVO.choices,
	)

	class AtivoSearchForm(forms.Form):
		ativo = forms.ChoiceField(
			choices=CONST.ATIVO.choices,
			widget=forms.Select(
				attrs={
					'class': 'form-control'
			   }
			)
		)

	class Meta:
		model = TblAcademicoCurso
		fields = ('descricao','quant_vaga', 'carga_horaria', 'semestre', 'turno','pre_requisito', 'ativo')