tables.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  1. import django_tables2 as tables
  2. from dbsynce.models import *
  3. from dbsynce.models import *
  4. from django.contrib.auth import get_user_model
  5. from django.utils.html import format_html
  6. from django.utils.translation import gettext_lazy as _
  7. from dbsynce.lib.dicts import *
  8. class TransactionsWalletTable(tables.Table):
  9. # id = tables.Column(order_by=True)
  10. id = tables.Column(
  11. verbose_name='#',
  12. orderable=False,
  13. attrs={
  14. "td": {"width": "5%"}
  15. }
  16. )
  17. wallet = tables.Column(
  18. verbose_name=_('Owner'),
  19. orderable=False,
  20. attrs={
  21. "td": {"width": "15%"}
  22. }
  23. )
  24. name_operation = tables.Column(
  25. verbose_name=_('Service'),
  26. attrs={
  27. 'th': {'scope': 'col'},
  28. "td": {"width": "20%"}
  29. }
  30. )
  31. price = tables.Column(
  32. verbose_name=_('Points'),
  33. attrs={
  34. "class": "row",
  35. "td": {"width": "10%"}
  36. }
  37. )
  38. date_operation = tables.Column(
  39. verbose_name=_('Registration date'),
  40. attrs={
  41. "td": {"width": "30%"}
  42. }
  43. )
  44. is_carried_out = tables.BooleanColumn(
  45. verbose_name=_('Status'),
  46. orderable=False,
  47. yesno=_("Successful, not successful"),
  48. attrs={
  49. "td": {"width": "20%"}
  50. }
  51. )
  52. class Meta:
  53. # model = TransactionsWallets
  54. attrs = {
  55. "class": "table table-striped"
  56. }
  57. exclude = (
  58. "balance_before",
  59. "amount",
  60. "metaservice_id",
  61. "transaction_type",
  62. "doc_num",
  63. "service_id"
  64. )
  65. def render_name_operation(self, value, record):
  66. return format_html(
  67. "<a href='{}'>{}</a>",
  68. record.get_absolute_url(),
  69. value
  70. )
  71. class PartnersTable(tables.Table):
  72. id = tables.Column(
  73. verbose_name=_('ID'),
  74. attrs={
  75. "td": {"width": "5%"}
  76. }
  77. )
  78. #legal_name = tables.Column(
  79. # verbose_name=_('Legal entity'),
  80. # attrs={
  81. # 'th': {'scope': 'col'},
  82. # "td": {"width": "20%"}
  83. # }
  84. #)
  85. legal_name = tables.LinkColumn(
  86. 'sharix_admin:partner_detail',
  87. args=[tables.A('pk')],
  88. verbose_name=_('Legal entity'),
  89. #args=[tables.A('pk')],
  90. attrs={
  91. 'th': {'scope': 'col'},
  92. "td": {"width": "20%"}
  93. }
  94. )
  95. repr = tables.Column(
  96. accessor='repr.full_name',
  97. order_by=('repr.first_name', 'repr.last_name'),
  98. verbose_name=_('Responsible'),
  99. attrs={
  100. "td": {"width": "15%"}
  101. }
  102. )
  103. status = tables.Column(
  104. verbose_name=_('Status'),
  105. attrs={
  106. 'th': {'scope': 'col'},
  107. "td": {"width": "20%"}
  108. }
  109. )
  110. check = tables.BooleanColumn(
  111. verbose_name='',
  112. attrs={
  113. 'th': {'scope': 'col'},
  114. "td": {"width": "20%"}
  115. }
  116. )
  117. # paginate_by = 10
  118. class Meta:
  119. model = Company
  120. attrs = {
  121. "class": "table table-layout-fixed"
  122. }
  123. exclude = (
  124. 'inn',
  125. 'kpp',
  126. 'ogrn',
  127. 'bank_name',
  128. 'bik',
  129. 'ks',
  130. 'rs',
  131. 'address',
  132. 'requirements',
  133. 'id_metaservice',
  134. 'is_global',
  135. 'is_visible',
  136. 'ticket_status',
  137. )
  138. def render_check(self, value, record):
  139. if record.status == '0':
  140. return format_html(
  141. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-partners-id="{}">',
  142. record.id
  143. )
  144. else:
  145. return format_html(
  146. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-partners-id="{}">',
  147. record.id
  148. )
  149. class OrdersTable(tables.Table):
  150. id = tables.Column(
  151. verbose_name=_('ID'),
  152. attrs={
  153. "td": {"width": "5%"}
  154. }
  155. )
  156. title = tables.LinkColumn(
  157. 'sharix_admin:order_detail',
  158. args=[tables.A('pk')],
  159. verbose_name=_('Title'),
  160. attrs={
  161. "td": {"width": "20%"}
  162. }
  163. )
  164. status = tables.Column(
  165. accessor='status',
  166. #accessor='status_by_code(status)',
  167. verbose_name=_('Status'),
  168. attrs={
  169. "td": {"width": "15%"}
  170. }
  171. )
  172. receiver = tables.Column(
  173. accessor='receiver.get_full_name',
  174. verbose_name=_('Receiver'),
  175. #'sharix_admin:user_detail',
  176. #args=[tables.A('pk')],
  177. attrs={
  178. "td": {"width": "20%"}
  179. }
  180. )
  181. time_created = tables.DateTimeColumn(
  182. verbose_name=_('Created'),
  183. attrs={
  184. "td": {"width": "20%"}
  185. }
  186. )
  187. class Meta:
  188. model = Orders
  189. attrs = {
  190. "class": "table table-layout-fixed"
  191. }
  192. exclude = (
  193. 'id_metaservice',
  194. 'note',
  195. 'time_placed',
  196. 'time_start',
  197. 'time_start_real',
  198. 'time_start_predicted',
  199. 'time_finish_real',
  200. 'time_finish_predicted',
  201. 'real_price',
  202. 'predicted_price',
  203. 'asap',
  204. 'is_global',
  205. 'is_visible',
  206. 'ticket',
  207. 'service',
  208. 'service_category',
  209. 'client',
  210. 'provider',
  211. 'company')
  212. class ResourcesTable(tables.Table):
  213. id = tables.LinkColumn(
  214. 'sharix_admin:resource_detail',
  215. args=[tables.A('pk')],
  216. verbose_name=_('ID'),
  217. attrs={
  218. "td": {"width": "5%"}
  219. }
  220. )
  221. # В user ссылка LinkColumn на страницу Аси "Информация о партнере" страница partner_information_form
  222. user = tables.Column(
  223. accessor='user.get_full_name',
  224. order_by=('user.first_name', 'user.last_name'),
  225. verbose_name=_('Responsible'),
  226. attrs={
  227. "td": {"width": "15%"}
  228. }
  229. )
  230. status = tables.Column(
  231. verbose_name=_('Status'),
  232. attrs={
  233. 'th': {'scope': 'col'},
  234. "td": {"width": "20%"}
  235. }
  236. )
  237. resource_type = tables.Column(
  238. attrs={
  239. 'th': {'scope': 'col'},
  240. "td": {"width": "20%"}
  241. }
  242. )
  243. edit = tables.LinkColumn(
  244. 'sharix_admin:resource/edit/',
  245. verbose_name='',
  246. orderable=False,
  247. text="E",
  248. args=[tables.A('pk')],
  249. attrs={
  250. 'th': {'scope': 'col'},
  251. "td": {"class": "edit_col"},
  252. "td": {"width": "10%"}
  253. }
  254. )
  255. check = tables.BooleanColumn(
  256. verbose_name='',
  257. attrs={
  258. 'th': {'scope': 'col'},
  259. "td": {"width": "10%"}
  260. }
  261. )
  262. # paginate_by = 10
  263. class Meta:
  264. model = Resource
  265. attrs = {
  266. "class": "table table-layout-fixed"
  267. }
  268. exclude = (
  269. 'id_metaservice',
  270. 'requirements',
  271. 'is_global',
  272. 'is_visible',
  273. 'ticket_status'
  274. )
  275. def render_check(self, value, record):
  276. if record.status == '0':
  277. return format_html(
  278. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-resource-id="{}">',
  279. record.id
  280. )
  281. else:
  282. return format_html(
  283. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-resource-id="{}">',
  284. record.id
  285. )
  286. class ProvidersTable(tables.Table):
  287. id = tables.LinkColumn(
  288. 'sharix_admin:provider_detail',
  289. args=[tables.A('pk')],
  290. verbose_name=_('ID'),
  291. attrs={
  292. "td": {"width": "5%"}
  293. }
  294. )
  295. user = tables.Column(
  296. accessor='user.full_name',
  297. order_by=('user.first_name', 'user.last_name'),
  298. verbose_name=_('Full Name'),
  299. attrs={
  300. "td": {"width": "15%"}
  301. }
  302. )
  303. status = tables.Column(
  304. #verbose_name=_('Status'),
  305. attrs={
  306. 'th': {'scope': 'col'},
  307. "td": {"width": "20%"}
  308. }
  309. )
  310. service = tables.LinkColumn(
  311. 'sharix_admin:service_tariff_detail',
  312. args=[tables.A('service.pk')],
  313. accessor='service.caption',
  314. verbose_name=_('Service'),
  315. attrs={
  316. 'th': {'scope': 'col'},
  317. "td": {"width": "20%"}
  318. }
  319. )
  320. resource = tables.LinkColumn(
  321. 'sharix_admin:resource_detail',
  322. args=[tables.A('resource.pk')],
  323. accessor='resource.resource_type',
  324. verbose_name=_('Resource'),
  325. attrs={
  326. 'th': {'scope': 'col'},
  327. "td": {"width": "20%"}
  328. }
  329. )
  330. #edit = tables.LinkColumn(
  331. # 'sharix_admin:provider/edit/',
  332. # verbose_name='',
  333. # orderable=False,
  334. # text="E",
  335. # args=[tables.A('pk')],
  336. # attrs={
  337. # 'th': {'scope': 'col'},
  338. # "td": {"class": "edit_col"}
  339. # }
  340. #)
  341. check = tables.BooleanColumn(
  342. verbose_name='',
  343. attrs={
  344. 'th': {'scope': 'col'},
  345. "td": {"width": "20%"}
  346. }
  347. )
  348. paginate_by = 10
  349. class Meta:
  350. model = Provider
  351. attrs = {
  352. "class": "table table-layout-fixed"
  353. }
  354. exclude = (
  355. 'id_metaservice',
  356. 'gap',
  357. 'requirements',
  358. 'status',
  359. 'service_status',
  360. 'location_type',
  361. 'default_location',
  362. 'is_global',
  363. 'is_visible',
  364. 'ticket_status',
  365. )
  366. def render_check(self, value, record):
  367. if record.status == '0':
  368. return format_html(
  369. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-provider-id="{}">',
  370. record.id
  371. )
  372. else:
  373. return format_html(
  374. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-provider-id="{}">',
  375. record.id
  376. )
  377. class ServiceTariffsTable(tables.Table):
  378. id = tables.Column(
  379. verbose_name=_('ID'),
  380. attrs={
  381. "td": {"width": "5%"}
  382. }
  383. )
  384. codename = tables.LinkColumn(
  385. 'sharix_admin:service_tariff_detail',
  386. verbose_name=_('Кодовое название'),
  387. text=lambda record: record.caption,
  388. args=[tables.A('pk')],
  389. attrs={
  390. 'th': {'scope': 'col'},
  391. "td": {"width": "15%"}
  392. }
  393. )
  394. #service_category = tables.Column(
  395. service_category = tables.LinkColumn(
  396. 'sharix_admin:service_category_detail',
  397. verbose_name=_('Название Типа услуги'),
  398. text=lambda record: record.service_category.caption,
  399. args=[tables.A('pk')],
  400. attrs={
  401. 'th': {'scope': 'col'},
  402. "td": {"width": "15%"}
  403. }
  404. )
  405. resource_type = tables.Column(
  406. #verbose_name=_('Тип ресурса'),
  407. attrs={
  408. 'th': {'scope': 'col'},
  409. "td": {"width": "20%"}
  410. }
  411. )
  412. company_comission = tables.Column(
  413. #verbose_name=_('Комиссия партнера'),
  414. attrs={
  415. 'th': {'scope': 'col'},
  416. "td": {"width": "20%"}
  417. }
  418. )
  419. edit = tables.LinkColumn(
  420. 'sharix_admin:service_tariff/edit/',
  421. verbose_name='',
  422. orderable=False,
  423. text="E",
  424. args=[tables.A('pk')],
  425. attrs={
  426. 'th': {'scope': 'col'},
  427. "td": {"class": "edit_col"}
  428. }
  429. )
  430. check = tables.BooleanColumn(
  431. verbose_name=_('Activity'),
  432. orderable=False,
  433. attrs={
  434. 'th': {'scope': 'col'},
  435. "td": {"width": "20%"}
  436. }
  437. )
  438. class Meta:
  439. model = Service
  440. attrs = {
  441. "class": "table table-layout-fixed"
  442. }
  443. exclude = (
  444. 'resource',
  445. 'company',
  446. 'caption',
  447. 'description',
  448. 'price_type',
  449. 'price_min',
  450. 'price_amount',
  451. 'id_metaservice',
  452. 'requirements',
  453. 'ticket_status',
  454. 'price_km',
  455. 'is_global',
  456. 'is_visible',
  457. 'status'
  458. )
  459. def render_check(self, value, record):
  460. if record.status == '0':
  461. return format_html(
  462. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-service-id="{}">',
  463. record.id
  464. )
  465. else:
  466. return format_html(
  467. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-service-id="{}">',
  468. record.id
  469. )
  470. class ServiceCategoriesTable(tables.Table):
  471. id = tables.LinkColumn(
  472. 'sharix_admin:service_category_detail',
  473. args=[tables.A('pk')],
  474. attrs={"td": {"width": "50px"}}
  475. )
  476. caption = tables.LinkColumn(
  477. 'sharix_admin:service_category_detail',
  478. verbose_name='Услуга',
  479. orderable=False,
  480. text=lambda record: record.caption,
  481. args=[tables.A('pk')],
  482. attrs={
  483. "a": {"style": "pointer-events: none;"},
  484. 'th': {'scope': 'col'},
  485. "td": {"class": "name_col"}
  486. }
  487. )
  488. #codename = tables.LinkColumn(
  489. # 'sharix_admin:service_category/edit/',
  490. # verbose_name='Тех.название',
  491. # orderable=False,
  492. # text=lambda record: record.codename,
  493. # args=[tables.A('pk')],
  494. # attrs={
  495. # "a": {"style": "pointer-events: none;"},
  496. # 'th': {'scope': 'col'},
  497. # "td": {"class": "name_col"}
  498. # }
  499. #)
  500. description = tables.Column(
  501. orderable=False,
  502. #verbose_name='Описание',
  503. #text=lambda record: record.description,
  504. #args=[tables.A('pk')],
  505. attrs={
  506. "a": {"style": "pointer-events: none;"},
  507. 'th': {'scope': 'col'},
  508. "td": {"class": "description_col"}
  509. }
  510. )
  511. metaservice_comission = tables.Column(
  512. #verbose_name=_('Комиссия Сервиса'),
  513. attrs={
  514. 'th': {'scope': 'col'},
  515. "td": {"width": "15%"}}
  516. )
  517. edit = tables.LinkColumn(
  518. 'sharix_admin:service_category/edit/',
  519. verbose_name='',
  520. orderable=False,
  521. text="E",
  522. args=[tables.A('pk')],
  523. attrs={
  524. 'th': {'scope': 'col'},
  525. "td": {"class": "edit_col"}
  526. }
  527. )
  528. check = tables.BooleanColumn(
  529. verbose_name=_('Activity'),
  530. orderable=False,
  531. attrs={
  532. 'th': {'scope': 'col'},
  533. "td": {"width": "5%"}
  534. }
  535. )
  536. #TODO change to 'change status!'
  537. #deletee = tables.LinkColumn(
  538. # 'sharix_admin:service_category/delete/',
  539. # verbose_name='',
  540. # orderable=False,
  541. # text="D",
  542. # args=[tables.A('pk')],
  543. # attrs={
  544. # 'th': {'scope': 'col'},
  545. # "td": {"class": "delete_col"}
  546. # }
  547. #)
  548. class Meta:
  549. model = ServiceCategory
  550. attrs = {
  551. "class": "table table-layout-fixed text-start"
  552. }
  553. exclude = (
  554. 'requirements',
  555. 'price_type',
  556. 'status',
  557. 'ticket_status',
  558. 'id_metaservice',
  559. 'link_agreement',
  560. 'is_global',
  561. 'is_visible',
  562. 'codename',
  563. )
  564. def render_check(self, value, record):
  565. if record.status == '0':
  566. #if record.status == 'active':
  567. return format_html(
  568. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-service_category-id="{}">',
  569. record.id
  570. )
  571. #return format_html('<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-service_category-id="{}">')
  572. #return format_html('<input class="form-check-input status-toggle" disabled checked type="checkbox"')
  573. else:
  574. return format_html(
  575. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-service_category-id="{}">',
  576. record.id
  577. )
  578. #return format_html('<input class="form-check-input status-toggle" disabled type="checkbox"')
  579. # def render_delete(self, value, record):
  580. # return format_html('<a href="/service_category/delete" class="btn btn-outline-danger">_(Delete)</a>')
  581. # def render_name_operation(self, value, record):
  582. # return format_html("<a href='{}'>{}</a>", record.get_absolute_url(), value)
  583. #class ServiceTable(tables.Table):
  584. # id = tables.Column(
  585. # verbose_name=_('ID'),
  586. # attrs={
  587. # "td": {"width": "5%"}
  588. # }
  589. # )
  590. # service_category = tables.Column(
  591. # verbose_name=_('Description of the service'),
  592. # accessor='service_category.caption',
  593. # attrs={
  594. # 'th': {'scope': 'col'},
  595. # "td": {"width": "20%"}}
  596. # )
  597. # description = tables.Column(verbose_name='Название тарифа', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  598. # description = tables.Column(verbose_name='Описание строки тарифов', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  599. # price_type = tables.Column(verbose_name='Тип тарифа', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  600. # price_km = tables.Column(
  601. # verbose_name=_('Cost km.'),
  602. # attrs={
  603. # 'th': {'scope': 'col'},
  604. # "td": {"width": "20%"}
  605. # }
  606. # )
  607. # price_min = tables.Column(
  608. # verbose_name=_('Cost min.'),
  609. # attrs={
  610. # 'th': {'scope': 'col'},
  611. # "td": {"width": "20%"}}
  612. # )
  613. # price_amount = tables.Column(
  614. # verbose_name=_('Cost of service'),
  615. # attrs={
  616. # 'th': {'scope': 'col'},
  617. # "td": {"width": "20%"}
  618. # }
  619. # )
  620. #
  621. # class Meta:
  622. # model = Service
  623. # attrs = {
  624. # "class": "table table-layout-fixed"
  625. # }
  626. # exclude = (
  627. # 'resource',
  628. # 'requirements',
  629. # 'id_metaservice',
  630. # 'price_type',
  631. # 'ticket_status',
  632. # 'is_global',
  633. # 'is_visible'
  634. # )
  635. # def render_check(self, value, record):
  636. # if record.status == '0':
  637. # return format_html(
  638. # '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-service-id="{}">',
  639. # record.id
  640. # )
  641. # else:
  642. # return format_html(
  643. # '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-service-id="{}">',
  644. # record.id
  645. # )
  646. class UserInfoTable(tables.Table):
  647. id = tables.Column(
  648. verbose_name=_('ID'),
  649. attrs={
  650. "td": {"width": "5%"}
  651. }
  652. )
  653. class Meta:
  654. model = get_user_model()
  655. attrs = {
  656. "class": "table table-layout-fixed"
  657. }
  658. exclude = (
  659. 'password',
  660. 'phone_number',
  661. 'last_login',
  662. 'is_staff',
  663. 'is_superuser',
  664. 'date_joined'
  665. )
  666. class PermissionsTable(tables.Table):
  667. id = tables.Column(
  668. verbose_name=_('ID'),
  669. attrs={
  670. "td": {"width": "5%"}
  671. }
  672. )
  673. user = tables.Column(
  674. accessor='user.full_name',
  675. order_by=('user.first_name', 'user.last_name'),
  676. verbose_name=_('User'),
  677. attrs={
  678. "td": {"width": "15%"}
  679. }
  680. )
  681. id_permissions = tables.Column(
  682. verbose_name=_('Permission'),
  683. attrs={
  684. "td": {"width": "15%"}
  685. }
  686. )
  687. status = tables.Column(
  688. verbose_name=_('Status'),
  689. attrs={
  690. 'th': {'scope': 'col'},
  691. "td": {"width": "20%"}
  692. }
  693. )
  694. check = tables.BooleanColumn(
  695. verbose_name='',
  696. attrs={
  697. 'th': {'scope': 'col'},
  698. "td": {"width": "20%"}
  699. }
  700. )
  701. # paginate_by = 10
  702. class Meta:
  703. model = Permissions
  704. attrs = {
  705. "class": "table table-layout-fixed"
  706. }
  707. exclude = (
  708. 'check_date',
  709. 'expire_date',
  710. 'check_level',
  711. 'checked_by',
  712. 'ticket_status'
  713. )
  714. def render_check(self, value, record):
  715. if record.status == '0':
  716. return format_html(
  717. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-permissions-id="{}">',
  718. record.id
  719. )
  720. else:
  721. return format_html(
  722. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-permissions-id="{}">',
  723. record.id
  724. )
  725. class RelationshipTable(tables.Table):
  726. id = tables.Column(
  727. verbose_name=_('ID'),
  728. attrs={
  729. "td": {"width": "5%"}
  730. }
  731. )
  732. user_who = tables.Column(
  733. accessor='user_who.full_name',
  734. order_by=('user_who.first_name', 'user_who.last_name'),
  735. verbose_name=_('Initiator'),
  736. attrs={
  737. "td": {"width": "15%"}
  738. }
  739. )
  740. user_whom = tables.Column(
  741. accessor='user_whom.full_name',
  742. order_by=('user_whom.first_name', 'user_whom.last_name'),
  743. verbose_name=_('Goal'),
  744. attrs={
  745. "td": {"width": "15%"}
  746. }
  747. )
  748. neg_type = tables.Column(
  749. verbose_name=_('Neg Type'),
  750. attrs={
  751. 'th': {'scope': 'col'},
  752. "td": {"width": "20%"}
  753. }
  754. )
  755. status = tables.Column(
  756. verbose_name=_('Status'),
  757. attrs={
  758. 'th': {'scope': 'col'},
  759. "td": {"width": "20%"}
  760. }
  761. )
  762. check = tables.BooleanColumn(
  763. verbose_name='',
  764. attrs={
  765. 'th': {'scope': 'col'},
  766. "td": {"width": "20%"}
  767. }
  768. )
  769. paginate_by = 10
  770. class Meta:
  771. model = Relationship
  772. attrs = {
  773. "class": "table table-layout-fixed"
  774. }
  775. exclude = (
  776. 'ticket_status',
  777. )
  778. def render_check(self, value, record):
  779. if record.status == '0':
  780. return format_html(
  781. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-relationship-id="{}">',
  782. record.id
  783. )
  784. else:
  785. return format_html(
  786. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-relationship-id="{}">',
  787. record.id
  788. )