Exemplo n.º 1
0
 def setup_table(table):
     table.add_columns(
         'id',
         'name',
         'Tags',
         ColumnBase(column_name='people',
                    field='people',
                    annotations={'people': Count('person__id')}),
         ColumnLink(column_name='view_company_1',
                    field=['id', 'name'],
                    url_name='example2'),
         ColumnLink(column_name='view_company_2',
                    link_ref_column='id',
                    field='name',
                    url_name='example2'),
     )
     table.add_js_filters('tag', 'Tags')
Exemplo n.º 2
0
 def setup_schemas(self, table):
     table.add_columns(
         'schema', 'size',
         ColumnLink(
             column_name='view_schema', link_ref_column='schema', url_name='gdrive_backup:schema_info',
             link_html='<button class="btn btn-sm btn-outline-dark">VIEW</button>'
         ),
         ColumnBase(column_name='Backup',
                    render=[row_button('backup_schema', 'Backup', button_classes='btn btn-success btn-sm',)])
     )
     table.table_data = [{'schema': s[0], 'size': s[1]} for s in self.schemas]
     table.table_options['column_id'] = 0
     table.sort('schema')
     table.table_options['stateSave'] = False
Exemplo n.º 3
0
 def setup_table(table):
     table.add_columns(
         ('id', {
             'column_defs': {
                 'width': '30px'
             }
         }),
         'name',
         'Tags',
         ColumnBase(column_name='people',
                    field='people',
                    annotations={'people': Count('person__id')}),
         ColumnLink(column_name='view_company',
                    field='name',
                    url_name='example2'),
         ColumnLink(
             column_name='view_company_icon',
             link_ref_column='id',
             url_name='example2',
             width='10px',
             link_html=
             '<button class="btn btn-sm btn-outline-dark"><i class="fas fa-building"></i></button>'
         ),
     )
     table.column('name').column_defs['orderable'] = False
     table.add_plugin(ColourRows, [{
         'column': 0,
         'values': {
             '1': 'table-danger'
         }
     }])
     table.ajax_data = False
     table.add_js_filters('tag', 'Tags')
     table.add_js_filters('totals',
                          'people',
                          filter_title='Number of People',
                          collapsed=False)
Exemplo n.º 4
0
    class Datatable(DatatableModel):
        people = {'annotations': {'people': Count('person__id')}}
        collink_1 = ColumnLink(title='Defined in Model',
                               field=['id', 'name'],
                               url_name='example2')
        company_list = ['id', 'name']

        class ModelIdColumn(DatatableColumn):
            def col_setup(self):
                self.field = 'id'
                if 'title' not in self.kwargs:
                    self.title = 'Modal Class'

        model_instance = ModelIdColumn(title='Instance')
        direct_tag = ManyToManyColumn(field='direct_tag__tag_direct')
        reverse_tag = ManyToManyColumn(field='tags__tag')

        class Tags(DatatableColumn):
            def setup_results(self, request, all_results):
                tags = Tags.objects.values_list('company__id', 'id')
                tag_dict = {}
                for t in tags:
                    tag_dict.setdefault(t[0], []).append(t[1])
                all_results['tags'] = tag_dict

            @staticmethod
            def proc_result(data_dict, page_results):
                return page_results['tags'].get(data_dict['id'], [])

            def col_setup(self):
                self.options['render'] = [
                    {
                        'var': '%1%',
                        'html': '%1%',
                        'function': 'ReplaceLookup'
                    },
                ]
                self.options['lookup'] = list(
                    Tags.objects.values_list('id', 'tag'))
                self.row_result = self.proc_result
Exemplo n.º 5
0
    class Datatable(DatatableModel):
        people = {'annotations': {'people': Count('person__id')}}
        collink_1 = ColumnLink(title='Defined in Model', field='name', url_name='company')

        class Tags(DatatableColumn):
            def setup_results(self, request, all_results):
                tags = Tags.objects.values_list('company__id', 'id')
                tag_dict = {}
                for t in tags:
                    tag_dict.setdefault(t[0], []).append(t[1])
                all_results['tags'] = tag_dict

            @staticmethod
            def proc_result(data_dict, page_results):
                return page_results['tags'].get(data_dict['id'], [])

            def col_setup(self):
                self.options['render'] = [
                    {'var': '%1%', 'html': '%1%', 'function': 'ReplaceLookup'},
                ]
                self.options['lookup'] = list(Tags.objects.values_list('id', 'tag'))
                self.row_result = self.proc_result
Exemplo n.º 6
0
    def setup_table(self, table):
        table.add_columns(
            ('id', {
                'column_defs': {
                    'width': '30px'
                }
            }),
            'name',
            'Tags',
            ('dissolved', {
                'choices': ['yes', 'no']
            }),
            ColumnLink(column_name='peoplex',
                       field=['id', 'name'],
                       url_name='example2'),
            ColumnBase(column_name='people',
                       field='people',
                       annotations={'people': Count('person__id')}),
            ColumnLink(column_name='view_company',
                       field=['id', 'name'],
                       url_name='example2'),
            ColumnLink(
                column_name='view_company_icon',
                link_ref_column='id',
                url_name='example2',
                width='10px',
                link_html=
                '<button class="btn btn-sm btn-outline-dark"><i class="fas fa-building"></i></button>'
            ),
            'reverse_tag',
            ManyToManyColumn(
                column_name='DirectTag',
                field='direct_tag__tag_direct',
                model=models.Company,
                html='<span class="badge badge-primary"> %1% </span>'),
        )
        table.column('name').column_defs['orderable'] = False
        table.add_plugin(ColourRows, [{
            'column': 'id',
            'values': {
                '1': 'table-danger'
            }
        }])
        table.ajax_data = False
        table.add_js_filters('tag', 'Tags')
        table.add_js_filters('totals',
                             'people',
                             filter_title='Number of People',
                             collapsed=False)
        add_save_filters(table, self.request.user)
        # table.add_js_filters('tag', 'DirectTag')
        table.table_options['row_href'] = row_link('example2', 'id')
        table.table_options['no_col_search'] = True
        table.table_options['pageLength'] = '22'

        # table.table_options['scrollX'] = True
        # table.table_options['row_href'] = [render_replace(column='id', html='javascript:console.log("%1%")')]
        table.add_plugin(ColumnTotals, {'id': {
            'sum': 'over1000'
        }},
                         template='add_sum_calc.html')