class WalletsTable(django_tables2.Table): action = django_tables2.LinkColumn(open_wallet, text='open', args=[A('pk')]) moving = django_tables2.LinkColumn(delete_wallet, text='delete', args=[A('pk')]) class Meta: attrs = { "class": "paleblue", } # this fixed table rendering model = Wallet fields = ( "btcaddress", "ethaddress", "btcbalance", "ethbalance", )
class EmployeeTable(tables.Table): name = tables.LinkColumn('edit_employee',args=[A('pk')]) category_id = tables.Column(verbose_name="Category") class Meta: model = Employee sequence = ("name","designation","category_id","salary","phone_number","joined_date" ,"status","outstanding") fields = ("name","designation","category_id","salary","phone_number","joined_date" ,"status","outstanding") attrs = {"class": "paleblue"}
class RoundsTable(tables.Table): title = tables.LinkColumn('funds:rounds:detail', args=[A('pk')], orderable=True, text=lambda record: record.title) fund = tables.Column(accessor=A('specific.fund')) lead = tables.Column() start_date = tables.Column() end_date = tables.Column() progress = tables.Column(verbose_name="Determined") class Meta: fields = ('title', 'fund', 'lead', 'start_date', 'end_date', 'progress') attrs = {'class': 'responsive-table'} def render_lead(self, value): return format_html('<span>{}</span>', value) def render_progress(self, record): return f'{record.progress}%' def _field_order(self, field, desc): return getattr(F(f'{field}'), 'desc' if desc else 'asc')(nulls_last=True) def order_start_date(self, qs, desc): return qs.order_by(self._field_order('start_date', desc)), True def order_end_date(self, qs, desc): return qs.order_by(self._field_order('end_date', desc)), True def order_fund(self, qs, desc): return qs.order_by(self._field_order('fund', desc)), True def order_progress(self, qs, desc): return qs.order_by(self._field_order('progress', desc)), True def get_column_class_names(self, classes_set, bound_column): classes_set = super(RoundsTable, self).get_column_class_names( classes_set, bound_column) classes_set.add(bound_column.name) return classes_set
class RecipeImportTable(tables.Table): id = tables.LinkColumn('new_recipe_import', args=[A('id')]) delete = tables.TemplateColumn( "<a href='{% url 'delete_recipe_import' record.id %}' >" + _('Delete') + "</a>") class Meta: model = RecipeImport template_name = 'generic/table_template.html' fields = ('id', 'name', 'file_path')
class TextTable(tables.Table): legacy_id = tables.LinkColumn( 'assignments:text_detail', args=[A('pk')], verbose_name='Legacy ID' ) text_type = tables.LinkColumn( 'assignments:text_detail', args=[A('pk')], verbose_name='Text Type' ) forename = tables.Column() class Meta: model = Text sequence = ( 'legacy_id', 'text_type', ) attrs = {"class": "table table-responsive table-hover"}
class ProposalTable(tables.Table): local_contacts_short = TruncatedTextColumn(verbose_name= 'Local contact', orderable = False) get_categories = tables.Column(verbose_name= 'Categories') #, order_by = A('categories__count') name = TruncatedTextColumn(linkify=True) proposaltype = tables.Column(verbose_name='Type') supervisor = tables.Column(empty_values=[]) proposer = tables.LinkColumn('app_contacts_detail', args=[A('proposer.contact.pk')], text=lambda record: record.proposer.contact.name, order_by = A('proposer.contact.name')) pid = tables.Column(attrs={'td': {'class': 'font-weight-bold'}}) pdf = tables.LinkColumn('proposal_pdf_detail_view', args=[A('pid')], text="PDF", attrs={'a': {'target': '_blank'}}, orderable = False) def __init__(self, *args, **kwargs): #if self.request.user.has_perm('app.approve_panel'): # self.Meta.exclude.pop("reporter") super().__init__(*args, **kwargs) def order_get_categories(self, queryset, is_descending): queryset = queryset.annotate( countcat=Count('categories'), firstcat=Max('categories'), ).order_by(("-" if is_descending else "") + "countcat", ("-" if is_descending else "") + "firstcat") return (queryset, True) def before_render(self, request): if request.user.has_perm('app.approve_panel') or request.user.has_perm('app.approve_board'): self.columns.show('reporter') else: self.columns.hide('reporter') if request.user.has_perm('app.view_proposals'): # typically user office self.columns.show('grants') else: self.columns.hide('grants') def render_supervisor(self, record): if record.student: return "✓ (%s)" % record.supervisor return "✗" class Meta: model = Proposals template_name = 'django_tables2/bootstrap4.html' exclude = ('id', 'abstract', 'slug', 'student', 'scientific_bg', 'thesis_topic') #, 'reporter') sequence = ('pid', 'name', 'pdf', '...') attrs = { 'class': 'table table-striped table-sm table-hover'}
class ReleaseTable(tables.Table): releaseid = tables.LinkColumn('girvi_release_detail', args=[A('pk')]) class Meta: model = Release fields = ('id', 'releaseid', 'created', 'loan', 'interestpaid') attrs = { "class": "table table-sm table-striped table-bordered table-hover" } empty_text = "There are no customers matching the search criteria..."
class IntervalTable(tables.Table): NeatName = tables.LinkColumn('IntervalDetailView', args=[A('pk')]) class Meta: model = Interval attrs = {"class": "paleblue"} sequence = ('IntervalSerialNumber', 'NeatName', 'chr', 'start', 'stop', 'IntervalSize', 'Link') order_by = ('start', ) exclude = ('Structure', )
class MembershipTable(tables.Table): """Membership table configuration """ organization = tables.LinkColumn('membership_id', args=[A('id')]) class Meta: model = Membership fields = ('organization','member_type','status') order_by = ('organization') template_name = 'django_tables2/bootstrap.html'
class UserTable(tables.Table): pk = tables.LinkColumn('accounts:detail', args=[A('pk')], verbose_name='User ID') employee = tables.Column(accessor='get_full_name.title', verbose_name='Employee', orderable=False) class Meta: model = User fields = ('pk', 'employee', 'username', 'email') attrs = {"class": "table-striped table-bordered"} empty_text = "There are no users matching the search criteria..."
class SumssNoMatchListTable(tables.Table): export_formats = [ 'csv', ] id = tables.Column(verbose_name='ID') image_id = tables.LinkColumn('image_detail', args=[ A('image_id'), ], orderable=True, verbose_name='Img. ID') master_name = tables.LinkColumn( 'crossmatch_detail', args=[A('image_id'), "noaskapmatchtocatalog", A('id')], orderable=True, verbose_name='Source Name') ra = RAColumn(attrs={"td": { "style": "white-space:nowrap;" }}, verbose_name='RA') dec = DecColumn(attrs={"td": { "style": "white-space:nowrap;" }}, verbose_name='Dec') # ra_decimal = table.Column(verbose_name= 'RA dec', accessor=A('ra')) # askap_iflux = RMSColumn(verbose_name= 'ASKAP Int. Flux (mJy)') catalog_iflux = FloatColumn(verbose_name='Cat. Int. Flux (mJy)') cat_snr = tables.Column(verbose_name='Catalog SNR') scaled_cat_snr = tables.Column(verbose_name='Scaled ASKAP SNR') survey = CapitalColumn(verbose_name='Ref Survey') pipelinetag = tables.Column(verbose_name='Pipeline Tag') usertag = tables.Column(verbose_name='User Tag') userreason = tables.Column(verbose_name='User Reason') checkedby = tables.Column(verbose_name='Checked By') class Meta: model = Sumssnomatch template_name = 'django_tables2/bootstrap4.html' fields = ("id", "image_id", "master_name", "ra", "dec", "catalog_iflux", "cat_snr", "scaled_cat_snr", "survey", "pipelinetag", "usertag", "userreason", "checkedby") attrs = {"th": {"bgcolor": "#EBEDEF"}}
class SchoolTermTable(tables.Table): """Table to list persons.""" class Meta: attrs = {"class": "responsive-table highlight"} name = tables.LinkColumn("edit_school_term", args=[A("id")]) date_start = tables.Column() date_end = tables.Column() edit = tables.LinkColumn( "edit_school_term", args=[A("id")], text=_("Edit"), attrs={ "a": { "class": "btn-flat waves-effect waves-orange orange-text" } }, verbose_name=_("Actions"), )
class UserTable(tables.Table): editar = tables.LinkColumn( 'edit_user', args=[A('id')], orderable=False, text=mark_safe('<i class="fa fa-pencil" aria-hidden="true"></i>')) senha = tables.LinkColumn( 'change_password', args=[A('id')], orderable=False, text=mark_safe('<i class="fa fa-key" aria-hidden="true"></i>')) class Meta: model = User orderable = False fields = ('username', 'email', 'first_name', 'last_name') attrs = {"class": "paleblue"} sequence = ('editar', 'senha', 'username', 'email', 'first_name', 'last_name')
class CustomersTable(tables.Table): id = tables.LinkColumn('customer_page', args=[A('pk')]) class Meta: model = Customer exclude = ('avatar', 'comment') attrs = {'class': 'paleblue table table-striped table-bordered'} empty_text = _( 'Пока нет ни одного клиента. Для добавления используйте соответствующий пункт меню' )
class ItemsTable(tables.Table): name = tables.Column(linkify=("details", [tables.A("pk")])) # (viewname, args) edit = tables.LinkColumn('edit_items', args=[A('pk')], verbose_name = ' ',text=lambda record: " Редактировать", attrs={ "a": {"style": "color: red;"} }) class Meta: model = Items template_name = "django_tables2/bootstrap4.html" fields = ("id","name", "domain", "author", "value")
class TermTable(tables.Table): """Term table configuration """ mem_type = tables.LinkColumn('term_id', args=[A('id')]) class Meta: model = Term fields = ('mem_type','n_workshops') order_by = ('mem_type') template_name = 'django_tables2/bootstrap.html'
class CandidateTable(tables.Table): full_name = tables.LinkColumn('detail_candidates', args=[A('pk')]) class Meta: model = Candidate template_name = 'django_tables2/semantic.html' exclude = ('description', 'author', 'email', 'phone_number_2', 'phone_number_1') sequence = ('id', 'full_name', 'position', 'status', 'interview_date', 'updated', 'created')
class OrganizationTable(tables.Table): """Organization table confiiguration """ name = tables.LinkColumn('organization_id', args=[A('id')]) class Meta: model = Organization fields = ('name','country','url') order_by = ('name') template_name = 'django_tables2/bootstrap.html'
class DemographicTable(tables.Table): clinical = tables.LinkColumn('clinical_detail', text='View', args=[A('clinical.pk')], verbose_name='') participant = tables.LinkColumn('participant_detail', verbose_name="Participant", accessor=A('clinical'), args=[A('clinical.participant.id')]) def render_participant(self, value): """ Get access to clinical participant via RelatedManager :param value: :return: """ return value.participant class Meta: model = Demographic template_name = 'django_tables2/bootstrap.html' attrs = {"class": "ui-responsive table table-hover"} fields = ['clinical', 'participant', 'gender', 'age_assessment', 'marital_status', 'living_arr', 'years_school', 'current_emp_status', 'employment_history']
class CiscoDeviceTable(tables.Table): device_name = tables.LinkColumn('device-details', args=[A('pk')], orderable=True) ios_version = tables.Column(orderable=True) ios_type = tables.Column(orderable=True) vulnerabs = tables.Column(orderable=True) def render_vulnerabs(self, value): return '%s' % (len(value.all()))
class CognacyTable(DataTable): """Do Cognacy Table""" id = tables.LinkColumn('lexicon-edit', args=[A('id')]) language = tables.LinkColumn('language-detail', args=[A('language.slug')]) source = tables.LinkColumn('source-detail', args=[A('source.slug')]) classification = tables.Column() entry = tables.Column() annotation = tables.Column() loan = tables.BooleanColumn(null=False, yesno=('x', '')) cognacy = tables.Column() edit = tables.Column() def render_language(self, record): col = tables.LinkColumn('language-detail', args=[record.language.slug]) return col.render(value=record.language, record=record.language, bound_column=None) def render_cognacy(self, record): return mark_safe(" ".join([ render_to_string('cognacy/includes/button.html', cognate_button(c)) for c in sorted(record.cognacy) ])) def render_edit(self, record): return mark_safe( '<input type="text" class="input-mini" id="c-%d" name="c-%d" value="" />' % (record.id, record.id)) def render_classification(self, record): return mark_safe( render_to_string('includes/condense_classification.html', condense_classification(record.classification))) class Meta(DataTable.Meta): model = Lexicon order_by = 'classification' # default sorting sequence = ('id', 'language', 'source', 'classification', 'entry', 'annotation', 'loan', 'cognacy', 'edit') exclude = ('editor', 'added', 'slug', 'phon_entry', 'loan_source', 'word', 'source_gloss') Meta.attrs['summary'] = 'Table of Lexicon'
class DocumentTable(tables.Table): number = tables.LinkColumn('doc:document-detail', args=[A('pk')]) class Meta: model = Document fields = ('number', 'date', 'summary', 'issued_by', 'projects') attrs = {'class': 'table-striped table-bordered table-hover'} empty_text = 'No content' per_page = 100
class CustomerTable(tables.Table): edit_link = tables.LinkColumn('customer', args=[A('pk')], verbose_name='Edit Customer', text='Edit', accessor='pk', attrs={'class': 'edit_link'}) delete_link = tables.LinkColumn('customer_delete', args=[A('pk')], verbose_name='Delete Customer', text='Delete', accessor='pk', attrs={'class': 'delete_link'}) class Meta: model = Party attrs = {'class': 'tableStyle'}
class FilemapTable(tables.Table): add_doc = tables.LinkColumn('evidence_add_doc', args=[A('pk')], verbose_name='', accessor='pk', text='add file', attrs={'class': 'edit_link'}) mod_evidence = tables.LinkColumn('evidence_update', args=[A('pk')], verbose_name='', accessor='pk', text='modify', attrs={'class': 'edit_link'}) class Meta: model = Filemap template_name = 'django_tables2/bootstrap.html' exclude = []
class AssignmentTable(tables.Table): title = tables.LinkColumn( 'assignments:assignment_detail', args=[A('pk')], verbose_name='Title' ) description = tables.LinkColumn( 'assignments:assignment_detail', args=[A('pk')], verbose_name='Description' ) forename = tables.Column() class Meta: model = Assignment sequence = ( 'id', 'title', 'description', ) attrs = {"class": "table table-responsive table-hover"}
class GraphSelectorTable(tables.Table): id = tables.LinkColumn('edit_graph_selector', args=[A('id')]) options = tables.TemplateColumn( "<a href='{% url 'delete_graph_selector' record.id %}' class='btn btn-danger'><i class='fas fa-trash'></i></a>", verbose_name=_('Options')) class Meta: model = GraphSelector fields = ('id', 'name', 'type', 'instance')
class SalidaTable(tables.Table): referencia = tables.LinkColumn('salida_detalle', args=[A('pk')]) class Meta: model = Salida attrs = {'class': 'table table-striped responsive-table'} orderable = False fields = [ 'referencia', 'descripcion', 'fecha_creacion', 'estado', 'acciones' ]
class DisplayTable(tables.Table): id = tables.LinkColumn('edit_display', args=[A('id')]) options = tables.TemplateColumn( "<a href='{% url 'delete_display' record.id %}' class='btn btn-danger'><i class='fas fa-trash'></i></a>", verbose_name=_('Options')) class Meta: model = Display fields = ('id', 'name')
class VisitTable(tables.Table): link = tables.LinkColumn('openvisit', text='open Visit', args=[A('pk')]) class Meta: model = Visit fields = {'Id', 'Date', 'Patient.FirstName', 'Patient.LastName'} sequence = ('Id', 'Date', 'Patient.FirstName', 'Patient.LastName') template = 'django_tables2/bootstrap.html'
class QuoteTable(tables.Table): text = tables.LinkColumn('browsing:quote_detail', args=[A('pk')], verbose_name='Text') book_source = tables.Column() class Meta: model = Quote sequence = ('text', 'book_source') attrs = {"class": "table table-responsive table-hover"}