Use date and datetime inputs

Properly implements 4d91a76513
This commit is contained in:
Lukáš Kucharczyk 2023-02-20 21:33:15 +01:00
parent 42d002a9d9
commit b30679f6e7
2 changed files with 14 additions and 20 deletions

View File

@ -2,6 +2,11 @@ from django import forms
from games.models import Game, Platform, Purchase, Session, Edition, Device from games.models import Game, Platform, Purchase, Session, Edition, Device
custom_date_widget = forms.DateInput(attrs={"type": "date"})
custom_datetime_widget = forms.DateTimeInput(
attrs={"type": "datetime-local"}, format="%Y-%m-%d %H:%M"
)
class SessionForm(forms.ModelForm): class SessionForm(forms.ModelForm):
purchase = forms.ModelChoiceField( purchase = forms.ModelChoiceField(
@ -9,6 +14,10 @@ class SessionForm(forms.ModelForm):
) )
class Meta: class Meta:
widgets = {
"timestamp_start": custom_datetime_widget,
"timestamp_end": custom_datetime_widget,
}
model = Session model = Session
fields = [ fields = [
"purchase", "purchase",
@ -30,6 +39,10 @@ class PurchaseForm(forms.ModelForm):
platform = forms.ModelChoiceField(queryset=Platform.objects.order_by("name")) platform = forms.ModelChoiceField(queryset=Platform.objects.order_by("name"))
class Meta: class Meta:
widgets = {
"date_purchased": custom_date_widget,
"date_refunded": custom_date_widget,
}
model = Purchase model = Purchase
fields = [ fields = [
"edition", "edition",

View File

@ -154,23 +154,4 @@ if _csrf_trusted_origins:
else: else:
CSRF_TRUSTED_ORIGINS = [] CSRF_TRUSTED_ORIGINS = []
REST_FRAMEWORK = { USE_L10N = False
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly"
]
}
FRONTEND_ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", "frontend", "dist"))
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_HEADERS = list(default_headers) + [
"Accept-Language",
"Connection",
"Host",
"Origin",
"Referer",
"Sec-Fetch-Dest",
"Sec-Fetch-Mode",
"Sec-Fetch-Site",
]