def get(self):
        current_page = self.get_argument('page','')
        if current_page:
            current_page = int(current_page)
        else:
            current_page = 1

        total_num = dbtool.get_imgs_count()
        page_num = total_num/PAGE_NUMBER+1
        start_num = (current_page-1)*PAGE_NUMBER+1

        if page_num<current_page:
            current_page = page_num

        allitems = dbtool.get_imgs(PAGE_NUMBER, (current_page-1)*PAGE_NUMBER)

        #get the start and end page num
        if current_page>3:
            start_page_num = current_page-3
        else:
            start_page_num = 1

        end_page_num = start_page_num+6
        if end_page_num>page_num:
            end_page_num = page_num
            start_page_num = end_page_num-6
            if start_page_num<1:
                start_page_num = 1

        end_num  = start_num+len(allitems)-1



        #get tb_rows

        return self.render('preview.html',
                           page_name  = 'preview',
                           current_page = current_page,
                           page_num = page_num,
                           total_num = total_num,
                           start_num = start_num,
                           end_num = end_num,
                           start_page_num = start_page_num,
                           end_page_num = end_page_num,
                           allitems = allitems)
Exemple #2
0
    def get(self):
        current_page = self.get_argument('page', '')
        if current_page:
            current_page = int(current_page)
        else:
            current_page = 1

        total_num = dbtool.get_imgs_count()
        page_num = total_num / PAGE_NUMBER + 1
        start_num = (current_page - 1) * PAGE_NUMBER + 1

        if page_num < current_page:
            current_page = page_num

        allitems = dbtool.get_imgs(PAGE_NUMBER,
                                   (current_page - 1) * PAGE_NUMBER)

        #get the start and end page num
        if current_page > 3:
            start_page_num = current_page - 3
        else:
            start_page_num = 1

        end_page_num = start_page_num + 6
        if end_page_num > page_num:
            end_page_num = page_num
            start_page_num = end_page_num - 6
            if start_page_num < 1:
                start_page_num = 1

        end_num = start_num + len(allitems) - 1

        #get tb_rows

        return self.render('preview.html',
                           page_name='preview',
                           current_page=current_page,
                           page_num=page_num,
                           total_num=total_num,
                           start_num=start_num,
                           end_num=end_num,
                           start_page_num=start_page_num,
                           end_page_num=end_page_num,
                           allitems=allitems)
Exemple #3
0
    def get(self):
        basic_config_dict = {}
        basic_config_dict['device_name'] = ''
        basic_config_dict['device_id'] = ''
        basic_config_dict['device_type'] = ''
        basic_config_dict['channel_number'] = ''
        basic_config_dict['storage'] = ''
        basic_config_dict['used_storage'] = ''
        get_basic_conf_value(basic_config_dict)
        allitems = dbtool.get_imgs(1, 0)
        total_num = dbtool.get_imgs_count()
        basic_config_dict['img_num'] = total_num
        newest_img = allitems
	if len(allitems)>1:
		newest_img = allitems[0]
	else:
		newest_img = []
        return self.render('home.html',
                           page_name = 'home',
                           basic_config_dict = basic_config_dict,
                           newest_img = newest_img
                           )