Add date and time pickers to forms
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
e51d586255
commit
beec919b2e
|
@ -2,6 +2,7 @@
|
|||
|
||||
* New
|
||||
* When adding session, pre-select game with the last session
|
||||
* Date and time input fields now have proper pickers
|
||||
|
||||
## 0.2.4 / 2023-01-16 19:39+01:00
|
||||
|
||||
|
|
|
@ -13,12 +13,26 @@ class SessionForm(forms.ModelForm):
|
|||
"duration_manual",
|
||||
"note",
|
||||
]
|
||||
custom_datetime_widget = forms.SplitDateTimeWidget(
|
||||
date_attrs={"type": "date"}, time_attrs={"type": "time"}
|
||||
)
|
||||
widgets = {
|
||||
"timestamp_start": custom_datetime_widget,
|
||||
"timestamp_end": custom_datetime_widget,
|
||||
}
|
||||
|
||||
|
||||
class PurchaseForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Purchase
|
||||
fields = ["game", "platform", "date_purchased", "date_refunded"]
|
||||
custom_date_widget = forms.DateInput(
|
||||
format=("%d-%m-%Y"), attrs={"type": "date"}
|
||||
)
|
||||
widgets = {
|
||||
"date_purchased": custom_date_widget,
|
||||
"date_refunded": custom_date_widget,
|
||||
}
|
||||
|
||||
|
||||
class GameForm(forms.ModelForm):
|
||||
|
@ -31,3 +45,7 @@ class PlatformForm(forms.ModelForm):
|
|||
class Meta:
|
||||
model = Platform
|
||||
fields = ["name", "group"]
|
||||
|
||||
|
||||
class UnifiedGameForm(forms.ModelForm):
|
||||
GameFormSet = forms.inlineformset_factory(Game, Purchase)
|
||||
|
|
Loading…
Reference in New Issue