Permalink
Browse files

Fixes bug 1025944 - Ensured better verification of existence of field…

…s in SuperSearch form.
  • Loading branch information...
1 parent df77a20 commit d1d4f5ec6651f40cbd02df2969370b6d7e998f59 @adngdb adngdb committed Jun 17, 2014
Showing with 13 additions and 11 deletions.
  1. +13 −11 webapp-django/crashstats/supersearch/forms.py
View
24 webapp-django/crashstats/supersearch/forms.py
@@ -2,7 +2,7 @@
from django import forms
-from crashstats.supersearch import form_fields
+from . import form_fields
def make_restricted_choices(sequence, exclude=None):
@@ -26,13 +26,6 @@ def __init__(
):
super(self.__class__, self).__init__(*args, **kwargs)
- # Default values
- platforms = [(x['name'], x['name']) for x in current_platforms]
- products = [(x, x) for x in current_products]
- versions = [
- (v['version'], v['version']) for v in current_versions
- ]
-
# Generate the list of fields.
for field_data in all_fields.values():
if (
@@ -70,9 +63,18 @@ def __init__(
self.fields[field_data['name']] = field_obj
- self.fields['product'].choices = products
- self.fields['version'].choices = versions
- self.fields['platform'].choices = platforms
+ # Default values loaded from a database.
+ if 'product' in self.fields:
+ products = [(x, x) for x in current_products]
+ self.fields['product'].choices = products
+ if 'version' in self.fields:
+ versions = [
+ (v['version'], v['version']) for v in current_versions
+ ]
+ self.fields['version'].choices = versions
+ if 'platform' in self.fields:
+ platforms = [(x['name'], x['name']) for x in current_platforms]
+ self.fields['platform'].choices = platforms
def get_fields_list(self):
'''Return a dictionary describing the fields, to pass to the

0 comments on commit d1d4f5e

Please sign in to comment.