tables.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 ServiceTypeTable(tables.Table):
  25. id = tables.Column(verbose_name='ID', attrs={"td":{"width":"5%"}})
  26. caption = tables.LinkColumn('service_type/edit/', verbose_name='Название услуги', text = lambda record: record.caption,
  27. args=[tables.A('pk')], attrs={'th':{'scope':'col'}, "td":{"width":"100%"},})
  28. deletee = tables.LinkColumn('service_type/delete/', verbose_name='', text = "Удалить",
  29. args=[tables.A('pk')], attrs={'th':{'scope':'col'}, "td":{"width":"auto"},})
  30. class Meta:
  31. model = ServiceType
  32. attrs = {"class": "table table-layout-fixed text-start"}
  33. exclude = ('codename','description','requirements',
  34. 'price_type','status','ticket_status',
  35. 'id_metaservice', 'link_agreement',
  36. 'is_global', 'is_visible',)
  37. def render_delete(self, value, record):
  38. return format_html('<a href="/service_type/delete" class="btn btn-outline-danger">Удалить</a>')