class UsersTable(CoreTable): id = tables.Column(visible=False) name = tables.Column('User', linkify=True) customer = tables.Column('Customer', linkify=True) ad_groups = tables.ManyToManyColumn() mail_groups = tables.ManyToManyColumn() class Meta(CoreTable.Meta): model = User
class VfbEntryTable(tables.Table): id = tables.LinkColumn('summaries:verfachbucheintrag_detail', args=[A('pk')], verbose_name='ID') mentioned_person = tables.ManyToManyColumn() mentioned_inst = tables.ManyToManyColumn() mentioned_place = tables.ManyToManyColumn() class Meta: model = VfbEntry sequence = ('id', ) attrs = {"class": "table table-responsive table-hover"}
class ComisionTable(tables.Table): localidades = tables.ManyToManyColumn(verbose_name="Localidades") empleados = tables.ManyToManyColumn(verbose_name="Empleados") fechaInicio = tables.Column(verbose_name="Fecha Inicio") fechaFin = tables.Column(verbose_name="Fecha Fin") acciones = tables.TemplateColumn(template_name="formButtons.html", orderable=False) class Meta: template_name = "django_tables2/semantic.html" model = Comision
class ResearchEventTable(tables.Table): id = tables.LinkColumn('archiv:researchevent_detail', args=[A('pk')], verbose_name='ID') start_date = tables.DateColumn(format='Y-m-d') end_date = tables.DateColumn(format='Y-m-d') site_id = tables.ManyToManyColumn() responsible_researcher = tables.ManyToManyColumn() responsible_institution = tables.ManyToManyColumn() research_method = tables.ManyToManyColumn() class Meta: model = ResearchEvent sequence = ('id', 'start_date', 'end_date') attrs = {"class": "table table-responsive table-hover"}
class PersonTable(tables.Table): id = tables.LinkColumn('entities:person_detail', args=[A('pk')], verbose_name='ID') name = tables.LinkColumn('entities:person_detail', args=[A('pk')], verbose_name='Name') is_main_person = tables.TemplateColumn( "{% for x in record.is_main_person.all %}\ <a href='{{ x.get_absolute_url }}'>{{ x }} </a>|{% endfor %}", orderable=False) is_adm_person = tables.TemplateColumn( "{% for x in record.is_adm_person.all %}\ <a href='{{ x.get_absolute_url }}'>{{ x }} </a>|{% endfor %}", orderable=False) is_related_person = tables.TemplateColumn( "{% for x in record.is_related_person.all %}\ <a href='{{ x.get_absolute_url }}'>{{ x }} </a>|{% endfor %}", orderable=False) is_other_person = tables.TemplateColumn( "{% for x in record.is_other_person.all %}\ <a href='{{ x.get_absolute_url }}'>{{ x }} </a>|{% endfor %}", orderable=False) profession = tables.ManyToManyColumn() merge = MergeColumn(verbose_name='keep | remove', accessor='pk') class Meta: model = Person sequence = ( 'id', 'written_name', ) attrs = {"class": "table table-responsive table-hover"}
class MessagesTable(tables.Table): by = tables.LinkColumn('twiscrape:account-detail', args=[A('by_id')]) #project = tables.LinkColumn('twiscrape:project-detail', args=[A('pk')]) hashtags = tables.ManyToManyColumn(transform_hashtags) mentions = tables.ManyToManyColumn() class Meta: model = Message fields = ['text'] # add class="paleblue" to <table> tag attrs = {"class": "table table-hover table-striped table-condensed"} def __init__(self, *args, exclude_columns=None, **kwargs): super().__init__(*args, **kwargs) if exclude_columns is not None: self.exclude = exclude_columns
class ArchEntTable(tables.Table): id = tables.LinkColumn('archiv:archent_detail', args=[A('pk')], verbose_name='ID') name = tables.LinkColumn('archiv:archent_detail', args=[A('pk')], verbose_name='Name') comment = tables.TemplateColumn("{{ record.comment|truncatechars:250 }}") site_id = tables.Column() public = tables.Column() topography = tables.ManyToManyColumn() period = tables.ManyToManyColumn() class Meta: model = ArchEnt sequence = ('id', 'name', 'site_id', 'ent_type') attrs = {"class": "table table-responsive table-hover"}
class ActivityTable(tables.Table): registrant = tables.ManyToManyColumn() class Meta: model = Activities sequence = ('start_date', 'end_date', 'reg_start')
class BackupsTable(CoreTable): id = tables.Column(visible=False) name = tables.Column('Backup', linkify=True) computer = tables.Column('Computer', linkify=True) target_device = tables.ManyToManyColumn(linkify_item=True) class Meta(CoreTable.Meta): model = Backup
class CardTable(tables.Table): signature = tables.LinkColumn() legacy_id = tables.LinkColumn(verbose_name='Lfd. Nr.') number = tables.LinkColumn() mentioned_person = tables.ManyToManyColumn() mentioned_inst = tables.ManyToManyColumn() mentioned_place = tables.ManyToManyColumn() creator_person = tables.ManyToManyColumn() creator_inst = tables.ManyToManyColumn() subject_norm = tables.ManyToManyColumn() bild_technik = tables.ManyToManyColumn() thumbnail = tables.columns.TemplateColumn( template_name="cards/thumbcolumn.html", orderable=False, verbose_name='Vorschaubild') class Meta: model = Card sequence = ( 'legacy_id', 'card_collection', 'number', 'thumbnail', ) attrs = {"class": "table table-responsive table-hover"}
class LogTable(tables.Table): usage_set = tables.ManyToManyColumn(transform=lambda r: f'{r.resource.name}={r.amount}{r.resource.unit}', verbose_name='Used Resources') class Meta: model = Log template_name = 'django_tables2/bootstrap4.html' exclude = ('created', 'last_updated', 'id', 'proposal') sequence = ('instrument', '...') attrs = { 'class': 'table table-striped table-sm table-hover'}
class UserLicensesTable(CoreTable): id = tables.Column(visible=False) license_ptr = tables.Column(visible=False) customer = tables.Column('Customer', linkify=True) used_licenses = tables.Column() user = tables.ManyToManyColumn(linkify_item=True) class Meta(CoreTable.Meta): model = UserLicense
class ProjectsTable(tables.Table): # name = tables.LinkColumn(viewname='proj', args=[A('pk')]) name = tables.Column(linkify=('proj',[A('pk')])) collaborators = tables.ManyToManyColumn() editors = tables.ManyToManyColumn() experiments = tables.ManyToManyColumn(separator=', ',verbose_name="Experiments", linkify_item=('exp',{'pk_proj':A('project.pk'),'pk_exp':A('pk')})) # checked = tables.CheckBoxColumn(accessor='pk',empty_values=(), verbose_name="checked") def render_date_modified(self, value): return formatDateTime(value) def render_date_created(self, value): return formatDateTime(value) class Meta: model = Project template_name = 'django_tables2/bootstrap-responsive.html' fields = ['name','owner','created_date','modified_date','experiments','collaborators','editors',]
class InventoryEntryTable(tables.Table): id = tables.LinkColumn('summaries:inventory_detail', args=[A('pk')], verbose_name='ID') inv_signatur = tables.LinkColumn('summaries:inventory_detail', args=[A('pk')], verbose_name='Titel') main_person = tables.ManyToManyColumn() adm_person = tables.ManyToManyColumn() related_person = tables.ManyToManyColumn() other_person = tables.ManyToManyColumn() class Meta: model = InventoryEntry sequence = ( 'id', 'inv_signatur', ) attrs = {"class": "table table-responsive table-hover"}
class VerfachBuchTable(tables.Table): id = tables.LinkColumn('summaries:verfachbuch_detail', args=[A('pk')], verbose_name='ID') title = tables.LinkColumn('summaries:verfachbuch_detail', args=[A('pk')], verbose_name='Titel') mentioned_person = tables.ManyToManyColumn() mentioned_inst = tables.ManyToManyColumn() mentioned_place = tables.ManyToManyColumn() creator_person = tables.ManyToManyColumn() creator_inst = tables.ManyToManyColumn() forename = tables.Column() class Meta: model = VerfachBuch sequence = ( 'id', 'title', ) attrs = {"class": "table table-responsive table-hover"}
class ArticlesTable(tables.Table): article_id = tables.Column(linkify=True, verbose_name="ID") tags = tables.ManyToManyColumn(linkify_item=True) class Meta: model = Article2 template_name = "django_tables2/bootstrap.html" exclude = ( "created_at", "is_processed", "process_timestamp", )
class BookTable(tables.Table): title = tables.Column(linkify=True) author = tables.Column(linkify=True) genre = tables.ManyToManyColumn(transform=lambda genre: genre.name) isbn = tables.Column() class Meta: title = 'Books' placeholder = 'Search books' empty_text = 'No books found' template_name = 'mybootstrap4.html' attrs = {'id': 'book_table'}
class CandidatesTable(tables.Table): id = tables.Column() user = tables.Column(order_by=('user__first_name', 'user__last_name')) requested_positions = tables.ManyToManyColumn() approved_positions = tables.ManyToManyColumn() availabilities = tables.ManyToManyColumn(accessor='availability_set') class Meta: template_name = "django_tables2/bootstrap4.html" def render_id(self, value: int): return format_html('<input type="radio" name="assignee" value="{}" />', value) def render_user(self, value: User): return format_html("{} {}", value.first_name, value.last_name) def render_availabilities(self, value: QuerySet): return format_html_join("\n", "{} - {}<br>", ((availability.start_date.strftime('%d.%m.%Y'), availability.end_date.strftime('%d.%m.%Y')) for availability in value.all()))
class PersonTable(tables.Table): id = tables.LinkColumn('entities:person_detail', args=[A('pk')], verbose_name='ID') name = tables.LinkColumn('entities:person_detail', args=[A('pk')], verbose_name='Name') belongs_to_institution = tables.ManyToManyColumn() class Meta: model = Person sequence = ( 'id', 'written_name', ) attrs = {"class": "table table-responsive table-hover"}
class CompanyUserTable(tables.Table): Name = tables.Column(accessor='user.get_full_name', verbose_name='Name') Email = tables.EmailColumn(accessor='user.email') Active = tables.BooleanColumn(accessor='user.is_active', ) Role = tables.ManyToManyColumn(accessor='user.groups', verbose_name='Role') class Meta: model = UserProfile exclude = ( 'id', 'updated_at', 'created_at', 'company', 'user', ) attrs = {'class': 'table table-responsive table-hover'}
class RequestTable(tables.Table): created_on = tables.DateColumn(format="d.m.Y") assigned_to = tables.ManyToManyColumn(verbose_name="Исполнители", linkify_item=True) applicant = tables.Column(verbose_name="Заявитель", linkify=True, accessor="applicant") apartment = tables.Column(verbose_name="Помещение", linkify=True) actions = tables.TemplateColumn(verbose_name="Действия", template_name="misc/linkbuttons.html", extra_context={ 'view_link': 'requests:view', 'edit_link': 'requests:edit', 'remove_link': 'requests:remove' }, orderable=False, exclude_from_export=True) class Meta: model = Request fields = ['created_on', 'applicant', 'request_type', 'assigned_to', 'priority', 'is_proceed', 'closed_on', 'apartment'] template_name = 'django_tables2/bootstrap4.html' attrs = {'class': 'table table-striped table-bordered text-center'} empty_text = "Ничего не найдено"
class AccessionTable(tables.Table): """ Table that is displayed on the accession list view """ id = tables.LinkColumn("accession_detail", args=[A('id')], text=lambda record: record.pk, verbose_name="ID", order_by="pk") name = tables.Column(accessor="name", verbose_name="Name", order_by="name") country = tables.Column(accessor="country", verbose_name="Country", order_by="country") sitename = tables.Column(accessor="sitename", verbose_name="Sitename", order_by="sitename") collector = tables.Column(accessor="collector", verbose_name="Collector", order_by="collector") longitude = tables.Column(accessor="longitude", verbose_name="Longitude", order_by="longitude") latitude = tables.Column(accessor="latitude", verbose_name="Latitude", order_by="latitude") cs_number = tables.URLColumn({"target": "_blank"}, lambda record: record.cs_number, accessor="cs_number_url", verbose_name="CS Number", order_by="cs_number") genotypes = tables.ManyToManyColumn( accessor="genotype_set", transform=lambda genotype: genotype.name) number_of_phenotypes = tables.Column(accessor="count_phenotypes", verbose_name='# Phenotypes') class Meta: attrs = {"class": "striped"} def order_number_of_phenotypes(self, QuerySet, is_descending): QuerySet = QuerySet.annotate(count=Count( 'observationunit__phenotypevalue__phenotype', distinct=True)).order_by(('-' if is_descending else '') + 'count') return (QuerySet, True)
class HapaPlaceNameTable(tables.Table): id = tables.LinkColumn(verbose_name='ID') tags = tables.ManyToManyColumn() # merge = MergeColumn(verbose_name='keep | remove', accessor='pk') beleg = tables.columns.ManyToManyColumn() wortbildung = tables.TemplateColumn("{{ record.wortbildung|safe }}") etymology = tables.TemplateColumn("{{ record.etymology|safe }}") syntax = tables.TemplateColumn("{{ record.syntax|safe }}") comment = tables.TemplateColumn("{{ record.comment|safe }}") internal_comment = tables.TemplateColumn( "{{ record.internal_comment|safe }}") class Meta: model = HapaPlaceName sequence = ('id', ) attrs = {"class": "table table-responsive table-hover"} order_by = [ '-id', ]
class HapaBelegTable(tables.Table): id = tables.LinkColumn(verbose_name='ID') tags = tables.ManyToManyColumn() text = tables.TemplateColumn("{{ record.text|safe }}") comment = tables.TemplateColumn("{{ record.comment|safe }}") internal_comment = tables.TemplateColumn( "{{ record.internal_comment|safe }}") zot_key = tables.TemplateColumn("{{ record.zotero_id.zot_key }}", orderable=False) class Meta: model = HapaBeleg sequence = ( 'id', '...', 'zotero_id', 'page_nr', 'zot_key', ) attrs = {"class": "table table-responsive table-hover"}
class CommentsTable(tables.Table): resubmit = CheckBoxColumnWithName(accessor="pk", verbose_name="Resubmit?", exclude_from_export=True) id = tables.LinkColumn() document = tables.LinkColumn(exclude_from_export=True) short_comment = tables.Column(orderable=False, verbose_name="Comment", exclude_from_export=True) commenter = tables.Column(exclude_from_export=True) commenter__first_name = tables.Column(verbose_name="Commenter First Name", visible=False) commenter__last_name = tables.Column(verbose_name="Commenter Last Name", visible=False) commenter__email = tables.Column(verbose_name="Commenter Email", visible=False) comment = tables.Column(visible=False) document__document_id = tables.Column(verbose_name="Document ID", visible=False) document__title = tables.Column(verbose_name="Document Title", visible=False) document__document_type = tables.Column(verbose_name="Document Type", visible=False) document__comment_start_date = tables.Column( verbose_name="Document Comment Start Date", visible=False) document__comment_end_date = tables.Column( verbose_name="Document Comment End Date", visible=False) document__topics = tables.ManyToManyColumn(verbose_name="Document Topics", visible=False) class Meta: model = Comment order_by = ("-created_at", ) fields = [ "id", "created_at", "document", "commenter", "short_comment", "client_mode", "was_submitted", "resubmit" ]
class ArchResourceTable(tables.Table): id = tables.LinkColumn('archiv:archresource_detail', args=[A('pk')], verbose_name='ID') title = tables.LinkColumn('archiv:archresource_detail', args=[A('pk')], verbose_name='Titel') mentioned_person = tables.ManyToManyColumn() mentioned_inst = tables.ManyToManyColumn() mentioned_place = tables.ManyToManyColumn() creator_person = tables.ManyToManyColumn() creator_inst = tables.ManyToManyColumn() subject_norm = tables.ManyToManyColumn() creators = tables.ManyToManyColumn() class Meta: model = ArchResource sequence = ( 'id', 'title', ) attrs = {"class": "table table-responsive table-hover"}
class ApartmentTable(tables.Table): address = tables.Column(verbose_name="Адрес") balance_of_business_account = tables.Column(verbose_name="Баланс") number_of_business_account = tables.Column(verbose_name="ЛС") client = tables.ManyToManyColumn(verbose_name="Клиенты", linkify_item=True) actions = tables.TemplateColumn(verbose_name="Действия", template_name="misc/linkbuttons.html", extra_context={ 'view_link': 'apartments:view', 'edit_link': 'apartments:edit', 'remove_link': 'apartments:remove' }, orderable=False, exclude_from_export=True) class Meta: model = Apartment fields = [ 'number_of_business_account', 'address', 'apartment_number', 'area', 'client', 'balance_of_business_account' ] template_name = 'django_tables2/bootstrap4.html' attrs = {'class': 'table table-striped table-bordered text-center'} empty_text = "Ничего не найдено"
class AssignmentTable(tables.Table): employee = tables.Column( linkify=( 'employee:employee:detail', {'slug': tables.A('employment.employee.slug'), }, ), accessor="employment.employee", ) employment = tables.Column( verbose_name=_("Position held"), ) projects = tables.ManyToManyColumn( linkify_item=( 'schedule:project:detail', {'slug': tables.A('slug'), }, ), ) hours = tables.LinkColumn( verbose_name=_("Hours"), footer=lambda table: _('Total: {}').format( sum(x.hours for x in table.data) ), ) delete = tables.CheckBoxColumn(accessor="pk") class Meta: model = Assignment fields = ( 'employee', 'employment', 'projects', 'start', 'end', 'hours', ) empty_text = _("There are no records available")
class OccupationTable(tables.Table): name = tables.Column(linkify=True) people = tables.ManyToManyColumn(linkify_item=True)
class GroupTable(tables.Table): name = tables.Column(linkify=True) members = tables.ManyToManyColumn(linkify_item=True)