timetracker/games/forms.py

62 lines
1.4 KiB
Python
Raw Normal View History

2022-12-31 13:18:27 +00:00
from django import forms
2023-01-15 22:39:52 +00:00
2023-02-18 20:12:18 +00:00
from games.models import Game, Platform, Purchase, Session, Edition, Device
2022-12-31 13:18:27 +00:00
class SessionForm(forms.ModelForm):
2023-02-18 19:49:46 +00:00
purchase = forms.ModelChoiceField(
queryset=Purchase.objects.order_by("edition__name")
)
2022-12-31 13:18:27 +00:00
class Meta:
model = Session
fields = [
"purchase",
"timestamp_start",
"timestamp_end",
"duration_manual",
2023-02-18 20:12:18 +00:00
"device",
2022-12-31 13:18:27 +00:00
"note",
]
class PurchaseForm(forms.ModelForm):
2023-02-18 19:49:46 +00:00
edition = forms.ModelChoiceField(queryset=Edition.objects.order_by("name"))
platform = forms.ModelChoiceField(queryset=Platform.objects.order_by("name"))
2022-12-31 13:18:27 +00:00
class Meta:
model = Purchase
2023-02-18 19:53:47 +00:00
fields = [
"edition",
"platform",
"date_purchased",
"date_refunded",
"price",
"price_currency",
"ownership_type",
2023-02-18 19:53:47 +00:00
]
2023-02-18 19:49:46 +00:00
class EditionForm(forms.ModelForm):
class Meta:
model = Edition
fields = ["game", "name", "platform"]
2022-12-31 13:18:27 +00:00
class GameForm(forms.ModelForm):
class Meta:
model = Game
fields = ["name", "wikidata"]
2023-01-04 16:23:34 +00:00
class PlatformForm(forms.ModelForm):
class Meta:
model = Platform
fields = ["name", "group"]
2023-02-18 20:12:18 +00:00
class DeviceForm(forms.ModelForm):
class Meta:
model = Device
fields = ["name", "type"]