def version_sidebar(request, form_data, facets): appver = '' # If appver is in the request, we read it cleaned via form_data. if 'appver' in request.GET or form_data.get('appver'): appver = form_data.get('appver') app = unicode(request.APP.pretty) exclude_versions = getattr(request.APP, 'exclude_versions', []) # L10n: {0} is an application, such as Firefox. This means "any version of # Firefox." rv = [FacetLink(_(u'Any {0}').format(app), dict(appver='any'), not appver)] vs = [dict_from_int(f['term']) for f in facets['appversions']] # Insert the filtered app version even if it's not a facet. av_dict = version_dict(appver) if av_dict and av_dict not in vs and av_dict['major']: vs.append(av_dict) # Valid versions must be in the form of `major.minor`. vs = set((v['major'], v['minor1'] if v['minor1'] not in (None, 99) else 0) for v in vs) versions = ['%s.%s' % v for v in sorted(vs, reverse=True)] for version, floated in zip(versions, map(float, versions)): if (floated not in exclude_versions and floated > request.APP.min_display_version): rv.append(FacetLink('%s %s' % (app, version), dict(appver=version), appver == version)) return rv
def version_sidebar(request, form_data, facets): appver = '' # If appver is in the request, we read it cleaned via form_data. if 'appver' in request.GET or form_data.get('appver'): appver = form_data.get('appver') app = unicode(request.APP.pretty) exclude_versions = getattr(request.APP, 'exclude_versions', []) # L10n: {0} is an application, such as Firefox. This means "any version of # Firefox." rv = [FacetLink(_(u'Any {0}').format(app), dict(appver='any'), not appver)] vs = [dict_from_int(f['term']) for f in facets['appversions']] # Insert the filtered app version even if it's not a facet. av_dict = version_dict(appver) if av_dict and av_dict not in vs and av_dict['major']: vs.append(av_dict) # Valid versions must be in the form of `major.minor`. vs = set((v['major'], v['minor1'] if v['minor1'] not in (None, 99) else 0) for v in vs) versions = ['%s.%s' % v for v in sorted(vs, reverse=True)] for version, floated in zip(versions, map(float, versions)): if (floated not in exclude_versions and floated > request.APP.min_display_version): rv.append( FacetLink('%s %s' % (app, version), dict(appver=version), appver == version)) return rv
def version_sidebar(request, form_data, facets): appver = "" # If appver is in the request, we read it cleaned via form_data. if "appver" in request.GET or form_data.get("appver"): appver = form_data.get("appver") app = unicode(request.APP.pretty) exclude_versions = getattr(request.APP, "exclude_versions", []) # L10n: {0} is an application, such as Firefox. This means "any version of # Firefox." rv = [FacetLink(_(u"Any {0}").format(app), dict(appver="any"), not appver)] vs = [dict_from_int(f["term"]) for f in facets["appversions"]] # Insert the filtered app version even if it's not a facet. av_dict = version_dict(appver) if av_dict and av_dict not in vs and av_dict["major"]: vs.append(av_dict) # Valid versions must be in the form of `major.minor`. vs = set((v["major"], v["minor1"] if v["minor1"] not in (None, 99) else 0) for v in vs) versions = ["%s.%s" % v for v in sorted(vs, reverse=True)] for version, floated in zip(versions, map(float, versions)): if floated not in exclude_versions and floated > request.APP.min_display_version: rv.append(FacetLink("%s %s" % (app, version), dict(appver=version), appver == version)) return rv
def test_version_dict(): eq_(version_dict('5.0'), {'major': 5, 'minor1': 0, 'minor2': None, 'minor3': None, 'alpha': None, 'alpha_ver': None, 'pre': None, 'pre_ver': None})
def test_version_dict(): eq_( version_dict("5.0"), { "major": 5, "minor1": 0, "minor2": None, "minor3": None, "alpha": None, "alpha_ver": None, "pre": None, "pre_ver": None, }, )
def version_sidebar(request, query, facets): appver = query.get('appver') app = unicode(request.APP.pretty) exclude_versions = getattr(request.APP, 'exclude_versions', []) # L10n: {0} is an application, such as Firefox. This means "any version of # Firefox." rv = [FacetLink(_(u'Any {0}').format(app), dict(appver=''), not appver)] vs = [dict_from_int(f['term']) for f in facets['appversions']] # Insert the filtered app version even if it's not a facet. av_dict = version_dict(appver) if av_dict and av_dict not in vs and av_dict['major']: vs.append(av_dict) vs = set((v['major'], v['minor1'] if v['minor1'] != 99 else 0) for v in vs) versions = ['%s.%s' % v for v in sorted(vs, reverse=True)] for version, floated in zip(versions, map(float, versions)): if (floated not in exclude_versions and floated > request.APP.min_display_version): rv.append(FacetLink('%s %s' % (app, version), dict(appver=version), appver == version)) return rv
def __init__(self, *args, **kwargs): super(AppVersion, self).__init__(*args, **kwargs) # Add all the major, minor, ..., version attributes to the object. self.__dict__.update(compare.version_dict(self.version or ''))
def __init__(self, *args, **kwargs): super(AppVersion, self).__init__(*args, **kwargs) self.__dict__.update(compare.version_dict(self.version or ''))