예제 #1
0
파일: controllers.py 프로젝트: kamalhg/eden
    def summary_urls(resource, url, filters):
        """
            Construct the summary tabs URLs for a saved filter.

            @param resource: the S3Resource
            @param url: the filter page URL
            @param filters: the filter GET vars
        """

        links = {}

        if not url:
            return links

        get_vars = S3URLQuery.parse_url(url)
        get_vars.pop("t", None)
        get_vars.pop("w", None)
        get_vars.update(filters)

        list_vars = []
        for (k, v) in get_vars.items():
            if v is None:
                continue
            values = v if type(v) is list else [v]
            for value in values:
                if value is not None:
                    list_vars.append((k, value))
        base_url = url.split("?", 1)[0]

        summary_config = S3Summary._get_config(resource)
        tab_idx = 0
        for section in summary_config:

            if section.get("common"):
                continue
            section_id = section["name"]

            tab_vars = list_vars + [("t", str(tab_idx))]
            links[section["name"]] = "%s?%s" % (base_url, urlencode(tab_vars))
            tab_idx += 1

        return links
예제 #2
0
    def summary_urls(resource, url, filters):
        """
            Construct the summary tabs URLs for a saved filter.

            @param resource: the S3Resource
            @param url: the filter page URL
            @param filters: the filter GET vars
        """

        links = {}

        if not url:
            return links

        get_vars = S3URLQuery.parse_url(url)
        get_vars.pop("t", None)
        get_vars.pop("w", None)
        get_vars.update(filters)

        list_vars = []
        for (k, v) in get_vars.items():
            if v is None:
                continue
            values = v if type(v) is list else [v]
            for value in values:
                if value is not None:
                    list_vars.append((k, value))
        base_url = url.split("?", 1)[0]

        summary_config = S3Summary._get_config(resource)
        tab_idx = 0
        for section in summary_config:

            if section.get("common"):
                continue
            section_id = section["name"]

            tab_vars = list_vars + [("t", str(tab_idx))]
            links[section["name"]] = "%s?%s" % (base_url, urlencode(tab_vars))
            tab_idx += 1

        return links