Ejemplo n.º 1
0
    def clean(self):
        cleaned = super(WebsiteIssuesSearchForm, self).clean()

        for field_name, field_def in FIELD_DEFS.items():
            if field_name not in cleaned:
                cleaned[field_name] = field_def.default
                continue
            if BooleanField == type(field_def.field) \
                    and cleaned.get(field_name) not in (True, False):
                cleaned[field_name] = field_def.default
            if ChoiceField == type(field_def.field) \
                    and cleaned.get(field_name) not in field_def.keys:
                cleaned[field_name] = field_def.default

        if cleaned.get('product') and cleaned.get('platform'):
            product = PRODUCTS[cleaned.get('product')]
            possible_platforms = [platform for platform in PLATFORMS.values()
                                  if product in platform.prods]

            if PLATFORMS[cleaned.get('platform')] not in possible_platforms:
                cleaned['platform'] = FIELD_DEFS['platform'].default

        if not cleaned.get('version'):
            cleaned['version'] = VERSION_CHOICES[FIREFOX][0][0]

        if cleaned.get('page') is not None:
            cleaned['page'] = max(1, int(cleaned['page']))
        else:
            cleaned['page'] = FIELD_DEFS['page'].default

        return cleaned
Ejemplo n.º 2
0
    def clean(self):
        cleaned = super(WebsiteIssuesSearchForm, self).clean()

        for field_name, field_def in FIELD_DEFS.items():
            if field_name not in cleaned:
                cleaned[field_name] = field_def.default
                continue
            if BooleanField == type(field_def.field) \
                    and cleaned.get(field_name) not in (True, False):
                cleaned[field_name] = field_def.default
            if ChoiceField == type(field_def.field) \
                    and cleaned.get(field_name) not in field_def.keys:
                cleaned[field_name] = field_def.default

        if cleaned.get('product') and cleaned.get('platform'):
            product = PRODUCTS[cleaned.get('product')]
            possible_platforms = [
                platform for platform in PLATFORMS.values()
                if product in platform.prods
            ]

            if PLATFORMS[cleaned.get('platform')] not in possible_platforms:
                cleaned['platform'] = FIELD_DEFS['platform'].default

        if not cleaned.get('version'):
            cleaned['version'] = (getattr(FIREFOX, 'default_version', None)
                                  or Version(LATEST_BETAS[FIREFOX]).simplified)

        if cleaned.get('page') is not None:
            cleaned['page'] = max(1, int(cleaned['page']))
        else:
            cleaned['page'] = FIELD_DEFS['page'].default

        return cleaned
Ejemplo n.º 3
0
    def clean(self):
        cleaned = super(WebsiteIssuesSearchForm, self).clean()

        for field_name, field_def in FIELD_DEFS.items():
            if field_name not in cleaned:
                cleaned[field_name] = field_def.default
                continue
            if BooleanField == type(field_def.field) and cleaned.get(field_name) not in (True, False):
                cleaned[field_name] = field_def.default
            if ChoiceField == type(field_def.field) and cleaned.get(field_name) not in field_def.keys:
                cleaned[field_name] = field_def.default

        if cleaned.get("product") and cleaned.get("platform"):
            product = PRODUCTS[cleaned.get("product")]
            possible_platforms = [platform for platform in PLATFORMS.values() if product in platform.prods]
            if PLATFORMS[cleaned.get("platform")] not in possible_platforms:
                cleaned["platform"] = FIELD_DEFS["platform"].default

        if not cleaned.get("version"):
            product = cleaned.get("product", FIREFOX)
            cleaned["version"] = VERSION_CHOICES[get_channel()][product][0][0]

        if cleaned.get("page") is not None:
            cleaned["page"] = max(1, int(cleaned["page"]))
        else:
            cleaned["page"] = FIELD_DEFS["page"].default

        return cleaned
Ejemplo n.º 4
0
def _common_data(form):
    platforms = PLATFORMS.values()
    product_name = form.cleaned_data["product"]
    if product_name:
        product = PRODUCTS[product_name]
        platforms = [platform for platform in platforms if product in platform.prods]
    return {"form": form,
            "platforms": platforms,
            "products": form.fields["product"].choices,
            "product": product,
            "versions": VERSION_CHOICES[get_channel()][product],
            "version": form.cleaned_data["version"]}
Ejemplo n.º 5
0
def _common_data(form):
    platforms = PLATFORMS.values()
    product_name = form.cleaned_data["product"]
    if product_name:
        product = PRODUCTS[product_name]
        platforms = [p for p in platforms if product in p.prods]
    return {"form": form,
            "platforms": platforms,
            "products": form.fields["product"].choices,
            "product": product,
            "versions": VERSION_CHOICES[product],
            "version": form.cleaned_data["version"]}
Ejemplo n.º 6
0
def platform_name(platform):
    """Convert a PLATFORM short name into a human readable version."""
    return PLATFORMS.get(platform, PLATFORM_OTHER).pretty