1
0

tables.py 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. import django_tables2 as tables
  2. from metaservicesynced.models import *
  3. from .models import *
  4. from django.utils.html import format_html
  5. from metaservicesynced.models import *
  6. class TransactionsWalletTable(tables.Table):
  7. # id = tables.Column(order_by=True)
  8. id = tables.Column(verbose_name='#', orderable=False, attrs={"td":{"width":"5%"}})
  9. wallet = tables.Column(verbose_name='Владелец', orderable=False, attrs={"td":{"width":"15%"}})
  10. name_operation = tables.Column(verbose_name='Услуга', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  11. price = tables.Column(verbose_name='Баллы', attrs={"class":"row", "td":{"width":"10%"}})
  12. date_operation = tables.Column(verbose_name='Дата оформления', attrs={"td":{"width":"30%"}})
  13. is_carried_out = tables.BooleanColumn(verbose_name='Статус', orderable=False, yesno="Успешно,Не успешно", attrs={"td":{"width":"20%"}})
  14. class Meta:
  15. #model = TransactionsWallets
  16. attrs = {"class": "table table-striped"}
  17. exclude = ("balance_before",
  18. "amount",
  19. "metaservice_id",
  20. "transaction_type",
  21. "doc_num",
  22. "service_id")
  23. def render_name_operation(self, value, record):
  24. return format_html("<a href='{}'>{}</a>", record.get_absolute_url(), value)
  25. class PartnersTable(tables.Table):
  26. id = tables.Column(verbose_name='ID', attrs={"td":{"width":"5%"}})
  27. legal_name = tables.Column(verbose_name='Юрлицо', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  28. repr_id = tables.Column(accessor='repr_id.full_name', order_by=('repr_id.first_name', 'repr_id.last_name'), verbose_name='Ответственный', attrs={"td":{"width":"15%"}})
  29. status = tables.Column(verbose_name='Статус', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  30. check = tables.BooleanColumn(verbose_name='', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  31. # paginate_by = 10
  32. class Meta:
  33. model = Company
  34. attrs = {"class": "table table-layout-fixed"}
  35. exclude = ('inn','kpp','ogrn', 'bank_name',
  36. 'bik', 'ks', 'rs',
  37. 'address', 'requirements',
  38. 'id_metaservice', 'is_global', 'is_visible', 'ticket_status')
  39. def render_check(self, value, record):
  40. if record.status == 'active':
  41. return format_html('<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-partners-id="{}">', record.id)
  42. else:
  43. return format_html('<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-partners-id="{}">', record.id)
  44. class ResourceTable(tables.Table):
  45. id = tables.Column(verbose_name='ID', attrs={"td":{"width":"5%"}})
  46. #В user_id ссылка LinkColumn на страницу Аси "Информация о партнере" страница partner_information_form
  47. user_id = tables.Column(accessor='user_id.full_name', order_by=('user_id.first_name', 'user_id.last_name'), verbose_name='Ответственный', attrs={"td":{"width":"15%"}})
  48. status = tables.Column(verbose_name='Статус', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  49. check = tables.BooleanColumn(verbose_name='', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  50. # paginate_by = 10
  51. class Meta:
  52. model = Resource
  53. attrs = {"class": "table table-layout-fixed"}
  54. exclude = ('type_id','requirements','ticket_status', 'id_metaservice',
  55. 'is_global', 'is_visible')
  56. def render_check(self, value, record):
  57. if record.status == 'active':
  58. return format_html('<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-resource-id="{}">', record.id)
  59. else:
  60. return format_html('<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-resource-id="{}">', record.id)
  61. class ProviderTable(tables.Table):
  62. id = tables.Column(verbose_name='ID', attrs={"td":{"width":"5%"}})
  63. user_id = tables.Column(accessor='user_id.full_name', order_by=('user_id.first_name', 'user_id.last_name'), verbose_name='ФИО', attrs={"td":{"width":"15%"}})
  64. status = tables.Column(verbose_name='Статус', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  65. check = tables.BooleanColumn(verbose_name='', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  66. paginate_by = 10
  67. class Meta:
  68. model = Provider
  69. attrs = {"class": "table table-layout-fixed"}
  70. exclude = ('type','company_id','id_metaservice', 'requirements',
  71. 'ticket_status', 'location_type', 'default_location',
  72. 'is_global', 'is_visible')
  73. def render_check(self, value, record):
  74. if record.status == 'active':
  75. return format_html('<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-provider-id="{}">', record.id)
  76. else:
  77. return format_html('<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-provider-id="{}">', record.id)
  78. class ServiceTariffTable(tables.Table):
  79. id = tables.Column(verbose_name='ID', attrs={"td":{"width":"5%"}})
  80. servicetype_id = tables.LinkColumn('service_tariff/edit/', verbose_name='Название тарифа', text = lambda record: record.servicetype_id.caption,
  81. args=[tables.A('pk')], attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  82. ticket_status = tables.Column(verbose_name='Название схемы услуги', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  83. check = tables.BooleanColumn(verbose_name='Активность', orderable=False, attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  84. class Meta:
  85. model = Service
  86. attrs = {"class": "table table-layout-fixed"}
  87. exclude = ('resource_id','id_provider','price_alg',
  88. 'price_min','price_amount','id_metaservice',
  89. 'requirements', 'service_status', 'price_km',
  90. 'is_global', 'is_visible','status')
  91. def render_check(self, value, record):
  92. if record.status == 'active':
  93. return format_html('<input class="form-check-input status-toggle" disabled checked type="checkbox"')
  94. else:
  95. return format_html('<input class="form-check-input status-toggle" disabled type="checkbox"')
  96. class ServiceTypeTable(tables.Table):
  97. id = tables.Column(verbose_name='ID', attrs={"td":{"width":"5%"}})
  98. caption = tables.LinkColumn('service_type/edit/', verbose_name='Название услуги', text = lambda record: record.caption,
  99. args=[tables.A('pk')], attrs={'th':{'scope':'col'}, "td":{"width":"100%"},})
  100. deletee = tables.LinkColumn('service_type/delete/', verbose_name='', text = "Удалить",
  101. args=[tables.A('pk')], attrs={'th':{'scope':'col'}, "td":{"width":"auto"},})
  102. class Meta:
  103. model = ServiceType
  104. attrs = {"class": "table table-layout-fixed text-start"}
  105. exclude = ('codename','description','requirements',
  106. 'price_type','status','ticket_status',
  107. 'id_metaservice', 'link_agreement',
  108. 'is_global', 'is_visible',)
  109. def render_delete(self, value, record):
  110. return format_html('<a href="/service_type/delete" class="btn btn-outline-danger">Удалить</a>')
  111. def render_name_operation(self, value, record):
  112. return format_html("<a href='{}'>{}</a>", record.get_absolute_url(), value)
  113. class ServiceTable(tables.Table):
  114. id = tables.Column(verbose_name='ID', attrs={"td":{"width":"5%"}})
  115. servicetype_id = tables.Column(verbose_name='Описание услуги (сервиса)', accessor = 'servicetype_id.caption',
  116. attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  117. # description = tables.Column(verbose_name='Название тарифа', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  118. # description = tables.Column(verbose_name='Описание строки тарифов', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  119. # price_type = tables.Column(verbose_name='Тип тарифа', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  120. price_km = tables.Column(verbose_name='Стоимость км.', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  121. price_min = tables.Column(verbose_name='Стоимость мин.', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  122. price_amount = tables.Column(verbose_name='Стоимость услуги', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  123. class Meta:
  124. model = Service
  125. attrs = {"class": "table table-layout-fixed"}
  126. exclude = ('resource_id', 'requirements', 'id_provider',
  127. 'id_metaservice', 'price_alg', 'service_status', 'ticket_status',
  128. 'is_global', 'is_visible')
  129. def render_check(self, value, record):
  130. if record.status == 'active':
  131. return format_html('<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-service-id="{}">', record.id)
  132. else:
  133. return format_html('<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-service-id="{}">', record.id)
  134. class UserInfoTable(tables.Table):
  135. id = tables.Column(verbose_name='ID', attrs={"td":{"width":"5%"}})
  136. class Meta:
  137. model = SharixUser
  138. attrs = {"class": "table table-layout-fixed"}
  139. exclude = ('password', 'phone_number',
  140. 'last_login','is_staff', 'is_superuser',
  141. 'date_joined')