Permalink
Browse files

Lets take the data from VersionCount for select boxes

  • Loading branch information...
1 parent 04e2720 commit afa6b950e422bae7ffff01f2af04da63b648fa3e @nigelbabu nigelbabu committed Oct 26, 2011
Showing with 22 additions and 9 deletions.
  1. +1 −0 apps/feedback/models.py
  2. +7 −7 apps/search/forms.py
  3. +14 −2 apps/search/views.py
View
@@ -231,6 +231,7 @@ class VersionCount(ModelBase):
class Meta:
unique_together = (('product', 'version'))
db_table = 'version_count'
+ ordering = ['-version_int']
def update_version_int(sender, instance, **kwargs):
View
@@ -11,22 +11,22 @@
from input import (FIREFOX, MOBILE, PLATFORM_USAGE, LATEST_BETAS,
KNOWN_DEVICES, KNOWN_MANUFACTURERS)
from input.fields import DateInput, SearchInput
-
+from feedback.models import VersionCount
PROD_CHOICES = (
(FIREFOX.short, FIREFOX.pretty),
(MOBILE.short, MOBILE.pretty),
)
+VERSIONS = VersionCount.objects.filter(active=1)
+
VERSION_CHOICES = {
FIREFOX: ([('--', _lazy(u'-- all --', 'version_choice'))] +
- [(v, v) for v in (FIREFOX.extra_versions +
- FIREFOX.release_versions +
- FIREFOX.beta_versions)]),
+ [(v.version, v.version) for v in VERSIONS
+ if v.product == FIREFOX.id]),
MOBILE: ([('--', _lazy(u'-- all --', 'version_choice'))] +
- [(v, v) for v in (MOBILE.extra_versions +
- MOBILE.release_versions +
- MOBILE.beta_versions)]),
+ [(v.version, v.version) for v in VERSIONS
+ if v.product == MOBILE.id]),
}
SENTIMENT_CHOICES = [('', _lazy('-- all --', 'sentiment_choice')),
View
@@ -13,12 +13,13 @@
from product_details.version_compare import Version
from tower import ugettext as _, ugettext_lazy as _lazy
-from input import (PRODUCTS, PRODUCT_IDS, FIREFOX, LATEST_BETAS,
+from input import (PRODUCTS, PRODUCT_IDS, FIREFOX, MOBILE, LATEST_BETAS,
OPINION_PRAISE, OPINION_ISSUE, OPINION_IDEA, OPINION_TYPES)
from input.decorators import cache_page, forward_mobile
from input.urlresolvers import reverse
+from feedback.models import VersionCount
from search.client import Client, SearchError
-from search.forms import ReporterSearchForm, PROD_CHOICES, VERSION_CHOICES
+from search.forms import ReporterSearchForm, PROD_CHOICES
log = commonware.log.getLogger('i.search')
@@ -195,6 +196,17 @@ def index(request):
of the page is "Search Results".
"""
+ VERSIONS = VersionCount.objects.filter(active=1)
+
+ VERSION_CHOICES = {
+ FIREFOX: ([('--', _lazy(u'-- all --', 'version_choice'))] +
+ [(v.version, v.version) for v in VERSIONS
+ if v.product == FIREFOX.id]),
+ MOBILE: ([('--', _lazy(u'-- all --', 'version_choice'))] +
+ [(v.version, v.version) for v in VERSIONS
+ if v.product == MOBILE.id]),
+ }
+
try:
meta = ('type', 'locale', 'platform', 'day_sentiment', 'manufacturer',
'device')

0 comments on commit afa6b95

Please sign in to comment.