Skip to content

Commit

Permalink
Merge pull request OpenTreeMap#32 from ahinz/topic/forms
Browse files Browse the repository at this point in the history
Add pests to the add form
  • Loading branch information
ahinz committed Nov 8, 2012
2 parents 23f5f73 + 6c52387 commit 8066f4d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion treemap/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TreeAddForm(forms.Form):
plot_length = forms.ChoiceField(required=False, choices=[('1','1'),('2','2'),('3','3'),('4','4'),('5','5'),('6','6'),('7','7'),('8','8'),('9','9'),('10','10'),('11','11'),('12','12'),('13','13'),('14','14'),('15','15'),('99','15+')])
plot_width_in = forms.ChoiceField(required=False, choices=[('1','1'),('2','2'),('3','3'),('4','4'),('5','5'),('6','6'),('7','7'),('8','8'),('9','9'),('10','10'),('11','11')])
plot_length_in = forms.ChoiceField(required=False, choices=[('1','1'),('2','2'),('3','3'),('4','4'),('5','5'),('6','6'),('7','7'),('8','8'),('9','9'),('10','10'),('11','11')])
pests = forms.ChoiceField(choices=settings.CHOICES['pests'], required=False)
plot_type = forms.TypedChoiceField(choices=settings.CHOICES["plot_types"], required=False)
power_lines = forms.TypedChoiceField(choices=settings.CHOICES["powerlines"], required=False)
sidewalk_damage = forms.ChoiceField(choices=settings.CHOICES["sidewalks"], required=False)
Expand All @@ -60,6 +61,7 @@ class TreeAddForm(forms.Form):
def __init__(self, *args, **kwargs):
super(TreeAddForm, self).__init__(*args, **kwargs)
if not self.fields['plot_type'].choices[0][0] == '':
self.fields['pests'].choices.insert(0, ('','Select One...' ) )
self.fields['plot_type'].choices.insert(0, ('','Select One...' ) )
self.fields['power_lines'].choices.insert(0, ('','Select One...' ) )
self.fields['sidewalk_damage'].choices.insert(0, ('','Select One...' ) )
Expand Down Expand Up @@ -165,7 +167,9 @@ def save(self,request):
canopy_condition = self.cleaned_data.get('canopy_condition')

#TODO: fix this
if species or height or canopy_height or dbh or condition or canopy_condition:
pests = self.cleaned_data.get('pests')
if species or height or canopy_height or dbh or \
condition or canopy_condition or pests:
# print species, height, canopy_height, dbh, condition, canopy_condition
if species:
spp = Species.objects.filter(id=species)
Expand All @@ -176,6 +180,8 @@ def save(self,request):
else:
new_tree = Tree()

new_tree.pests = pests

if species_other1:
new_tree.species_other1 = species_other1
if species_other2:
Expand Down

0 comments on commit 8066f4d

Please sign in to comment.