add notes app

This commit is contained in:
Java-Fish 2025-06-10 14:49:08 +02:00
parent acb398be1c
commit a29376b3c5
38 changed files with 1720 additions and 45 deletions

View file

@ -18,53 +18,30 @@ 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"),
"description": _("Beschreibung"),
"condition": _("Zustand"),
"last_ward_round": _("Letzte Inspektion"),
"last_ward_round": _("Letzte Visite"),
"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"))
# Mark required fields
self.fields['description'].required = True
self.fields['condition'].required = True
self.fields['last_ward_round'].required = True
# Set today as default for last_ward_round
if not self.instance.pk and 'last_ward_round' in self.fields:
self.fields['last_ward_round'].initial = date.today
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