add help text for status
This commit is contained in:
@@ -1,58 +1,65 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.forms import DateInput
|
from django.forms import DateInput
|
||||||
|
|
||||||
from .models import Rental, RentalItem
|
from .models import Rental, RentalItem
|
||||||
|
|
||||||
|
|
||||||
class DateInput(DateInput):
|
class DateInput(DateInput):
|
||||||
input_type = "date"
|
input_type = "date"
|
||||||
|
|
||||||
|
|
||||||
class RentalCreateForm(forms.ModelForm):
|
class RentalCreateForm(forms.ModelForm):
|
||||||
# Conformation
|
# Conformation
|
||||||
conformation = forms.BooleanField(
|
conformation = forms.BooleanField(
|
||||||
required=True,
|
required=True,
|
||||||
label=("Ich habe die Verleihregeln gelesen und akzeptiere sie."),
|
label=("Ich habe die Verleihregeln gelesen und akzeptiere sie."),
|
||||||
initial=False,
|
initial=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Rental
|
model = Rental
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
"firstname",
|
"firstname",
|
||||||
"surname",
|
"surname",
|
||||||
"matriculation_number",
|
"matriculation_number",
|
||||||
"email",
|
"email",
|
||||||
"phone",
|
"phone",
|
||||||
"organization",
|
"organization",
|
||||||
"date_start",
|
"date_start",
|
||||||
"date_end",
|
"date_end",
|
||||||
"reason",
|
"reason",
|
||||||
"comment",
|
"comment",
|
||||||
"rentalitems",
|
"rentalitems",
|
||||||
]
|
]
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
"date_start": DateInput(format=("%Y-%m-%d")),
|
"date_start": DateInput(format=("%Y-%m-%d")),
|
||||||
"date_end": DateInput(format=("%Y-%m-%d")),
|
"date_end": DateInput(format=("%Y-%m-%d")),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs) # to get the self.fields set
|
super().__init__(*args, **kwargs) # to get the self.fields set
|
||||||
|
|
||||||
self.fields["firstname"].autofocus = True
|
self.fields["firstname"].autofocus = True
|
||||||
|
|
||||||
|
|
||||||
class RentalAdminForm(forms.ModelForm):
|
class RentalAdminForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Rental
|
model = Rental
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
|
|
||||||
widgets = {"rentalitems": forms.CheckboxSelectMultiple()}
|
widgets = {"rentalitems": forms.CheckboxSelectMultiple()}
|
||||||
|
|
||||||
|
help_texts = {
|
||||||
class RentalItemAdminForm(forms.ModelForm):
|
"status": (
|
||||||
class Meta:
|
"Wird der Status auf 'Verleih genehmigt' oder 'Verleih abgelehnt' gesetzt, wird "
|
||||||
model = RentalItem
|
"eine E-Mail gesendet."
|
||||||
fields = "__all__"
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class RentalItemAdminForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = RentalItem
|
||||||
|
fields = "__all__"
|
||||||
|
|||||||
Reference in New Issue
Block a user