class SimpleTable(tables.Table): a = tables.Column() b = tables.Column(orderable=False)
class OccupationTable2(tables.Table): extra = tables.Column() class Meta: model = Occupation
class OccupationTable(TableMixin, tables.Table): extra2 = tables.Column() class Meta: model = Occupation
class SimpleTable(tables.Table): name = tables.Column(order_by=('first_name', 'last_name'))
class PersonTable(tables.Table): delete = tables.Column()
class OperatorConsoleTable(tables.Table): bus_depot_zone = tables.Column(accessor='volunteer_bus.bus_depot.depot_zone') bus_depot_code = tables.Column(accessor='volunteer_bus.bus_depot.depot_code') bus_depot_name = tables.Column(accessor='volunteer_bus.bus_depot.depot_name') bus_volunteer_depot_login_time = tables.Column(accessor='volunteer_bus.bus_volunteer_depot_login_time') bus_safe_time = tables.Column(accessor='volunteer_bus.bus_safe_time') bus_expected_number_of_children = tables.Column(accessor='volunteer_bus.bus_expected_number_of_children') bus_expected_number_of_adults = tables.Column(accessor='volunteer_bus.bus_expected_number_of_adults') bus_number_water_bottles_initial = tables.Column(accessor='volunteer_bus.bus_number_water_bottles_initial') bus_number_food_packets_initial = tables.Column(accessor='volunteer_bus.bus_number_food_packets_initial') bus_number_tickets_initial = tables.Column(accessor='volunteer_bus.bus_number_tickets_initial') #bus_started_from_depot_flag = tables.Column(accessor='volunteer_bus.bus_started_from_depot_flag') bus_started_from_depot_time = tables.Column(accessor='volunteer_bus.bus_started_from_depot_time') bus_first_aid_kit_available_flag = tables.Column(accessor='volunteer_bus.bus_first_aid_kit_available_flag') bus_num_children_male_pickedup = tables.Column(accessor='volunteer_bus.bus_num_children_male_pickedup') bus_num_children_female_pickedup = tables.Column(accessor='volunteer_bus.bus_num_children_female_pickedup') bus_num_adults_male_pickedup = tables.Column(accessor='volunteer_bus.bus_num_adults_male_pickedup') bus_num_adults_female_pickedup = tables.Column(accessor='volunteer_bus.bus_num_adults_female_pickedup') #all_deboarded_at_stadium_flag = tables.Column(accessor='volunteer_bus.all_deboarded_at_stadium_flag') all_deboarded_at_stadium_time = tables.Column(accessor='volunteer_bus.all_deboarded_at_stadium_time') num_children_male_seated = tables.Column(accessor='volunteer_bus.num_children_male_seated') num_children_female_seated = tables.Column(accessor='volunteer_bus.num_children_female_seated') num_adults_male_seated = tables.Column(accessor='volunteer_bus.num_adults_male_seated') num_adults_female_seated = tables.Column(accessor='volunteer_bus.num_adults_female_seated') bus_num_children_male_return_journey = tables.Column(accessor='volunteer_bus.bus_num_children_male_return_journey') bus_num_children_female_return_journey = tables.Column( accessor='volunteer_bus.bus_num_children_female_return_journey') bus_num_adults_male_return_journey = tables.Column(accessor='volunteer_bus.bus_num_adults_male_return_journey') bus_num_adults_female_return_journey = tables.Column(accessor='volunteer_bus.bus_num_adults_female_return_journey') #everyone_dropped_off_flag = tables.Column(accessor='volunteer_bus.everyone_dropped_off_flag') everyone_dropped_off_time = tables.Column(accessor='volunteer_bus.everyone_dropped_off_time') #feedback_form_taken_from_ngo_flag = tables.Column(accessor='volunteer_bus.feedback_form_taken_from_ngo_flag') feedback_form_taken_from_ngo_time = tables.Column(accessor='volunteer_bus.feedback_form_taken_from_ngo_time') bus_furthest_screen = tables.Column(accessor='volunteer_bus.bus_furthest_screen') # bus_last_location_latitude = tables.Column(accessor='volunteer_bus.bus_last_location_latitude') # bus_last_location_longitude = tables.Column(accessor='volunteer_bus.bus_last_location_longitude') # Render Bus Code Number def render_volunteer_bus(self, value): return value.bus_code_num # Ensure number of children expected == number of children picked up def render_bus_num_children_male_pickedup(self, value, record): return verifySumConstraint(value, record.volunteer_bus.bus_num_children_female_pickedup, record.volunteer_bus.bus_expected_number_of_children) def render_bus_num_children_female_pickedup(self, value, record): return verifySumConstraint(value, record.volunteer_bus.bus_num_children_male_pickedup, record.volunteer_bus.bus_expected_number_of_children) # Ensure number of adults expected == number of adults picked up def render_bus_num_adults_male_pickedup(self, value, record): return verifySumConstraint(value, record.volunteer_bus.bus_num_adults_female_pickedup, record.volunteer_bus.bus_expected_number_of_adults) def render_bus_num_adults_female_pickedup(self, value, record): return verifySumConstraint(value, record.volunteer_bus.bus_num_adults_male_pickedup, record.volunteer_bus.bus_expected_number_of_adults) # Ensure number of children expected == number of children seated def render_num_children_male_seated(self, value, record): return verifySumConstraint(value, record.volunteer_bus.num_children_female_seated, record.volunteer_bus.bus_expected_number_of_children) def render_num_children_female_seated(self, value, record): return verifySumConstraint(value, record.volunteer_bus.num_children_male_seated, record.volunteer_bus.bus_expected_number_of_children) # Ensure number of adults expected == number of adults seated def render_num_adults_male_seated(self, value, record): return verifySumConstraint(value, record.volunteer_bus.num_adults_female_seated, record.volunteer_bus.bus_expected_number_of_adults) def render_num_adults_female_seated(self, value, record): return verifySumConstraint(value, record.volunteer_bus.num_adults_male_seated, record.volunteer_bus.bus_expected_number_of_adults) # Ensure number of children expected == number of children on return journey def render_bus_num_children_male_return_journey(self, value, record): return verifySumConstraint(value, record.volunteer_bus.bus_num_children_female_return_journey, record.volunteer_bus.bus_expected_number_of_children) def render_bus_num_children_female_return_journey(self, value, record): return verifySumConstraint(value, record.volunteer_bus.bus_num_children_male_return_journey, record.volunteer_bus.bus_expected_number_of_children) # Ensure number of adults expected == number of adults on return journey def render_bus_num_adults_male_return_journey(self, value, record): return verifySumConstraint(value, record.volunteer_bus.bus_num_adults_female_return_journey, record.volunteer_bus.bus_expected_number_of_adults) def render_bus_num_adults_female_return_journey(self, value, record): return verifySumConstraint(value, record.volunteer_bus.bus_num_adults_male_return_journey, record.volunteer_bus.bus_expected_number_of_adults) # Ensure number of tickets == number of children + adult expected def render_bus_number_tickets_initial(self, value, record): return verifySumConstraint(value, record.volunteer_bus.bus_expected_number_of_adults, record.volunteer_bus.bus_expected_number_of_children) class Meta: model = Volunteer # add class="paleblue" to <table> tag attrs = {"class": "paleblue"} sequence = ("bus_depot_zone", "bus_depot_code", "bus_depot_name", "volunteer_bus", "...")
class FaultyPersonTable(PersonTable): missing = tables.Column()
class SimpleTable(tables.Table): column = tables.Column(accessor=lambda: 'foo', default='')
class PersonTable(tables.Table): safe = tables.Column()
class SimpleTable(tables.Table): safe = tables.Column(verbose_name=mark_safe("<b>Safe</b>"))
class SimpleTable(tables.Table): column = tables.Column(accessor={})
class SimpleTable(tables.Table): basic = tables.Column() acronym = tables.Column(verbose_name="has FBI help")
class Table(tables.Table): column = tables.Column()
class Table(tables.Table): a = tables.Column(empty_values=(1, 2), default="--")
class DeviceTable(BaseTable): pk = ToggleColumn() name = tables.TemplateColumn(order_by=('_name', ), template_code=DEVICE_LINK) status = ChoiceFieldColumn() tenant = TenantColumn() site = tables.Column(linkify=True) location = tables.Column(linkify=True) rack = tables.Column(linkify=True) device_role = ColoredLabelColumn(verbose_name='Role') manufacturer = tables.Column( accessor=Accessor('device_type__manufacturer'), linkify=True) device_type = tables.Column(linkify=True, verbose_name='Type') if settings.PREFER_IPV4: primary_ip = tables.Column(linkify=True, order_by=('primary_ip4', 'primary_ip6'), verbose_name='IP Address') else: primary_ip = tables.Column(linkify=True, order_by=('primary_ip6', 'primary_ip4'), verbose_name='IP Address') primary_ip4 = tables.Column(linkify=True, verbose_name='IPv4 Address') primary_ip6 = tables.Column(linkify=True, verbose_name='IPv6 Address') cluster = tables.Column(linkify=True) virtual_chassis = tables.Column(linkify=True) vc_position = tables.Column(verbose_name='VC Position') vc_priority = tables.Column(verbose_name='VC Priority') comments = MarkdownColumn() tags = TagColumn(url_name='dcim:device_list') class Meta(BaseTable.Meta): model = Device fields = ( 'pk', 'id', 'name', 'status', 'tenant', 'device_role', 'manufacturer', 'device_type', 'platform', 'serial', 'asset_tag', 'site', 'location', 'rack', 'position', 'face', 'primary_ip', 'primary_ip4', 'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'tags', ) default_columns = ( 'pk', 'name', 'status', 'tenant', 'site', 'location', 'rack', 'device_role', 'manufacturer', 'device_type', 'primary_ip', )
class SimpleTable(tables.Table): acronym = tables.Column(verbose_name="")
class DeviceInterfaceTable(InterfaceTable): name = tables.TemplateColumn( template_code= '<i class="mdi mdi-{% if record.mgmt_only %}wrench{% elif record.is_lag %}reorder-horizontal' '{% elif record.is_virtual %}circle{% elif record.is_wireless %}wifi{% else %}ethernet' '{% endif %}"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>', order_by=Accessor('_name'), attrs={'td': { 'class': 'text-nowrap' }}) parent = tables.Column(linkify=True, verbose_name='Parent') lag = tables.Column(linkify=True, verbose_name='LAG') actions = ButtonsColumn(model=Interface, buttons=('edit', 'delete'), prepend_template=INTERFACE_BUTTONS) class Meta(DeviceComponentTable.Meta): model = Interface fields = ( 'pk', 'id', 'name', 'label', 'enabled', 'type', 'parent', 'lag', 'mgmt_only', 'mtu', 'mode', 'mac_address', 'description', 'mark_connected', 'cable', 'cable_color', 'cable_peer', 'connection', 'tags', 'ip_addresses', 'untagged_vlan', 'tagged_vlans', 'actions', ) order_by = ('name', ) default_columns = ( 'pk', 'name', 'label', 'enabled', 'type', 'parent', 'lag', 'mtu', 'mode', 'description', 'ip_addresses', 'cable', 'connection', 'actions', ) row_attrs = { 'class': get_interface_row_class, 'data-name': lambda record: record.name, 'data-enabled': get_interface_state_attribute, }
class Table(tables.Table): count = tables.Column(accessor='info_list.count')
class PersonTable(tables.Table): first_name = tables.Column() last_name = tables.Column() occupation = tables.Column()
class SimpleTable(tables.Table): name = tables.Column()
class MultiRenderTable(tables.Table): name = tables.Column()
class MissingStudyTable(tables.Table): sample_id = tables.Column(verbose_name='Missing Sample ID') class Meta: attrs = {'class': 'table table-striped table-bordered'}
class PersonTable(tables.Table): extra = tables.Column() class Meta: model = Person fields = ('last_name', 'first_name')
class CountTable(tables.Table): name = tables.Column() count = tables.Column() class Meta: attrs = {'class': 'table table-striped table-bordered'}
class PersonTable(tables.Table): name = tables.Column(order_by=("first_name", "last_name")) occupation = tables.Column(order_by=("occupation__name", ))
class PostTable(tables.Table): date = tables.Column(accessor='date') collectdate = tables.Column(accessor='collectdate', verbose_name='Collect Date') address = tables.Column(accessor='address', verbose_name='Address') description = tables.Column(accessor='description', verbose_name='Description') usercompany = tables.Column(accessor='user.CompanyName', verbose_name='Company') foodtype = tables.Column(accessor='foodtype.name', verbose_name='Food') quantity = tables.Column(accessor='quantity', verbose_name='Quantity') class Meta: model = post order_by = 'collectdate' fields = ('date', 'collectdate', 'address', 'description', 'usercompany', 'foodtype', 'quantity') sequence = ('usercompany', 'collectdate', 'address', 'foodtype', 'quantity', 'description', 'date') def __init__(self, *args, **kwargs): tuser = kwargs.pop("user") super(PostTable, self).__init__(*args, **kwargs) self.requestuser = tuser def render_usercompany(self, value, record): return mark_safe("<div class=\"card-header\">Company: %s" % (escape(value))) def render_collectdate(self, value, record): return mark_safe( " <large class=\"float-sm-right\">Pick up By: %s</large></div>" % (escape(value.strftime('%d %B %Y')))) def render_address(self, value, record): return mark_safe("<ul class=\"list-group list-group-flush\">\ <li class=\"list-group-item\">Address: %s <large class=\"float-sm-right\">Contact: %s </large></li>" % (escape(value), escape(record.user.Contact))) def render_foodtype(self, value, record): return mark_safe("<li class=\"list-group-item\">Food Type: %s" % (escape(value))) def render_quantity(self, value, record): return mark_safe( "<large class=\"float-sm-right\">Quantity: %s tonnes</large></li>" % (escape(value))) def render_description(self, value, record): return mark_safe( "<li class=\"list-group-item\">Description: %s</li></ul>" % (escape(value))) def render_date(self, value, record): if (self.requestuser == record.user): return mark_safe("<div class=\"card-footer text-muted\">\ <small class=\"float-sm-right\">%s</small>\ </div><button userid=\"%s\" id=\"%s\"type=\"button\" class=\"btn btn-sm btn-primary\" onclick=\"location.href = '/post/post/%s';\" aria-label=\"Close\">\ Update\ </button><button userid=\"%s\" id=\"%s\"type=\"button\" class=\"btn btn-danger\" onclick=\"location.href = '/post/posts/delete/%s';\" aria-label=\"Close\">\ Remove\ </button>" % (escape(value.strftime('%d %B %Y')), escape(record.user.pk), escape(record.pk), escape(record.pk), escape( record.user.pk), escape(record.pk), escape(record.pk))) else: return mark_safe("<div class=\"card-footer text-muted\">\ <small class=\"float-sm-right\">%s</small></div>" % (escape(value.strftime('%d %B %Y'))))
class TableMixin(tables.Table): extra = tables.Column()
class AllServicesTable(tables.Table): service_name = tables.Column(verbose_name = 'Nazwa usługi', accessor = 'service.service_code.se_dict_name') service_detetime_start = tables.DateTimeColumn(accessor = 'service.planned_start', format="d-m-Y H:i") service_detetime_end = tables.DateTimeColumn(accessor = 'service.planned_end', format="d-m-Y H:i") service_price = tables.Column(verbose_name = 'Bazowa cena [zł]', accessor = 'service.service_code.base_price') client_first_name = tables.Column(accessor = 'service.client.first_name', visible = False) client_last_name = tables.Column(accessor = 'service.client.last_name', visible = False) client_name = tables.Column(accessor = 'service.client.get_client_full_name', orderable = False) worker_first_name = tables.Column(accessor = 'worker.first_name', visible = False) worker_last_name = tables.Column(accessor = 'worker.last_name', visible = False) employee_name = tables.Column(accessor = 'worker.get_employee_name', orderable = False) location_name = tables.Column(verbose_name = 'Nazwa lokalizacji', accessor = 'location.location_name') location_type = tables.Column(verbose_name = 'Typ lokalizacji', accessor = 'location.location_type') machine_name = tables.Column(verbose_name = 'Nazwa maszyny', accessor = 'machine.machine_name') machine_type = tables.Column(verbose_name = 'Typ maszyny', accessor = 'machine.machine_type') class Meta: model = ResourcesUsage fields = {} template = 'django_tables2/bootstrap.html'
class PersonTable(tables.Table): """ The test_colX columns are to test that the accessor is used to determine the field on the model, rather than the column name. """ first_name = tables.Column() fn1 = tables.Column(accessor='first_name') fn2 = tables.Column(accessor='first_name.upper') fn3 = tables.Column(accessor='last_name', verbose_name='OVERRIDE') last_name = tables.Column() ln1 = tables.Column(accessor='last_name') ln2 = tables.Column(accessor='last_name.upper') ln3 = tables.Column(accessor='last_name', verbose_name='OVERRIDE') region = tables.Column(accessor='occupation.region.name') r1 = tables.Column(accessor='occupation.region.name') r2 = tables.Column(accessor='occupation.region.name.upper') r3 = tables.Column(accessor='occupation.region.name', verbose_name='OVERRIDE') trans_test = tables.Column() trans_test_lazy = tables.Column()
class SimpleTable(tables.Table): a = tables.Column()