tables.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  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 == 'active':
  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 == 'active':
  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 == 'active':
  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 == 'active':
  461. return format_html('<input class="form-check-input status-toggle" disabled checked type="checkbox"')
  462. else:
  463. return format_html('<input class="form-check-input status-toggle" disabled type="checkbox"')
  464. class ServiceCategoriesTable(tables.Table):
  465. id = tables.LinkColumn(
  466. 'sharix_admin:service_category_detail',
  467. args=[tables.A('pk')],
  468. attrs={"td": {"width": "50px"}}
  469. )
  470. caption = tables.LinkColumn(
  471. 'sharix_admin:service_category_detail',
  472. verbose_name='Услуга',
  473. orderable=False,
  474. text=lambda record: record.caption,
  475. args=[tables.A('pk')],
  476. attrs={
  477. "a": {"style": "pointer-events: none;"},
  478. 'th': {'scope': 'col'},
  479. "td": {"class": "name_col"}
  480. }
  481. )
  482. #codename = tables.LinkColumn(
  483. # 'sharix_admin:service_category/edit/',
  484. # verbose_name='Тех.название',
  485. # orderable=False,
  486. # text=lambda record: record.codename,
  487. # args=[tables.A('pk')],
  488. # attrs={
  489. # "a": {"style": "pointer-events: none;"},
  490. # 'th': {'scope': 'col'},
  491. # "td": {"class": "name_col"}
  492. # }
  493. #)
  494. description = tables.Column(
  495. orderable=False,
  496. #verbose_name='Описание',
  497. #text=lambda record: record.description,
  498. #args=[tables.A('pk')],
  499. attrs={
  500. "a": {"style": "pointer-events: none;"},
  501. 'th': {'scope': 'col'},
  502. "td": {"class": "description_col"}
  503. }
  504. )
  505. metaservice_comission = tables.Column(
  506. #verbose_name=_('Комиссия Сервиса'),
  507. attrs={
  508. 'th': {'scope': 'col'},
  509. "td": {"width": "15%"}}
  510. )
  511. edit = tables.LinkColumn(
  512. 'sharix_admin:service_category/edit/',
  513. verbose_name='',
  514. orderable=False,
  515. text="E",
  516. args=[tables.A('pk')],
  517. attrs={
  518. 'th': {'scope': 'col'},
  519. "td": {"class": "edit_col"}
  520. }
  521. )
  522. check = tables.BooleanColumn(
  523. verbose_name=_('Activity'),
  524. orderable=False,
  525. attrs={
  526. 'th': {'scope': 'col'},
  527. "td": {"width": "5%"}
  528. }
  529. )
  530. #TODO change to 'change status!'
  531. #deletee = tables.LinkColumn(
  532. # 'sharix_admin:service_category/delete/',
  533. # verbose_name='',
  534. # orderable=False,
  535. # text="D",
  536. # args=[tables.A('pk')],
  537. # attrs={
  538. # 'th': {'scope': 'col'},
  539. # "td": {"class": "delete_col"}
  540. # }
  541. #)
  542. class Meta:
  543. model = ServiceCategory
  544. attrs = {
  545. "class": "table table-layout-fixed text-start"
  546. }
  547. exclude = (
  548. 'requirements',
  549. 'price_type',
  550. 'status',
  551. 'ticket_status',
  552. 'id_metaservice',
  553. 'link_agreement',
  554. 'is_global',
  555. 'is_visible',
  556. 'codename',
  557. )
  558. def render_check(self, value, record):
  559. if record.status == '0':
  560. #if record.status == 'active':
  561. return format_html(
  562. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-service_category-id="{}">',
  563. record.id
  564. )
  565. #return format_html('<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-service_category-id="{}">')
  566. #return format_html('<input class="form-check-input status-toggle" disabled checked type="checkbox"')
  567. else:
  568. return format_html(
  569. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-service_category-id="{}">',
  570. record.id
  571. )
  572. #return format_html('<input class="form-check-input status-toggle" disabled type="checkbox"')
  573. # def render_delete(self, value, record):
  574. # return format_html('<a href="/service_category/delete" class="btn btn-outline-danger">_(Delete)</a>')
  575. # def render_name_operation(self, value, record):
  576. # return format_html("<a href='{}'>{}</a>", record.get_absolute_url(), value)
  577. class ServiceTable(tables.Table):
  578. id = tables.Column(
  579. verbose_name=_('ID'),
  580. attrs={
  581. "td": {"width": "5%"}
  582. }
  583. )
  584. service_category = tables.Column(
  585. verbose_name=_('Description of the service'),
  586. accessor='service_category.caption',
  587. attrs={
  588. 'th': {'scope': 'col'},
  589. "td": {"width": "20%"}}
  590. )
  591. # description = tables.Column(verbose_name='Название тарифа', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  592. # description = tables.Column(verbose_name='Описание строки тарифов', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  593. # price_type = tables.Column(verbose_name='Тип тарифа', attrs={'th':{'scope':'col'}, "td":{"width":"20%"}})
  594. price_km = tables.Column(
  595. verbose_name=_('Cost km.'),
  596. attrs={
  597. 'th': {'scope': 'col'},
  598. "td": {"width": "20%"}
  599. }
  600. )
  601. price_min = tables.Column(
  602. verbose_name=_('Cost min.'),
  603. attrs={
  604. 'th': {'scope': 'col'},
  605. "td": {"width": "20%"}}
  606. )
  607. price_amount = tables.Column(
  608. verbose_name=_('Cost of service'),
  609. attrs={
  610. 'th': {'scope': 'col'},
  611. "td": {"width": "20%"}
  612. }
  613. )
  614. class Meta:
  615. model = Service
  616. attrs = {
  617. "class": "table table-layout-fixed"
  618. }
  619. exclude = (
  620. 'resource',
  621. 'requirements',
  622. 'id_metaservice',
  623. 'price_type',
  624. 'ticket_status',
  625. 'is_global',
  626. 'is_visible'
  627. )
  628. def render_check(self, value, record):
  629. if record.status == 'active':
  630. return format_html(
  631. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-service-id="{}">',
  632. record.id
  633. )
  634. else:
  635. return format_html(
  636. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-service-id="{}">',
  637. record.id
  638. )
  639. class UserInfoTable(tables.Table):
  640. id = tables.Column(
  641. verbose_name=_('ID'),
  642. attrs={
  643. "td": {"width": "5%"}
  644. }
  645. )
  646. class Meta:
  647. model = get_user_model()
  648. attrs = {
  649. "class": "table table-layout-fixed"
  650. }
  651. exclude = (
  652. 'password',
  653. 'phone_number',
  654. 'last_login',
  655. 'is_staff',
  656. 'is_superuser',
  657. 'date_joined'
  658. )
  659. class PermissionsTable(tables.Table):
  660. id = tables.Column(
  661. verbose_name=_('ID'),
  662. attrs={
  663. "td": {"width": "5%"}
  664. }
  665. )
  666. user = tables.Column(
  667. accessor='user.full_name',
  668. order_by=('user.first_name', 'user.last_name'),
  669. verbose_name=_('User'),
  670. attrs={
  671. "td": {"width": "15%"}
  672. }
  673. )
  674. id_permissions = tables.Column(
  675. verbose_name=_('Permission'),
  676. attrs={
  677. "td": {"width": "15%"}
  678. }
  679. )
  680. status = tables.Column(
  681. verbose_name=_('Status'),
  682. attrs={
  683. 'th': {'scope': 'col'},
  684. "td": {"width": "20%"}
  685. }
  686. )
  687. check = tables.BooleanColumn(
  688. verbose_name='',
  689. attrs={
  690. 'th': {'scope': 'col'},
  691. "td": {"width": "20%"}
  692. }
  693. )
  694. # paginate_by = 10
  695. class Meta:
  696. model = Permissions
  697. attrs = {
  698. "class": "table table-layout-fixed"
  699. }
  700. exclude = (
  701. 'check_date',
  702. 'expire_date',
  703. 'check_level',
  704. 'checked_by',
  705. 'ticket_status'
  706. )
  707. def render_check(self, value, record):
  708. if record.status == 'active':
  709. return format_html(
  710. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-resource-id="{}">',
  711. record.id
  712. )
  713. else:
  714. return format_html(
  715. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-resource-id="{}">',
  716. record.id
  717. )
  718. class RelationshipTable(tables.Table):
  719. id = tables.Column(
  720. verbose_name=_('ID'),
  721. attrs={
  722. "td": {"width": "5%"}
  723. }
  724. )
  725. user_who = tables.Column(
  726. accessor='user_who.full_name',
  727. order_by=('user_who.first_name', 'user_who.last_name'),
  728. verbose_name=_('Initiator'),
  729. attrs={
  730. "td": {"width": "15%"}
  731. }
  732. )
  733. user_whom = tables.Column(
  734. accessor='user_whom.full_name',
  735. order_by=('user_whom.first_name', 'user_whom.last_name'),
  736. verbose_name=_('Goal'),
  737. attrs={
  738. "td": {"width": "15%"}
  739. }
  740. )
  741. neg_type = tables.Column(
  742. verbose_name=_('Neg Type'),
  743. attrs={
  744. 'th': {'scope': 'col'},
  745. "td": {"width": "20%"}
  746. }
  747. )
  748. status = tables.Column(
  749. verbose_name=_('Status'),
  750. attrs={
  751. 'th': {'scope': 'col'},
  752. "td": {"width": "20%"}
  753. }
  754. )
  755. check = tables.BooleanColumn(
  756. verbose_name='',
  757. attrs={
  758. 'th': {'scope': 'col'},
  759. "td": {"width": "20%"}
  760. }
  761. )
  762. paginate_by = 10
  763. class Meta:
  764. model = Relationship
  765. attrs = {
  766. "class": "table table-layout-fixed"
  767. }
  768. exclude = (
  769. 'ticket_status',
  770. )
  771. def render_check(self, value, record):
  772. if record.status == 'active':
  773. return format_html(
  774. '<input class="form-check-input status-toggle" checked type="checkbox" id="flexCheckDefault" data-provider-id="{}">',
  775. record.id
  776. )
  777. else:
  778. return format_html(
  779. '<input class="form-check-input status-toggle" type="checkbox" id="flexCheckDefault" data-provider-id="{}">',
  780. record.id
  781. )