diff --git a/tasks/__pycache__/forms.cpython-313.pyc b/tasks/__pycache__/forms.cpython-313.pyc index f31edbd..4c102f5 100644 Binary files a/tasks/__pycache__/forms.cpython-313.pyc and b/tasks/__pycache__/forms.cpython-313.pyc differ diff --git a/tasks/__pycache__/views.cpython-313.pyc b/tasks/__pycache__/views.cpython-313.pyc index 1a3e6b2..ed351f7 100644 Binary files a/tasks/__pycache__/views.cpython-313.pyc and b/tasks/__pycache__/views.cpython-313.pyc differ diff --git a/tasks/forms.py b/tasks/forms.py index f3529de..4699323 100644 --- a/tasks/forms.py +++ b/tasks/forms.py @@ -1,5 +1,7 @@ from django import forms from .models import Cuenta, Movimientos, TipoMovimiento +from django.core.exceptions import ValidationError +from datetime import datetime class RegistroCuentaForm(forms.ModelForm): class Meta: @@ -18,11 +20,13 @@ class RegistroMovimientosForm(forms.ModelForm): ) fecha_factura = forms.DateField( widget=forms.DateInput( - attrs={'type': 'date', 'class': 'form-control'} + attrs={'type': 'date', 'class': 'form-control', + 'max': datetime.now().strftime('%Y-%m-%dT%H:%M')} + ), label="Fecha de factura", ) - + class Meta: model = Movimientos fields = ['tipo_movimiento','fecha_factura', 'saldo','n_factura', 'observacion','proveedor','responsable_cuenta'] @@ -33,4 +37,9 @@ class RegistroMovimientosForm(forms.ModelForm): 'proveedor': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Nombre del proveedor'}), 'responsable_cuenta': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Nombre del responsable'}), - } \ No newline at end of file + } + def clean_fecha_factura(self): + fecha_factura = self.cleaned_data.get('fecha_factura') + if fecha_factura > datetime.now().date(): + raise ValidationError("La fecha no puede ser en el futuro.") + return fecha_factura \ No newline at end of file diff --git a/tasks/templates/base.html b/tasks/templates/base.html index 266e116..61ae483 100644 --- a/tasks/templates/base.html +++ b/tasks/templates/base.html @@ -3,75 +3,105 @@ - {% block title %}Registro{% endblock %} + {% block title %}Registro de presupuestos{% endblock %} + + + + - -