mirror of
https://github.com/ae-utbm/sith.git
synced 2025-06-29 06:35:18 +00:00
fix: FutureDateTime form field
This commit is contained in:
parent
05a55f10e7
commit
a8c6cc29f5
@ -39,9 +39,8 @@ from django.forms import (
|
||||
DateInput,
|
||||
DateTimeInput,
|
||||
TextInput,
|
||||
Widget,
|
||||
)
|
||||
from django.utils.timezone import now
|
||||
from django.utils.timezone import localtime, now
|
||||
from django.utils.translation import gettext
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from phonenumber_field.widgets import RegionalPhoneNumberWidget
|
||||
@ -115,7 +114,7 @@ class SelectUser(TextInput):
|
||||
|
||||
def validate_future_timestamp(value: date | datetime):
|
||||
if value <= now():
|
||||
raise ValueError(_("Ensure this timestamp is set in the future"))
|
||||
raise ValidationError(_("Ensure this timestamp is set in the future"))
|
||||
|
||||
|
||||
class FutureDateTimeField(forms.DateTimeField):
|
||||
@ -123,8 +122,8 @@ class FutureDateTimeField(forms.DateTimeField):
|
||||
|
||||
default_validators = [validate_future_timestamp]
|
||||
|
||||
def widget_attrs(self, widget: Widget) -> dict[str, str]:
|
||||
return {"min": widget.format_value(now())}
|
||||
def widget_attrs(self, widget: forms.Widget) -> dict[str, str]:
|
||||
return {"min": widget.format_value(localtime())}
|
||||
|
||||
|
||||
# Forms
|
||||
|
Loading…
x
Reference in New Issue
Block a user