#encoding:utf-8 from django import forms from django.forms import ModelForm from bienes.models import * from django.db import models from django.forms.extras.widgets import * from django.contrib.admin import widgets import datetime class AutoridadForm(forms.ModelForm): class Meta: model = Autoridad class PersonaForm(forms.ModelForm): class Meta: exclude = ('estatus',) model = Persona class CalidadBienForm(forms.ModelForm): class Meta: model = CalidadBien class TipoBienForm(forms.ModelForm): class Meta: model = TipoBien class BienesForm(forms.ModelForm): class Meta: model = Bienes exclude = ('oficio',) widgets = { 'descripcion' : forms.Textarea(attrs={"class":"span6"}), 'observaciones' : forms.Textarea(attrs={"class":"span6"}), 'diligencias' : forms.Textarea(attrs={"class":"span6"}) } # fields = ('calidad_bien','tipo_bien','enlace','descripcion','situacion_juridica','observaciones','fecha_devolucion','devuelto','diligencias','foto') class OficioForm(forms.ModelForm): numero_averiguacion = forms.CharField(required=False) autoridad = forms.ModelChoiceField(label='Autoridad:',queryset=Autoridad.objects.all(),required=False), persona_entrega = forms.ModelChoiceField(label='Persona que Entrega:',queryset=Persona.objects.all(), empty_label="Seleccione una Persona", required=False), class Meta: model = Oficios widgets = { 'numero_oficio': forms.TextInput(attrs={"class": "required span2"}), 'identificacion': forms.Textarea(attrs={"class": "span4"}) } class RecepcionForm(forms.ModelForm): class Meta: model = Recepcion exclude = ('bien','estatus',) widgets ={ 'numero_acta': forms.TextInput(attrs={"class":"required span8"}), 'fecha': forms.TextInput(attrs={"class":"required span8"}), 'hora': forms.TextInput(attrs={"class":"required span8"}), 'envia': forms.Select(attrs={"class":"required span12"}), 'recibe': forms.Select(attrs={"class":"required span12"}), 'capturo': forms.Select(attrs={"class":"required span12"}), 'reviso': forms.Select(attrs={"class":"required span12"}), 'testigo1': forms.TextInput(attrs={"class":"required span8"}), 'testigo2': forms.TextInput(attrs={"class":"required span8"}) } def __init__(self, *args, **kwargs): super(RecepcionForm, self).__init__(*args, **kwargs) self.fields['envia'].label_from_instance = self.label_from_instance self.fields['recibe'].label_from_instance = self.label_from_instance self.fields['capturo'].label_from_instance = self.label_from_instance self.fields['reviso'].label_from_instance = self.label_from_instance @staticmethod def label_from_instance(obj): return "{} {} {} - {}".format(obj.nombre.encode('utf-8'),obj.apellidopaterno.encode('utf-8'),obj.apellidomaterno.encode('utf-8'),obj.cargo.encode('utf-8')) class DevolucionForm(forms.ModelForm): # bien = forms.ModelChoiceField(queryset=Bienes.objects.all().values_list('descripcion')) class Meta: model = Devolucion # exclude = ('recepcion',) widgets ={ 'recepcion': forms.Select(attrs={"class":"span8"}), 'numero_acta' : forms.TextInput(attrs={"class":"span8"}), 'propietario' : forms.TextInput(attrs={"class":"span8"}), 'numero_oficio' : forms.TextInput(attrs={"class":"span8"}), 'fecha_oficio' : forms.TextInput(attrs={"class":"span8"}), 'folio' : forms.TextInput(attrs={"class":"span8"}), 'horacierre' : forms.TextInput(attrs={"class":"span8"}), 'numero_expedienteacta' : forms.TextInput(attrs={"class":"span8"}), 'fecha_recepcion_oficio' : forms.TextInput(attrs={"class":"span8"}), 'tipopropietario' : forms.Select(attrs={"class":"span5"}), 'expedienteacta' : forms.Select(attrs={"class":"span5"}), 'fechahora' : forms.Textarea(attrs={"class":"span12"}), 'observaciones' : forms.Textarea(attrs={"class":"span12"}), 'cantidad' : forms.Textarea(attrs={"class":"span12"}), 'identificacion' : forms.Textarea(attrs={"class":"span12"}), 'testigo1': forms.TextInput(attrs={"class":"required span12"}), 'testigo2': forms.TextInput(attrs={"class":"required span12"}), 'reviso': forms.Select(attrs={"class":"required span12"}), } def __init__(self, *args, **kwargs): super(DevolucionForm, self).__init__(*args, **kwargs) self.fields['signado'].label_from_instance = self.label_from_instance self.fields['autoriza'].label_from_instance = self.label_from_instance self.fields['capturo'].label_from_instance = self.label_from_instance self.fields['reviso'].label_from_instance = self.label_from_instance @staticmethod def label_from_instance(obj): return "{} {} {} - {}".format(obj.nombre.encode('utf-8'), obj.apellidopaterno.encode('utf-8'), obj.apellidomaterno.encode('utf-8'), obj.cargo.encode('utf-8')) class FiltroForm(forms.Form): fecha_de = forms.DateField(label="De") fecha_a = forms.DateField(label="A") cantidad = forms.IntegerField(initial=10, label="Cantidad de Resultados" ) class EditarRecepcionForm(forms.ModelForm): class Meta: model = Recepcion exclude = ('oficio','bien','estatus',) widgets ={ 'numero_acta': forms.TextInput(attrs={"class":"required span8"}), 'fecha': forms.TextInput(attrs={"class":"required span8"}), 'hora': forms.TextInput(attrs={"class":"required span8"}), 'envia': forms.Select(attrs={"class":"required span8"}), 'recibe': forms.Select(attrs={"class":"required span8"}), 'capturo': forms.Select(attrs={"class":"required span8"}), 'reviso': forms.Select(attrs={"class":"required span8"}), 'testigo1': forms.TextInput(attrs={"class":"required span8"}), 'testigo2': forms.TextInput(attrs={"class":"required span8"}) } def __init__(self, *args, **kwargs): super(EditarRecepcionForm, self).__init__(*args, **kwargs) self.fields['envia'].label_from_instance = self.label_from_instance self.fields['recibe'].label_from_instance = self.label_from_instance self.fields['capturo'].label_from_instance = self.label_from_instance self.fields['reviso'].label_from_instance = self.label_from_instance @staticmethod def label_from_instance(obj): return "{} {} {} - {}".format(obj.nombre.encode('utf-8'),obj.apellidopaterno.encode('utf-8'),obj.apellidomaterno.encode('utf-8'),obj.cargo.encode('utf-8')) class EditarDevolucionForm(forms.ModelForm): class Meta: # bien = forms.ModelChoiceField(label='Autoridad:',queryset=Bienes.objects.filter(devolucion__pk=self.pk)), model = Devolucion # exclude = ('recepcion',) exclude = ('estatus',) widgets ={ 'recepcion': forms.Select(attrs={"class":"span8"}), 'bien': forms.Select(attrs={"class":"span12"}), 'numero_acta' : forms.TextInput(attrs={"class":"span8"}), 'propietario' : forms.TextInput(attrs={"class":"span8"}), 'numero_oficio' : forms.TextInput(attrs={"class":"span8"}), 'fecha_oficio' : forms.TextInput(attrs={"class":"span8"}), 'folio' : forms.TextInput(attrs={"class":"span8"}), 'horacierre' : forms.TextInput(attrs={"class":"span8"}), 'numero_expedienteacta' : forms.TextInput(attrs={"class":"span8"}), 'fecha_recepcion_oficio' : forms.TextInput(attrs={"class":"span8"}), 'tipopropietario' : forms.Select(attrs={"class":"span5"}), 'expedienteacta' : forms.Select(attrs={"class":"span5"}), 'fechahora' : forms.Textarea(attrs={"class":"span12"}), 'observaciones' : forms.Textarea(attrs={"class":"span12"}), 'cantidad' : forms.Textarea(attrs={"class":"span12"}), 'identificacion' : forms.Textarea(attrs={"class":"span12"}), 'testigo1': forms.TextInput(attrs={"class":"required span12"}), 'testigo2': forms.TextInput(attrs={"class":"required span12"}), 'reviso': forms.Select(attrs={"class":"required span12"}), } def __init__(self, *args, **kwargs): super(EditarDevolucionForm, self).__init__(*args, **kwargs) self.fields['signado'].label_from_instance = self.label_from_instance self.fields['autoriza'].label_from_instance = self.label_from_instance self.fields['capturo'].label_from_instance = self.label_from_instance self.fields['reviso'].label_from_instance = self.label_from_instance @staticmethod def label_from_instance(obj): return "{} {} {} - {}".format(obj.nombre.encode('utf-8'), obj.apellidopaterno.encode('utf-8'), obj.apellidomaterno.encode('utf-8'), obj.cargo.encode('utf-8'))