Exemple #1
0
class BlockTable(tables.Table):

    height = LinkColumn(verbose_name='Height', orderable=True)
    time = DateTimeColumn(verbose_name='Time (UTC)',
                          format="Y-m-d H:i:s",
                          orderable=True)
    miner = LinkColumn(verbose_name=settings.MEX_MINER)
    txcount = Column(verbose_name='TXs', orderable=True)
    size = Column(orderable=True)

    class Meta:
        model = Block
        fields = (
            'height',
            'time',
            'miner',
            'txcount',
            'size',
        )
        order_by = '-height',
        attrs = {'class': 'table table-sm table-striped table-hover'}
        orderable = False

    def render_height(self, record=None):
        link = reverse('block-detail', args=[str(record.hash)])
        return mark_safe(
            '<a href="{}" class="badge badge-info"><i class="fas fa-cube"></i>  {}</a>'
            .format(link, record.height))

    def render_miner(self, record=None):
        link = reverse('address-detail', args=[str(record.miner)])
        return mark_safe('<a href="{}">{}</a>'.format(link, record.miner))
Exemple #2
0
class BlockTable(tables.Table):

    height = LinkColumn(verbose_name="Height", orderable=True)
    time = DateTimeColumn(verbose_name="Time (UTC)",
                          format="Y-m-d H:i:s",
                          orderable=True)
    miner = LinkColumn(verbose_name=settings.MEX_MINER)
    txcount = Column(verbose_name="TXs", orderable=True)
    size = Column(orderable=True)

    class Meta:
        model = Block
        fields = ("height", "time", "miner", "txcount", "size")
        order_by = ("-height", )
        attrs = {"class": "table table-sm table-striped table-hover"}
        orderable = False

    def render_height(self, record=None):
        link = reverse("block-detail", args=[str(record.hash)])
        return mark_safe(
            '<a href="{}" class="badge badge-info"><i class="fas fa-cube"></i>  {}</a>'
            .format(link, record.height))

    def render_miner(self, record=None):
        link = reverse("address-detail", args=[str(record.miner)])
        return mark_safe('<a href="{}">{}</a>'.format(link, record.miner))
Exemple #3
0
class VMTemplateTable(BaseTable):

    template_name = LinkColumn("template-detail",
                               args=[A("cluster.slug"),
                                     A("template_name")],
                               verbose_name="name")
    description = Column()
    cluster = LinkColumn("cluster-detail",
                         args=[A("cluster.slug")],
                         accessor="cluster.slug",
                         verbose_name="cluster")
    os = Column(verbose_name='OS')
    memory = Column(verbose_name='RAM')
    disk_space = Column()
    vcpus = Column(verbose_name='vCPUs')

    class Meta:
        sequence = ("template_name", "description", "cluster", "os", "memory",
                    "disk_space", "vcpus")
        order_by = ("template_name")
        empty_text = "No Templates"

    def render_os(self, value):
        return render_os(value)

    def render_memory(self, value):
        return render_storage(value)

    def render_disk_space(self, value):
        return render_storage(value)
class RentalPropertyTable(tables.Table):
    url = URLColumn()
    promote = LinkColumn('main:promote',
                         text='Save',
                         args=[A('pk')],
                         attrs={'a': {
                             'class': 'btn'
                         }})
    delete = LinkColumn('main:destroy',
                        text='Delete',
                        args=[A('pk')],
                        attrs={'a': {
                            'class': 'btn'
                        }})
    block = LinkColumn('main:block',
                       text='Move to Block',
                       args=[A('pk')],
                       attrs={'a': {
                           'class': 'btn'
                       }})

    class Meta:
        model = RentalProperty
        template_name = "django_tables2/bootstrap.html"
        fields = (
            "name",
            "url",
            "promote",
            "delete",
            "block",
        )
Exemple #5
0
class FollowedTable(Table):
    picture = TemplateColumn(template_name="users/_picture_column.html",
                             orderable=False)
    handle = LinkColumn(
        "users:profile-detail",
        args=[Accessor("guid")],
        text=lambda record: record.handle,
        attrs={
            "th": {
                "class": "hidden-md-down"
            },
            "td": {
                "class": "hidden-md-down"
            }
        },
    )
    name = LinkColumn("users:profile-detail",
                      args=[Accessor("guid")],
                      text=lambda record: record.name)
    actions = TemplateColumn(
        template_name="users/_actions_column.html",
        orderable=False,
        attrs={"td": {
            "class": "align-middle"
        }},
    )

    class Meta:
        model = Profile
        fields = tuple()
        order_by = ("name", "handle")
        template = "users/_followed_table.html"
        sequence = ("picture", "name", "handle")
Exemple #6
0
class ClusterTable(BaseTable):

    cluster = LinkColumn("cluster-detail",
                         args=[A("slug")],
                         accessor="slug",
                         verbose_name='cluster')
    description = Column()
    version = Column(accessor="info.software_version",
                     orderable=False,
                     default="unknown")
    hypervisor = Column(accessor="info.default_hypervisor",
                        orderable=False,
                        default="unknown")
    master_node = LinkColumn("node-detail",
                             kwargs={
                                 "cluster_slug": A("slug"),
                                 "host": A("info.master")
                             },
                             accessor="info.master",
                             orderable=False,
                             default="unknown")
    nodes = Column(accessor="nodes.count", orderable=False)
    vms = Column(accessor="virtual_machines.count",
                 verbose_name='VMs',
                 orderable=False)

    class Meta:
        empty_text = "No Clusters"
        sequence = ("cluster", "description", "version", "hypervisor",
                    "master_node", "nodes", "vms")
        order_by = ("cluster")

    def render_hypervisor(self, value):
        return hv_prettify(value)
Exemple #7
0
class SupportTable(SquestTable):
    state = TemplateColumn(template_name='custom_columns/support_state.html')
    title = LinkColumn("service_catalog:instance_support_details", args=[A("instance__id"), A("id")])
    instance__name = LinkColumn("service_catalog:instance_details", args=[A("instance__id")],
                                verbose_name="Instance")

    class Meta:
        model = Support
        attrs = {"id": "support_table", "class": "table squest-pagination-tables"}
        fields = ("title", "instance__name", "opened_by", "date_opened", "state")
Exemple #8
0
class RollingAdTable(DashboardTable):
    title = LinkColumn('dashboard:ad-rolling_ad-update', args=[A('pk')])
    image = TemplateColumn(
        verbose_name=_('Image'),
        template_name='dashboard/ad/rolling_ad_row_image.html',
        orderable=False)
    link_url = URLColumn(verbose_name=_(u'链接地址'),
                         accessor='link_url',
                         orderable=False)
    description = TemplateColumn(
        verbose_name=_("Description"),
        accessor='description',
        orderable=False,
        template_code='{{ record.description|default:""|striptags'
        '|cut:"&nbsp;"|truncatewords:6 }}')
    order_num = Column(verbose_name=_(u'顺序'),
                       accessor='order_num',
                       orderable=True)
    valid = Column(verbose_name=_(u'开启'), accessor='valid', orderable=False)
    actions = TemplateColumn(
        verbose_name=_('Actions'),
        template_name=
        'dashboard/ad/rolling_ad_row_actions.html',  #'dashboard/ad/rolling_ad_row_actions.html',
        orderable=False)

    icon = "sitemap"

    class Meta(DashboardTable.Meta):
        model = RollingAd
        fields = ('title', 'position', 'image', 'link_url', 'order_num',
                  'description', 'valid')
        sequence = ('title', 'position', 'image', 'link_url', 'order_num',
                    'description', 'valid', 'actions')
        order_by = '-order_num'
Exemple #9
0
class ProductTable(Table):
    title = TemplateColumn(
        template_name='dashboard/catalogue/product_row_title.html',
        order_by='title',
        accessor=A('get_title'))
    image = TemplateColumn(
        template_name='dashboard/catalogue/product_row_image.html',
        orderable=False)
    product_class = Column(verbose_name=_("Type"),
                           accessor=A('get_product_class.name'),
                           order_by=('product_class__name'))
    parent = LinkColumn('dashboard:catalogue-product',
                        verbose_name=_("Parent"),
                        args=[A('parent.pk')],
                        accessor=A('parent.title'))
    children = Column(accessor=A('children.count'), orderable=False)
    stock_records = Column(accessor=A('stockrecords.count'), orderable=False)
    actions = TemplateColumn(
        template_name='dashboard/catalogue/product_row_actions.html',
        orderable=False)

    class Meta(DashboardTable.Meta):
        model = Product
        fields = ('upc', 'date_created')
        sequence = ('title', 'upc', 'image', 'product_class', 'parent',
                    'children', 'stock_records', '...', 'date_created',
                    'actions')
        order_by = '-date_created'
Exemple #10
0
class LogEntryTable(tables.Table):
    created = LinkColumn(None)

    class Meta:
        model = LogEntry
        template = 'django_tables2/bootstrap-responsive.html'
        fields = ['created', 'event_label', 'session_key', ]
Exemple #11
0
class TransactionTable(DashboardTable):
    order_number = LinkColumn('dashboard:order-detail',
                              args=[A('order_number')])

    amount = TemplateColumn(
        verbose_name=_('Amount'),
        template_name='dashboard/banktransfer/banktransfer_row_amount.html')

    date_confirmed = TemplateColumn(
        verbose_name=_('Date Confirmed'),
        template_name=
        'dashboard/banktransfer/banktransfer_row_date_confirmed.html',
        orderable=False)

    actions = TemplateColumn(
        verbose_name=_('Actions'),
        template_name='dashboard/banktransfer/banktransfer_row_actions.html',
        orderable=False)

    icon = "sitemap"

    class Meta(DashboardTable.Meta):
        model = BankTransferTransaction
        fields = ('order_number', 'bank_account', 'amount', 'confirmed',
                  'date_confirmed')
        sequence = ('order_number', 'bank_account', 'amount', 'confirmed',
                    'date_confirmed')
        order_by = '-date_created'
class ConfirmationTable(DashboardTable):
    order_number = LinkColumn('dashboard:order-detail',
                              args=[A('order_number')])

    filename = TemplateColumn(
        verbose_name=_('Proof Of Payment'),
        template_name=
        'dashboard/confirmation/confirmation_row_proof_payment.html',
        orderable=False)

    amount = TemplateColumn(
        verbose_name=_('Amount'),
        template_name='dashboard/confirmation/confirmation_row_amount.html')

    actions = TemplateColumn(
        verbose_name=_('Actions'),
        template_name='dashboard/confirmation/confirmation_row_actions.html',
        orderable=False)

    icon = "sitemap"

    class Meta(DashboardTable.Meta):
        model = ConfirmationPayment
        fields = ('order_number', 'transfer_date', 'destination_bank',
                  'amount', 'status')
        sequence = ('order_number', 'transfer_date', 'destination_bank',
                    'amount', 'filename', 'status', 'actions')
        order_by = '-date_created'
Exemple #13
0
class OrderTable(Table):
    order_id = LinkColumn("order_detail", args=[Accessor("pk")])

    class Meta:
        model = Order
        # fields = ("order_id", "order_date", "customer", "total_sales", "net_sales", "completed")
        exclude = ("last_updated", "created_date")
Exemple #14
0
class BaseVMTable(BaseTable):

    status = TemplateColumn(
        template_name="ganeti/virtual_machine/vmfield_status.html",
        attrs={"th": {
            "class": "status_indicator"
        }})
    cluster = LinkColumn("cluster-detail",
                         args=[A("cluster.slug")],
                         accessor="cluster.slug",
                         verbose_name='cluster')
    hostname = LinkColumn(
        "instance-detail",
        kwargs={
            "cluster_slug": A("cluster.slug"),
            "instance": A("hostname")
        },
        verbose_name='name',
    )
    owner = Column()
    node = Column(verbose_name='node', accessor="primary_node")
    operating_system = Column(verbose_name='OS')
    ram = Column(verbose_name='RAM')
    disk_size = Column(verbose_name='disk space')
    virtual_cpus = Column(verbose_name='vCPUs')

    class Meta:
        sequence = ("status", "hostname", "cluster", "...")
        order_by = ("hostname")
        empty_text = "No Virtual Machines"

    def render_disk_size(self, value):
        return render_storage(value)

    def render_ram(self, value):
        return render_storage(value)

    def render_operating_system(self, value):
        return render_os(value)

    def render_node(self, value):
        return abbreviate_fqdn(value)

    def render_owner(self, value):
        url = value.get_absolute_url()
        url_str = '<a href="{0}">{1}</a>'
        return mark_safe(url_str.format(url, value))
Exemple #15
0
class TransactionTable(tables.Table):

    block = LinkColumn(verbose_name="Block")
    hash = LinkColumn(verbose_name="TX Hash")
    idx = Column(verbose_name="IDX")

    class Meta:
        model = Transaction
        fields = ("block", "hash", "idx")
        attrs = {"class": "table table-sm table-striped table-hover"}
        order_by = ("-block", "idx")

    def render_block(self, record=None):
        link = reverse("block-detail", args=[str(record.block.hash)])
        return mark_safe(
            '<a href="{}" class="badge badge-info"><i class="fas fa-cube"></i>  {}</a>'
            .format(link, record.block.height))
Exemple #16
0
class PointTable(Table):
    description = LinkColumn('core:point_detail',
                             args=[A('entity_id')],
                             verbose_name='Data Point')
    current_value = Column(verbose_name='Latest Value')

    class Meta:
        order_by = 'description'
Exemple #17
0
class RecsReviewTable(Table):
    hh_user = LinkColumn("main:recsreviewview", args=[A('pk')])
    is_reviewed = BooleanColumn()

    class Meta:
        model = RecsReview
        order_by = ['hh_user']
        fields = ('hh_user', 'recs_type', 'is_reviewed')
        attrs = {'class': 'paleblue'}
Exemple #18
0
class StreamTable(tables.Table):

    name = LinkColumn(verbose_name="Stream")
    description = Column(verbose_name="Description", orderable=False)

    class Meta:
        model = Stream
        fields = ("name", "description", "creators", "items", "keys")
        attrs = {"class": "table table-sm table-striped table-hover"}
Exemple #19
0
class ModelTable(Table):
    entity_id = LinkColumn('core:model_detail',
                           args=[A('entity_id')],
                           text=lambda record: record.object_id,
                           verbose_name='Model ID')
    description = Column()

    class Meta:
        order_by = 'entity_id'
Exemple #20
0
class BrandTable(DashboardTable):
    name = LinkColumn('dashboard:catalogue-brand-edit', args=[A('pk')])
    slug = Column(verbose_name=_('Brand slug'))
    actions = TemplateColumn(
        template_name='dashboard/catalogue/brand_row_actions.html',
        orderable=False)

    class Meta(DashboardTable.Meta):
        model = Brand
        fields = ('name', 'slug')
Exemple #21
0
class CarouselItemTable(DashboardTable):
    title = LinkColumn('dashboard:carousel-item-edit', args=[A('pk')])
    description = Column(verbose_name=_('Brand description'))
    actions = TemplateColumn(
        template_name='dashboard/catalogue/carousel_row_actions.html',
        orderable=False)

    class Meta(DashboardTable.Meta):
        model = CarouselItem
        fields = ('title', 'description')
Exemple #22
0
class BookingTable(tables.Table):
    # https://stackoverflow.com/questions/33184108/how-to-change-display-text-in-django-tables-2-link-column
    # http://django-tables2.readthedocs.io/en/latest/pages/api-reference.html#linkcolumn
    booking_id = LinkColumn('booking_edit', text=lambda record: record.id, args=[A('pk')], attrs={'a': {'target': '_blank'}})

    class Meta:
        model = Booking
        # fields to display in table
        fields = ('property', 'state', 'from_date', 'to_date')
        attrs = {"class": "paleblue table table-striped table-hover table-bordered"}
        sequence = ('booking_id', '...',)
Exemple #23
0
class ManageNewsTable(GetRequestTableKwargs, tables.Table):
    title = LinkColumn('manager:news', args=[A('pk')])

    class Meta:
        model = News
        attrs = {"class": "table table-striped table-hover"}
        fields = ("id", "title", "language", 'competition', 'published_on',)
        per_page = 100
        template = "bootstrap/table.html"
        empty_text = _("There are no records")
        order_by = ['-published_on', ]
Exemple #24
0
class TagTable(Table):
    tag = LinkColumn('core:tag_detail', args=[A('tag')])

    class Meta:
        order_by = 'tag'
        model = Tag
        fields = (
            'tag',
            'kind',
            'description',
        )
Exemple #25
0
class CategoryTable(Table):
    name = LinkColumn('dashboard:catalogue-category-update', args=[A('pk')])
    description = TemplateColumn(
        template_code='{{ record.description|default:""|striptags'
        '|cut:"&nbsp;"|truncatewords:6 }}')
    # mark_safe is needed because of
    # https://github.com/bradleyayers/django-tables2/issues/187
    num_children = LinkColumn('dashboard:catalogue-category-detail-list',
                              args=[A('pk')],
                              verbose_name=mark_safe(
                                  _('Number of child categories')),
                              accessor='get_num_children',
                              orderable=False)
    actions = TemplateColumn(
        template_name='dashboard/catalogue/category_row_actions.html',
        orderable=False)

    class Meta(DashboardTable.Meta):
        model = Category
        fields = ('name', 'description')
Exemple #26
0
class DocTable(SquestTable):
    actions = TemplateColumn(template_name='custom_columns/doc_actions.html',
                             orderable=False)
    services = TemplateColumn(template_name='custom_columns/doc_services.html',
                              verbose_name="Linked services")
    title = LinkColumn("service_catalog:doc_show", args=[A("id")])

    class Meta:
        model = Doc
        attrs = {"id": "doc_table", "class": "table squest-pagination-tables"}
        fields = ("title", "services", "actions")
class ConfigReplaceTable(BaseTable):
    """Table to display Compliance Rules."""

    pk = ToggleColumn()
    name = LinkColumn("plugins:nautobot_golden_config:configreplace", args=[A("pk")])

    class Meta(BaseTable.Meta):
        """Table to display Compliance Rules Meta Data."""

        model = models.ConfigReplace
        fields = ("pk", "name", "platform", "description", "regex", "replace")
        default_columns = ("pk", "name", "platform", "description", "regex", "replace")
class ComplianceFeatureTable(BaseTable):
    """Table to display Compliance Features."""

    pk = ToggleColumn()
    name = LinkColumn("plugins:nautobot_golden_config:compliancefeature", args=[A("pk")])

    class Meta(BaseTable.Meta):
        """Table to display Compliance Features Meta Data."""

        model = models.ComplianceFeature
        fields = ("pk", "name", "slug", "description")
        default_columns = ("pk", "name", "slug", "description")
Exemple #29
0
class TeamTable(tables.Table):
    name = LinkColumn("profiles:team_details", args=[A("id")])
    actions = TemplateColumn(template_name='custom_columns/team_actions.html',
                             orderable=False)

    class Meta:
        model = Team
        attrs = {
            "id": "team_table",
            "class": "table squest-pagination-tables "
        }
        fields = ("name", "actions")
Exemple #30
0
class JobTemplateTable(SquestTable):
    is_compliant = TemplateColumn(template_name='custom_columns/job_template_compliant.html',
                                  verbose_name="Squest compliant")
    actions = TemplateColumn(template_name='custom_columns/job_template_actions.html', orderable=False)
    name = LinkColumn("service_catalog:job_template_details", args=[A("tower_server__id"), A("id")],
                      attrs={"td": {"class": "job_template_name"}})

    class Meta:
        row_attrs = {"id": lambda record: f'job_template_{record.id}'}
        model = JobTemplate
        attrs = {"id": "job_template_table", "class": "table squest-pagination-tables"}
        fields = ("name", "is_compliant", "actions")