- Add bloom_months to Plant and Species models (migration 0003)
- Swap pruning_months form field for bloom_months throughout
- Plant detail shows green bloom strip instead of pruning strip
- Dashboard shows 'Blooming now' count and list instead of overdue pruning
- Remove ✂️ pruning calendar from nav (feature hidden, backend intact)
- Update dashboard tests to reflect new context
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
from django import forms
|
|
from .models import Plant, PruningLog
|
|
|
|
MONTH_CHOICES = [
|
|
('1', 'Jan'), ('2', 'Feb'), ('3', 'Mar'), ('4', 'Apr'),
|
|
('5', 'May'), ('6', 'Jun'), ('7', 'Jul'), ('8', 'Aug'),
|
|
('9', 'Sep'), ('10', 'Oct'), ('11', 'Nov'), ('12', 'Dec'),
|
|
]
|
|
|
|
|
|
class PlantForm(forms.ModelForm):
|
|
bloom_months = forms.MultipleChoiceField(
|
|
choices=MONTH_CHOICES,
|
|
widget=forms.CheckboxSelectMultiple,
|
|
required=False,
|
|
label='Bloom months',
|
|
)
|
|
|
|
class Meta:
|
|
model = Plant
|
|
fields = ['name', 'location', 'is_indoor', 'bloom_months', 'photo', 'notes']
|
|
widgets = {
|
|
'notes': forms.Textarea(attrs={'rows': 3}),
|
|
'name': forms.TextInput(attrs={'class': 'form-control'}),
|
|
'location': forms.TextInput(attrs={'class': 'form-control'}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
if self.instance.pk and self.instance.bloom_months:
|
|
self.initial['bloom_months'] = [str(m) for m in self.instance.bloom_months]
|
|
elif not self.instance.pk and self.initial.get('bloom_months'):
|
|
self.initial['bloom_months'] = [str(m) for m in self.initial['bloom_months']]
|
|
|
|
def clean_bloom_months(self):
|
|
return [int(m) for m in self.cleaned_data.get('bloom_months', [])]
|
|
|
|
|
|
class PruningLogForm(forms.ModelForm):
|
|
class Meta:
|
|
model = PruningLog
|
|
fields = ['pruned_on', 'notes']
|
|
widgets = {
|
|
'pruned_on': forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}),
|
|
'notes': forms.Textarea(attrs={'rows': 2, 'class': 'form-control'}),
|
|
}
|