| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- import django_tables2 as tables
- from dbsynce.models import *
- from dbsynce.models import *
- from django.contrib.auth import get_user_model
- from django.utils.html import format_html
- from django.utils.translation import gettext_lazy as _
- from dbsynce.lib.dicts import *
- from sharix_admin.tables import ShariXTable
- class ProvidersLandingTable(ShariXTable):
- id = tables.Column(
- verbose_name=_('ID'),
- attrs={
- "td": {"width": "5%"}
- }
- )
- gap = tables.Column(
- #verbose_name=_('Status'),
- attrs={
- 'th': {'scope': 'col'},
- "td": {"width": "20%"}
- }
- )
- service_status = tables.Column(
- attrs={
- 'th': {'scope': 'col'},
- "td": {"width": "20%"}
- }
- )
- default_location = tables.Column(
- attrs={
- 'th': {'scope': 'col'},
- "td": {"width": "20%"}
- }
- )
- service = tables.LinkColumn(
- 'sharix_admin:service_tariff_detail',
- args=[tables.A('service.pk')],
- accessor='service.caption',
- verbose_name=_('Service'),
- attrs={'th': {'scope': 'col'}, "td": {"width": "20%"}}
- )
- resource = tables.LinkColumn(
- 'sharix_admin:resource_detail',
- args=[tables.A('resource.pk')],
- accessor='resource.resource_type',
- verbose_name=_('Resource'),
- attrs={
- 'th': {'scope': 'col'},
- "td": {"width": "20%"}
- }
- )
-
- class Meta:
- model = Provider
- attrs = {
- "class": "table table-layout-fixed"
- }
- exclude = (
- 'id_metaservice',
- 'requirements',
- 'status',
- 'location_type',
- 'default_location',
- 'is_global',
- 'is_visible',
- 'ticket_status',
- )
- class ServiceCategoryLandingTable(ShariXTable):
- caption = tables.LinkColumn(
- 'landing_service_detail',
- args=[tables.A('pk')],
- text=lambda record: record.caption,
- verbose_name=_('Название'),
- attrs={
- 'th': {'scope': 'col'},
- 'td': {'class': 'name_col'},
- }
- )
- price_min = tables.Column(
- verbose_name=_('Цена за минуту'),
- attrs={
- 'th': {'scope': 'col'},
- 'td': {'width': '18%'},
- }
- )
- price_amount = tables.Column(
- verbose_name=_('Фиксированная цена'),
- attrs={
- 'th': {'scope': 'col'},
- 'td': {'width': '18%'},
- }
- )
- price_km = tables.Column(
- verbose_name=_('Цена за км'),
- attrs={
- 'th': {'scope': 'col'},
- 'td': {'width': '18%'},
- }
- )
- def render_price_min(self, value):
- return value if value not in (None, '') else '—'
- def render_price_amount(self, value):
- return value if value not in (None, '') else '—'
- def render_price_km(self, value):
- return value if value not in (None, '') else '—'
- class Meta:
- model = Service
- attrs = {
- "class": "table table-layout-fixed text-start"
- }
- fields = (
- 'caption',
- 'price_min',
- 'price_amount',
- 'price_km',
- )
- class ServiceCategoryLandingTable(ShariXTable):
- caption = tables.LinkColumn(
- 'landing_service_detail',
- args=[tables.A('pk')],
- text=lambda record: record.caption,
- verbose_name=_('Название'),
- attrs={
- 'th': {'scope': 'col'},
- 'td': {'class': 'name_col'},
- }
- )
- price_min = tables.Column(
- verbose_name=_('Цена за минуту'),
- attrs={
- 'th': {'scope': 'col'},
- 'td': {'width': '18%'},
- }
- )
- price_amount = tables.Column(
- verbose_name=_('Фиксированная цена'),
- attrs={
- 'th': {'scope': 'col'},
- 'td': {'width': '18%'},
- }
- )
- price_km = tables.Column(
- verbose_name=_('Цена за км'),
- attrs={
- 'th': {'scope': 'col'},
- 'td': {'width': '18%'},
- }
- )
- def render_price_min(self, value):
- return value if value not in (None, '') else '—'
- def render_price_amount(self, value):
- return value if value not in (None, '') else '—'
- def render_price_km(self, value):
- return value if value not in (None, '') else '—'
- class Meta:
- model = Service
- attrs = {
- "class": "table table-layout-fixed text-start"
- }
- fields = (
- 'caption',
- 'price_min',
- 'price_amount',
- 'price_km',
- )
|