Example #1
0
    def __init__(self, request, qs, title=None, list_display=None, list_filter=None, search_fields=None,
                 list_per_page=25, list_subsets=None, exclude=None, relation=None, readonly=False, is_list_view=False,
                 help_text=None, url=None, template='datagrid.html', uid=None):

        super(Paginator, self).__init__(is_list_view and '_' or abs(hash(title)), request)
        if relation:
            qs = qs.model.objects.filter(pk__in=qs.values_list('pk', flat=True))
        else:
            qs = qs.all()
        self.qs = qs
        self.title = title
        self.list_display = list_display
        self.list_filter = list_filter
        self.search_fields = search_fields
        self.list_per_page = list_per_page
        self.subsets = None
        self.exclude = exclude
        self.relation = relation
        self.readonly = readonly
        self.is_list_view = is_list_view
        self.icon = get_metadata(qs.model, 'icon', None)
        self.list_total = get_metadata(qs.model, 'list_total', None)
        self.ordering = get_metadata(qs.model, 'ordering', None)
        self.template = get_metadata(self.qs.model, 'list_template', template)
        self.help_text = help_text
        self.url = url
        self.display_checkboxes = False
        self.action_names = None

        self.filters = []
        self.pagination = ''

        self.original_qs = qs
        self.count = None

        # tabs
        self.tabs = []
        self.current_tab = self._get_from_request('tab', None)
        if list_subsets is not None:
            self.subsets = OrderedDict()
            for subset_name in list_subsets:
                self.subsets[subset_name] = {}
        self._load_tabs()

        # list display
        self._configure_list_display()

        # column names
        self.column_names = []
        self._configure_column_names()

        # drop down
        self.class_dropdown = GroupDropDown(request, style='class-action')
        self.queryset_dropdown = GroupDropDown(request, style='queryset-action disabled')
        self.drop_down = ModelDropDown(request, qs.model)
        self.mobile = mobile(self.request)

        if hasattr(self.qs, 'permission_map'):
            self.permission_map = self.qs.permission_map
        self.qs = self._filter_queryset(self.qs)
Example #2
0
    def __init__(self,
                 request,
                 qs,
                 title=None,
                 list_display=None,
                 list_filter=None,
                 search_fields=None,
                 list_per_page=25,
                 list_subsets=None,
                 exclude=None,
                 to=None,
                 readonly=False,
                 is_list_view=False):

        super(Paginator, self).__init__(request)

        self.id = abs(hash(title))
        self.qs = qs.all()
        self.title = title
        self.list_display = list_display
        self.list_filter = list_filter
        self.search_fields = search_fields
        self.list_per_page = list_per_page
        self.list_subsets = list_subsets
        self.exclude = exclude
        self.to = to
        self.readonly = readonly
        self.is_list_view = is_list_view
        self.icon = get_metadata(qs.model, 'icon', None)
        self.list_total = get_metadata(qs.model, 'list_total', None)

        self.subset_actions = []
        self.filters = []
        self.pagination = ''

        self.original_qs = qs

        # list display
        self._configure_list_display()

        # column names
        self.column_names = []
        self._configure_column_names()

        # tabs
        self.tabs = []
        self.current_tab = self._get_from_request('tab', None)
        self._load_tabs()

        # drop down
        self.paginator_dropdown = GroupDropDown(request)
        self.subset_dropdown = GroupDropDown(request)
        self.drop_down = ModelDropDown(request, qs.model)
        self.mobile = mobile(self.request)

        if hasattr(self.qs, 'permission_map'):
            self.permission_map = self.qs.permission_map
        self.qs = self._filter_queryset(self.qs)
Example #3
0
    def __init__(self, uid=None, request=None, title=None):
        self.id = slugify(str(uid or uuid.uuid1().hex))
        self.as_pdf = False
        self.title = title
        self.request = request
        self.response = None
        self.mobile = http.mobile(request)

        if self.request:
            if 'pdf' in self.request.GET:
                self.as_pdf = True
Example #4
0
 def __init__(self, request, style=None):
     super(GroupDropDown, self).__init__('groupdropdown', request)
     self.actions = OrderedDict()
     self.mobile = http.mobile(self.request)
     self.actions[_('Actions')] = []
     self.style = style
Example #5
0
 def __init__(self, request):
     super(GroupDropDown, self).__init__('groupdropdown', request)
     self.actions = OrderedDict()
     self.mobile = http.mobile(self.request)
     self.actions['Ações'] = []
Example #6
0
def mobile(request):
    return http.mobile(request)