tables.py 1.4 KB

12345678910111213141516171819202122232425262728
  1. import django_tables2 as tables
  2. from .models import *
  3. from django.utils.html import format_html
  4. class TransactionsWalletTable(tables.Table):
  5. # id = tables.Column(order_by=True)
  6. id = tables.Column(verbose_name='#', orderable=False, attrs={"td":{"width":"5%"}})
  7. wallet = tables.Column(verbose_name='Владелец', orderable=False, attrs={"td":{"width":"15%"}})
  8. name_operation = tables.Column(verbose_name='Услуга', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  9. price = tables.Column(verbose_name='Баллы', attrs={"class":"row", "td":{"width":"10%"}})
  10. date_operation = tables.Column(verbose_name='Дата оформления', attrs={"td":{"width":"30%"}})
  11. is_carried_out = tables.BooleanColumn(verbose_name='Статус', orderable=False, yesno="Успешно,Не успешно", attrs={"td":{"width":"20%"}})
  12. class Meta:
  13. #model = TransactionsWallets
  14. attrs = {"class": "table table-striped"}
  15. exclude = ("balance_before",
  16. "amount",
  17. "metaservice_id",
  18. "transaction_type",
  19. "doc_num",
  20. "service_id")
  21. def render_name_operation(self, value, record):
  22. return format_html("<a href='{}'>{}</a>", record.get_absolute_url(), value)