예제 #1
0
파일: views.py 프로젝트: chowse/reporter
def _common_data(form):
    oses = OSES.values()
    product_name = form.cleaned_data["product"]
    if product_name:
        product = APPS[product_name]
        oses = [os for os in oses if product in os.apps]
    return {"form": form,
            "oses": oses,
            "latest_betas": LATEST_BETAS,
            "products": PROD_CHOICES,
            "product": form.cleaned_data["product"],
            "versions": VERSION_CHOICES[product],
            "version": form.cleaned_data["version"]}
예제 #2
0
파일: forms.py 프로젝트: chowse/reporter
    def clean(self):
        cleaned = super(WebsiteIssuesSearchForm, self).clean()

        for field_name, field_def in FIELD_DEFS.items():
            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("os"):
            product = APPS[cleaned.get("product")]
            possible_oses = [os for os in OSES.values() if product in os.apps]
            if OSES[cleaned.get("os")] not in possible_oses:
                cleaned["os"] = FIELD_DEFS["os"].default

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

        return cleaned
예제 #3
0
def os_name(os):
    """Convert an OS short name into a human readable version."""
    return OSES.get(os, OS_OTHER).pretty