init project tests
This commit is contained in:
parent
d0ff728224
commit
7c9318c778
44 changed files with 4431 additions and 49 deletions
|
@ -18,14 +18,53 @@ class AviaryEditForm(forms.ModelForm):
|
|||
}
|
||||
model = Aviary
|
||||
fields = [
|
||||
"name",
|
||||
"location",
|
||||
"description",
|
||||
"capacity",
|
||||
"current_occupancy",
|
||||
"contact_person",
|
||||
"contact_phone",
|
||||
"contact_email",
|
||||
"notes",
|
||||
"condition",
|
||||
"last_ward_round",
|
||||
"comment",
|
||||
]
|
||||
labels = {
|
||||
"name": _("Name"),
|
||||
"location": _("Standort"),
|
||||
"description": _("Bezeichnung"),
|
||||
"capacity": _("Kapazität"),
|
||||
"current_occupancy": _("Aktuelle Belegung"),
|
||||
"contact_person": _("Ansprechpartner"),
|
||||
"contact_phone": _("Telefon"),
|
||||
"contact_email": _("E-Mail"),
|
||||
"notes": _("Notizen"),
|
||||
"condition": _("Zustand"),
|
||||
"last_ward_round": _("Letzte Inspektion"),
|
||||
"commen": _("Bemerkungen"),
|
||||
"comment": _("Bemerkungen"),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# Set help text for key fields
|
||||
if 'capacity' in self.fields:
|
||||
self.fields['capacity'].help_text = str(_("Maximum number of birds this aviary can hold"))
|
||||
if 'current_occupancy' in self.fields:
|
||||
self.fields['current_occupancy'].help_text = str(_("Current number of birds in this aviary"))
|
||||
|
||||
def clean(self):
|
||||
"""Custom validation for the form."""
|
||||
cleaned_data = super().clean()
|
||||
capacity = cleaned_data.get('capacity')
|
||||
current_occupancy = cleaned_data.get('current_occupancy')
|
||||
|
||||
# Validate that occupancy doesn't exceed capacity
|
||||
if capacity is not None and current_occupancy is not None:
|
||||
if current_occupancy > capacity:
|
||||
raise forms.ValidationError({
|
||||
'current_occupancy': _('Current occupancy cannot exceed capacity.')
|
||||
})
|
||||
|
||||
return cleaned_data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue