tables.py 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import django_tables2 as tables
  2. from metaservicesynced.models import *
  3. from .models import *
  4. from django.utils.html import format_html
  5. class TransactionsWalletTable(tables.Table):
  6. # id = tables.Column(order_by=True)
  7. id = tables.Column(verbose_name='#', orderable=False, attrs={"td":{"width":"5%"}})
  8. wallet = tables.Column(verbose_name='Владелец', orderable=False, attrs={"td":{"width":"15%"}})
  9. name_operation = tables.Column(verbose_name='Услуга', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  10. price = tables.Column(verbose_name='Баллы', attrs={"class":"row", "td":{"width":"10%"}})
  11. date_operation = tables.Column(verbose_name='Дата оформления', attrs={"td":{"width":"30%"}})
  12. is_carried_out = tables.BooleanColumn(verbose_name='Статус', orderable=False, yesno="Успешно,Не успешно", attrs={"td":{"width":"20%"}})
  13. class Meta:
  14. #model = TransactionsWallets
  15. attrs = {"class": "table table-striped"}
  16. exclude = ("balance_before",
  17. "amount",
  18. "metaservice_id",
  19. "transaction_type",
  20. "doc_num",
  21. "service_id")
  22. def render_name_operation(self, value, record):
  23. return format_html("<a href='{}'>{}</a>", record.get_absolute_url(), value)
  24. class PartnersTable(tables.Table):
  25. id = tables.Column(verbose_name='ID', attrs={"td":{"width":"5%"}})
  26. legal_name = tables.Column(verbose_name='Юрлицо', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  27. 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%"}})
  28. status = tables.Column(verbose_name='Статус', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  29. check = tables.BooleanColumn(verbose_name='', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  30. # paginate_by = 10
  31. class Meta:
  32. model = Company
  33. attrs = {"class": "table table-layout-fixed"}
  34. exclude = ('inn','kpp','ogrn', 'bank_name',
  35. 'bik', 'ks', 'rs',
  36. 'address', 'requirements',
  37. 'id_metaservice', 'is_global', 'is_visible', 'ticket_status')
  38. def render_check(self, value, record):
  39. if record.status == 'active':
  40. return format_html('<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-partners-id="{}">', record.id)
  41. else:
  42. return format_html('<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-partners-id="{}">', record.id)
  43. class ResourceTable(tables.Table):
  44. id = tables.Column(verbose_name='ID', attrs={"td":{"width":"5%"}})
  45. #В user_id ссылка LinkColumn на страницу Аси "Информация о партнере" страница partner_information_form
  46. 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%"}})
  47. status = tables.Column(verbose_name='Статус', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  48. check = tables.BooleanColumn(verbose_name='', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  49. # paginate_by = 10
  50. class Meta:
  51. model = Resource
  52. attrs = {"class": "table table-layout-fixed"}
  53. exclude = ('type_id','requirements','ticket_status', 'id_metaservice',
  54. 'is_global', 'is_visible')
  55. def render_check(self, value, record):
  56. if record.status == 'active':
  57. return format_html('<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-resource-id="{}">', record.id)
  58. else:
  59. return format_html('<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-resource-id="{}">', record.id)