def browse_group(self):

        skip = (self.current_page - 1) * self.per_page
        take = self.per_page
        select_filter = utils.create_filter_criteria(self.section, self.group)
        results_count = utils.get_course_meta(select_filter)["totalResultCount"]
        courses = utils.get_course_data(select_filter, skip, take)

        utils.add_directory(utils.text_green % control.lang(30501), utils.icon_search, utils.icon_search,
                            "%s?action=search&section=%s&group=%s" % (sys.argv[0], self.section, self.group))

        for course in courses:
            name = course["courseName"].encode('utf-8')
            thumb = course["courseImage"]
            if thumb is None or thumb == '':
                thumb = self.icon
            cid = course["id"]
            utils.add_directory(name, thumb, thumb,
                                "%s?action=view-course&id=%s&url=%s" % (sys.argv[0], cid, utils.url_course % cid))
        has_more = (results_count - (skip+self.per_page)) > 0
        if has_more:
            next_url = "%s?action=browse-group&group=%s&section=%s&page=%i" % (
                sys.argv[0], urllib.quote_plus(self.group, safe=':/'), urllib.quote_plus(self.section, safe=':/'),
                self.current_page + 1)
            utils.add_next_page(next_url, self.current_page + 1)
        control.directory_end(False)
        return
Example #2
0
    def browse_group(self):

        skip = (self.current_page - 1) * self.per_page
        take = self.per_page
        select_filter = utils.create_filter_criteria(self.section, self.group)
        results_count = utils.get_course_meta(
            select_filter)["totalResultCount"]
        courses = utils.get_course_data(select_filter, skip, take)

        utils.add_directory(
            utils.text_green % control.lang(30501), utils.icon_search,
            utils.icon_search, "%s?action=search&section=%s&group=%s" %
            (sys.argv[0], self.section, self.group))

        for course in courses:
            name = course["courseName"].encode('utf-8')
            thumb = course["courseImage"]
            if thumb is None or thumb == '':
                thumb = self.icon
            cid = course["id"]
            utils.add_directory(
                name, thumb, thumb, "%s?action=view-course&id=%s&url=%s" %
                (sys.argv[0], cid, utils.url_course % cid))
        has_more = (results_count - (skip + self.per_page)) > 0
        if has_more:
            next_url = "%s?action=browse-group&group=%s&section=%s&page=%i" % (
                sys.argv[0], urllib.quote_plus(self.group, safe=':/'),
                urllib.quote_plus(self.section,
                                  safe=':/'), self.current_page + 1)
            utils.add_next_page(next_url, self.current_page + 1)
        control.directory_end(False)
        return
    def search(self):

        if self.search_term is None or self.search_term == '':
            t = control.lang(30201).encode('utf-8')
            k = control.keyboard('', t)
            k.doModal()
            self.search_term = k.getText() if k.isConfirmed() else None

        if self.search_term is None or self.search_term == '':
            return

        skip = (self.current_page-1) * self.per_page
        take = self.per_page
        select_filter = utils.create_filter_criteria(self.section, self.group, self.search_term)
        results_count = utils.get_course_meta(select_filter)["totalResultCount"]
        courses = utils.get_course_data(select_filter, skip, take)

        for course in courses:
            name = course["courseName"].encode('utf-8')
            thumb = course["courseImage"]
            if thumb is None or thumb == '':
                thumb = self.icon
            cid = course["id"]
            utils.add_directory(name, thumb, thumb,
                                "%s?action=view-course&id=%s&url=%s" % (sys.argv[0], cid, utils.url_course % cid))
        has_more = (results_count - (skip+self.per_page)) > 0
        if has_more:
            next_url = "%s?action=search&group=%s&section=%s&page=%i&query=%s" % (
                sys.argv[0], urllib.quote_plus(self.group, safe=':/'), urllib.quote_plus(self.section, safe=':/'),
                self.current_page + 1, self.search_term)
            utils.add_next_page(next_url, self.current_page + 1)
        control.directory_end(False)
        return