123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- import django_tables2 as tables
- from dbsynce.models import *
- from webservice_running.models import *
- from django.contrib.auth import get_user_model
- from django.utils.html import format_html
- from django.utils.translation import gettext_lazy as _
- from dbsynce.lib.dicts import *
- #from webservice_running.lib.dicts import *
- class EventTable(tables.Table):
- id = tables.Column(
- verbose_name=_('ID'),
- attrs={
- "td": {"width": "5%"}
- }
- )
- title = tables.LinkColumn(
- 'sharix_admin:order_detail',
- args=[tables.A('pk')],
- verbose_name=_('Title'),
- attrs={
- "td": {"width": "20%"}
- }
- )
- status = tables.Column(
- accessor='status',
- #accessor='status_by_code(status)',
- verbose_name=_('Status'),
- attrs={
- "td": {"width": "15%"}
- }
- )
- receiver = tables.Column(
- accessor='receiver.get_full_name',
- verbose_name=_('Receiver'),
- #'sharix_admin:user_detail',
- #args=[tables.A('pk')],
- attrs={
- "td": {"width": "20%"}
- }
- )
- time_created = tables.DateTimeColumn(
- verbose_name=_('Created'),
- attrs={
- "td": {"width": "20%"}
- }
- )
- class Meta:
- model = Orders
- attrs = {
- "class": "table table-layout-fixed"
- }
- exclude = (
- 'id_metaservice',
- 'note',
- 'time_placed',
- 'time_start',
- 'time_start_real',
- 'time_start_predicted',
- 'time_finish_real',
- 'time_finish_predicted',
- 'real_price',
- 'predicted_price',
- 'asap',
- 'is_global',
- 'is_visible',
- 'ticket',
- 'service',
- 'service_category',
- 'client',
- 'provider',
- 'company')
- class PlaceTable(tables.Table):
- id = tables.LinkColumn(
- 'sharix_admin:resource_detail',
- args=[tables.A('pk')],
- verbose_name=_('ID'),
- attrs={
- "td": {"width": "5%"}
- }
- )
- # В user ссылка LinkColumn на страницу Аси "Информация о партнере" страница partner_information_form
- user = tables.Column(
- accessor='user.get_full_name',
- order_by=('user.first_name', 'user.last_name'),
- verbose_name=_('Responsible'),
- attrs={
- "td": {"width": "15%"}
- }
- )
- status = tables.Column(
- verbose_name=_('Status'),
- attrs={
- 'th': {'scope': 'col'},
- "td": {"width": "20%"}
- }
- )
- resource_type = tables.Column(
- attrs={
- 'th': {'scope': 'col'},
- "td": {"width": "20%"}
- }
- )
- edit = tables.LinkColumn(
- 'sharix_admin:resource/edit/',
- verbose_name='',
- orderable=False,
- text="E",
- args=[tables.A('pk')],
- attrs={
- 'th': {'scope': 'col'},
- "td": {"class": "edit_col"},
- "td": {"width": "10%"}
- }
- )
- check = tables.BooleanColumn(
- verbose_name='',
- attrs={
- 'th': {'scope': 'col'},
- "td": {"width": "10%"}
- }
- )
- # paginate_by = 10
- class Meta:
- model = Resource
- attrs = {
- "class": "table table-layout-fixed"
- }
- exclude = (
- 'id_metaservice',
- 'requirements',
- 'is_global',
- 'is_visible',
- 'ticket_status'
- )
- def render_check(self, value, record):
- if record.status == 'active':
- return format_html(
- '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-resource-id="{}">',
- record.id
- )
- else:
- return format_html(
- '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-resource-id="{}">',
- record.id
- )
|