Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Lets take the data from VersionCount for select boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelbabu committed Oct 26, 2011
1 parent 04e2720 commit afa6b95
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions apps/feedback/models.py
Expand Up @@ -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):
Expand Down
14 changes: 7 additions & 7 deletions apps/search/forms.py
Expand Up @@ -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')),
Expand Down
16 changes: 14 additions & 2 deletions apps/search/views.py
Expand Up @@ -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')

Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit afa6b95

Please sign in to comment.