Exemple #1
0
    def __init__(self, config, data_list, request):
        self.config = config  # MOdelStark实例对象
        self.data_list = data_list  # 数据
        self.request = request

        # 分页
        data_count = self.data_list.count()
        current_page = int(self.request.GET.get('page', 1))
        base_path = self.request.path
        self.pagination = Pagination(
            current_page,
            data_count,
            base_path,
            self.request.GET,
            per_page_num=10,
            pager_count=11,
        )

        # 分页后的数据
        self.page_data = self.data_list[self.pagination.start:self.pagination.
                                        end]

        # actions 批量初始化,字段
        # self.actions = self.config.actions # [patch_init]
        self.actions = self.config.new_actions()  # [pathch_delete,patch_init,]
Exemple #2
0
    def __init__(self, config, queryset):

        self.config = config  #这个config对应的是你starkconfig的对象,而这里init的self是changelist的对象

        self.list_display = config.get_list_display()
        self.model_class = config.model_class
        self.request = config.request  # 因为在分页里面要用到request,而这个request在config对象中有
        self.show_add_btn = config.get_show_add_btn()

        # 搜索用
        self.show_search_form = config.get_show_search_form()
        self.search_form_val = config.request.GET.get(config.search_key, '')

        # actions批量操作相关
        self.actions = config.get_actions()
        self.show_actions = config.get_show_actions()

        # 组合搜索
        self.comb_filter = config.get_comb_filter()

        # 分页
        current_page = self.request.GET.get('page', 1)
        total_count = queryset.count()
        base_url = self.request.path_info

        page_obj = Pagination(current_page,
                              total_count,
                              base_url,
                              self.request.GET,
                              per_page_count=5,
                              max_pager_count=5)
        self.page_obj = page_obj

        self.data_list = queryset[page_obj.start:page_obj.end]
Exemple #3
0
    def __init__(self, config, data_list, request):
        self.config = config  # 接收传递过来的配置类对象 ModelStark的实例对象
        self.data_list = data_list  # 接收传递过来的当前表的所有对象
        self.request = request  #  <WSGIRequest: GET '/stark/app01/book/?page=2'>
        # 分页
        data_count = self.data_list.count()
        current_page = int(self.request.GET.get("page", 1))  # 默认是第一页
        base_path = self.request.path  # /stark/app01/book/

        self.pagination = Pagination(
            current_page,
            data_count,
            base_path,
            self.request.GET,
            per_page_num=10,
            pager_count=11,
        )
        # print("data_list", self.data_list)   # data_list <QuerySet [<Book: python葵花宝典>, <Book: go>, <Book: java>]>
        self.page_data = self.data_list[self.pagination.start:self.pagination.
                                        end]
        # print("page_data", self.page_data)   # page_data <QuerySet [<Book: python葵花宝典>]>

        # actions
        # self.actions = self.config.actions   # 拿到配置好的函数对象列表  [patch_init,]
        self.actions = self.config.new_actions()  # 拿到方法运行的返回结果
Exemple #4
0
    def __init__(self, config, data_list, request):
        self.config = config
        self.data_list = data_list
        self.request = request
        # 分页
        data_count = self.data_list.count()
        # 当前页
        current_page = int(self.request.GET.get("page", 1))
        # 路径
        base_path = self.request.path

        self.pagination = Pagination(
            current_page,
            data_count,
            base_path,
            self.request.GET,
            per_page_num=8,
            pager_count=10,
        )

        self.page_data = self.data_list[self.pagination.start:self.pagination.
                                        end]

        # action
        self.actions = self.config.new_actions()  # [patch_init]
Exemple #5
0
    def __init__(self, config, request, queryset):
        self.request = request
        self.config = config
        self.queryset = queryset

        current_page = self.request.GET.get("page", 1)
        base_url = self.request.path_info
        params = self.request.GET
        from stark.utils.page import Pagination
        all_count = queryset.count()
        pagination = Pagination(current_page,
                                all_count,
                                base_url,
                                params,
                                per_page_num=2,
                                pager_count=11)
        self.pagination = pagination
        data_list = self.queryset[pagination.start:pagination.end]
        self.data_list = data_list

        # actions
        self.actions = self.config.get_actions()  #  [patch_init,patch_delette]
        print("actions", self.actions)

        # filter
        self.list_filter = self.config.list_filter
Exemple #6
0
 def __init__(
     self,
     config,
     data_list,
     request,
 ):
     self.config = config
     self.data_list = data_list
     self.request = request
     #分页
     data_count = self.data_list.count()
     base_path = self.request.path
     current_page = int(self.request.GET.get("page", 1))
     self.pagination = Pagination(
         current_page,
         data_count,
         base_path,
         self.request.GET,
         per_page_num=5,
         pager_count=11,
     )
     self.page_data = self.data_list[self.pagination.start:self.pagination.
                                     end]
     #取actions
     self.actions = self.config.new_actions_list()
Exemple #7
0
 def get_pager_queryset(self):
     from stark.utils.page import Pagination
     current_page = self.request.GET.get('page', 1)
     self.pagination = Pagination(self.request,
                                  current_page,
                                  self.queryset,
                                  per_page_num=self.config_obj.per_page_num
                                  or 5)
     queryset = self.queryset[self.pagination.start:self.pagination.end]
     return queryset
Exemple #8
0
    def __init__(self, config_obj, queryset, request):
        self.config_obj = config_obj
        self.queryset = queryset
        self.request = request

        # 分页
        current_page = self.request.GET.get('page')
        pagination = Pagination(current_page,
                                self.queryset.count(),
                                self.request.GET,
                                per_page_num=2)
        self.pagination = pagination
        self.page_queryset = self.queryset[self.pagination.start:self.
                                           pagination.end]
Exemple #9
0
 def getPagination(self):
     current_page = self.request.GET.get("page")
     search_condition = self.get_search_condition()
     filter_condition = self.get_filter_condition()
     filter_queryset = self.queryset_obj.filter(filter_condition).filter(
         search_condition)
     if not current_page:
         current_page = 1
     # print("&&&&&&&",self.request)
     # print("*******",current_page)
     self.pagination = Pagination(current_page,
                                  filter_queryset.count(),
                                  self.request,
                                  per_page=3)
     self.pager_queryset = filter_queryset[self.pagination.start:self.
                                           pagination.end]
Exemple #10
0
 def __init__(self, config, data_list, request):
     self.config = config
     self.data_list = data_list
     self.request = request
     # 分页
     data_count = self.data_list.count()
     current_page = int(self.request.GET.get('page', 1))
     base_path = self.request.path
     params = self.request.GET
     per_page_num = 10
     pager_count = 11
     self.pagination = Pagination(current_page, data_count, base_path, params, per_page_num, pager_count, )
     # 分页后的数据
     self.page_data = self.data_list[self.pagination.start:self.pagination.end]
     # action批量初始化,字段
     self.actions = self.config.new_actions()
Exemple #11
0
    def __init__(self, conf_obj, request,
                 queryset):  # 在这里接收我们需要的参数,这里的conf_obj就是我们传过来的self,也就是配置类对象。
        self.conf_obj = conf_obj
        self.request = request
        self.queryset = queryset

        print('*' * 50, self.conf_obj)
        # 分页
        current_page = self.request.GET.get("page")  # 当前页码
        pagination = Pagination(current_page,
                                self.queryset.count(),
                                self.request.GET,
                                per_page_num=2)
        # 通过内置的分页类,来实例化出我们自己的分页方法。
        self.pagination = pagination
        self.page_queryset = self.queryset[self.pagination.start:self.
                                           pagination.end]
Exemple #12
0
 def __init__(self, config, data_list, request):
     self.config = config
     self.data_list = data_list
     self.request = request
     # 分页
     dataCount = self.data_list.count()
     current_page = int(self.request.GET.get("page", 1))
     base_path = self.request.path
     self.pagination = Pagination(current_page,
                                  dataCount,
                                  base_path,
                                  self.request.GET,
                                  per_page_num=10,
                                  pager_count=9)
     self.page_data = self.data_list[self.pagination.start:self.pagination.
                                     end]
     self.acitons = self.config.actions
Exemple #13
0
    def getPagination(self):
        current_page = self.request.GET.get('page')  # 拿到当前页码数
        # 这里需要进行三步,拿到所有的数据,进行search过滤,然后在进行filter过滤,经过分页,最后才显示出来
        search_condition = self.get_search_condition()  # 拿到搜索的条件

        filter_conditon = self.get_filter_condition()  # 拿到过滤的条件
        print("search_condition>>>>>>>>", filter_conditon)
        # 先按搜索的条件过滤,再按过滤的条件,
        filter_queryset = self.queryset.filter(search_condition)
        print("<<<<<<<<<<<<<<<<<<<<<<<<<")
        filter_queryset = filter_queryset.filter(filter_conditon)
        self.pagination = Pagination(current_page,
                                     filter_queryset.count(),
                                     self.request,
                                     per_page=8)  # 实例化分页器对象
        self.pager_queryset = filter_queryset[
            self.pagination.start:self.pagination.end]  # 通过对所有数据切片出,然后分页显示出来
Exemple #14
0
    def __init__(self, config, data_list, request):
        self.config = config
        self.data_list = data_list
        self.request = request

        # 分页
        data_count = self.data_list.count()
        current_page = self.request.GET.get('page', 1)
        base_path = self.request.path

        self.pagination = Pagination(current_page,
                                     data_count,
                                     base_path,
                                     self.request.GET,
                                     per_page_num=3,
                                     pager_count=11)
        self.page_data = self.data_list[self.pagination.start:self.pagination.
                                        end]

        self.actions = self.config.new_actions()
Exemple #15
0
 def __init__(self, config, data_list, request):
     self.config = config
     self.data_list = data_list
     self.request = request
     # 分页
     data_count = self.data_list.count()  # 获取数据总数量
     current_page = int(self.request.GET.get("page", 1))  # 获取当前页码
     base_url = self.request.path  # 获取url(不带参数)
     # 生成分页对象
     self.paginator = Pagination(current_page,
                                 data_count,
                                 base_url,
                                 self.request.GET,
                                 per_page_num=2,
                                 pager_count=11)
     # 当前页的数据列表
     self.page_data = self.data_list[self.paginator.start:self.paginator.
                                     end]
     # actions
     self.actions = self.config.new_actions()
Exemple #16
0
    def __init__(self, config, data_list, request):
        # 即实例化的ModelStark对象
        self.config = config
        self.data_list = data_list
        self.request = request
        #分页
        current_page = int(self.request.GET.get("page", 1))
        data_count = self.data_list.count()
        base_path = self.request.path
        # 调用分页模块,每页显示的数据
        self.pagination = Pagination(current_page,
                                     data_count,
                                     base_path,
                                     self.request.GET,
                                     per_page_num=3,
                                     pager_count=11)
        self.page_data = self.data_list[self.pagination.start:self.pagination.
                                        end]

        # actions
        self.actions = self.config.new_actions()  # [patch_init,]
Exemple #17
0
    def __init__(self, config, data_list, request):
        self.config = config  #ModelStark中的self
        self.data_list = data_list
        self.request = request
        ###分页###
        data_count = self.data_list.count()
        current_page = int(self.request.GET.get("page", 1))
        base_path = self.request.path

        self.pagination = Pagination(
            current_page,
            data_count,
            base_path,
            self.request.GET,
            per_page_num=10,
            pager_count=11,
        )
        self.page_data = self.data_list[self.pagination.start:self.pagination.
                                        end]

        # actions
        self.actions = self.config.new_actions()  # [patch_init,]
Exemple #18
0
    def get_page_queryset(self):

        current_page = self.request.GET.get("page", 1)  # 默认首页
        self.pagination = Pagination(current_page, self.data_list.count(), self.request, 10)
        page_queryset = self.data_list[self.pagination.start:self.pagination.end]
        return page_queryset