54 lines
1.1 KiB
Python
54 lines
1.1 KiB
Python
from django import forms
|
|
from django.forms import DateInput
|
|
|
|
from .models import Rental, RentalItem
|
|
|
|
|
|
class DateInput(DateInput):
|
|
input_type = "date"
|
|
|
|
|
|
class RentalCreateForm(forms.ModelForm):
|
|
# Conformation
|
|
conformation = forms.BooleanField(
|
|
required=True,
|
|
label=("Ich habe die Verleihregeln gelesen und akzeptiere sie."),
|
|
initial=False,
|
|
)
|
|
|
|
class Meta:
|
|
model = Rental
|
|
|
|
fields = [
|
|
"firstname",
|
|
"surname",
|
|
"matriculation_number",
|
|
"email",
|
|
"phone",
|
|
"organization",
|
|
"date_start",
|
|
"date_end",
|
|
"reason",
|
|
"comment",
|
|
"rentalitems",
|
|
]
|
|
|
|
widgets = {
|
|
"date_start": DateInput(format=("%Y-%m-%d")),
|
|
"date_end": DateInput(format=("%Y-%m-%d")),
|
|
}
|
|
|
|
|
|
class RentalAdminForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Rental
|
|
fields = "__all__"
|
|
|
|
widgets = {"rentalitems": forms.CheckboxSelectMultiple()}
|
|
|
|
|
|
class RentalItemAdminForm(forms.ModelForm):
|
|
class Meta:
|
|
model = RentalItem
|
|
fields = "__all__"
|