Example #1
0
class ResultsTable(tables.Table):
    challenger = tables.LinkColumn('team', args=[A('challenger')])
    challenged = tables.LinkColumn('team', args=[A('challenged')])
    g1_results = tables.URLColumn(orderable=False, )
    g2_results = tables.URLColumn(orderable=False, )
    winner = tables.LinkColumn(
        'team',
        args=[A('winner')],
        verbose_name="Winner",
    )

    class Meta:
        model = Challenge
        exclude = ('id', 'approved', 'g1_submitted', 'g2_submitted',
                   'submitted_by', 'loser')
        attrs = {'class': 'table current'}
        row_attrs = {'id': lambda record: 'P' + str(record.played)}

    def render_g1_results(self, value):
        if not self.data.data[0].submitted_by:
            return format_html(
                '<a target="_blank" href="https://tagpro.eu/?match={}" disabled/>#{}',
                value, value)
        else:
            return "submitted"

    def render_g2_results(self, value):
        if not self.data.data[0].submitted_by:
            return format_html(
                '<a target="_blank" href="https://tagpro.eu/?match={}" />#{}',
                value, value)
        else:
            return "submitted"
Example #2
0
class LeagueTable(tables.Table):
    website = tables.URLColumn()
    hfea_link = tables.URLColumn()
    live_births_per_cycle = PercentageColumn()
    live_births_per_icsi_cycle = PercentageColumn()

    class Meta:
        model = hfeascrape.models.Unit
        orderable = True
        exclude = ('id', 'hfea_code')
Example #3
0
def define_table(columns, typeTable):
    """
    :param columns: Array with names of columns to show
    :return: a class of type TableResults
    """

    attrs = dict((c, tables.Column()) for c in columns if c != "url")

    attrs2 = dict((c, tables.URLColumn()) for c in columns if c == "url")
    attrs.update(attrs2)
    if typeTable == "TableResult":
        attrs['Meta'] = type(
            'Meta', (),
            dict(attrs={
                'class':
                'table table-striped table-bordered table-hover dataTable no-footer',
                "id": lambda: "table_%d" % next(counter)
            },
                 ordenable=False,
                 empty_text="Results not found!",
                 order_by=("name", )))
    else:
        attrs['Meta'] = type(
            'Meta', (),
            dict(attrs={
                'class': 'table table-striped',
                "id": "notformattable"
            },
                 ordenable=False,
                 empty_text="Results not found!",
                 order_by=("name", )))

    klass = type('TableResult', (tables.Table, ), attrs)
    return klass
Example #4
0
class AccessionTable(tables.Table):
    """
    Table that is displayed on the accession list view
    """
    id = tables.LinkColumn("accession_detail",
                           args=[A('id')],
                           text=lambda record: record.pk,
                           verbose_name="ID",
                           order_by="pk")
    name = tables.Column(accessor="name", verbose_name="Name", order_by="name")
    country = tables.Column(accessor="country",
                            verbose_name="Country",
                            order_by="country")
    sitename = tables.Column(accessor="sitename",
                             verbose_name="Sitename",
                             order_by="sitename")
    collector = tables.Column(accessor="collector",
                              verbose_name="Collector",
                              order_by="collector")
    longitude = tables.Column(accessor="longitude",
                              verbose_name="Longitude",
                              order_by="longitude")
    latitude = tables.Column(accessor="latitude",
                             verbose_name="Latitude",
                             order_by="latitude")
    cs_number = tables.URLColumn({"target": "_blank"},
                                 lambda record: record.cs_number,
                                 accessor="cs_number_url",
                                 verbose_name="CS Number",
                                 order_by="cs_number")
    number_of_phenotypes = tables.Column(accessor="count_phenotypes",
                                         verbose_name='# Phenotypes')

    class Meta:
        attrs = {"class": "striped"}
Example #5
0
class ResourceTable(tables.Table):
    link = tables.URLColumn()
    file = tables.URLColumn()
    id = ModifyColumn('Modify')
    title = ClickableColumn()

    class Meta:
        model = Resource
        exclude = ('user', )
        orderable = True
        sequence = ('date', '...', 'id')

    def render_file(self, value):
        return mark_safe('<a href="' + value + '">View</a>')

    def render_link(self, value):
        return mark_safe('<a href="' + value + '" target="_blank">View</a>')
class IXAPITable(BaseTable):
    name = tables.Column(linkify=True)
    url = tables.URLColumn()
    actions = ButtonsColumn(IXAPI)

    class Meta(BaseTable.Meta):
        model = IXAPI
        fields = ("name", "url", "api_key", "actions")
        default_columns = ("name", "url", "api_key", "actions")
Example #7
0
class FATable(tables.Table):
    tagpro_profile = tables.URLColumn(
        attrs={'a': {
            'target': '_blank'
        }},
        orderable=False,
    )
    reddit_info = tables.URLColumn(
        attrs={'a': {
            'target': '_blank'
        }},
        orderable=False,
    )
    tagpro_stats = tables.URLColumn(
        verbose_name="TagPro Stats",
        attrs={'a': {
            'target': '_blank'
        }},
        orderable=False,
    )
    additional_notes = tables.Column(
        verbose_name="Additional Notes",
        orderable=False,
    )

    class Meta:
        model = FreeAgent
        exclude = ('id', 'user')
        attrs = {'class': 'table current'}

    def render_tagpro_profile(self, value):
        return format_html(
            '<a target="_blank" href="{}" style="color:#2b2b2b;" />Tagpro',
            value, value)

    def render_reddit_info(self, value):
        return format_html(
            '<a target="_blank" href="{}" style="color:#ff4500;" />Reddit',
            value, value)

    def render_tagpro_stats(self, value):
        return format_html(
            '<a target="_blank" href="{}" style="color:#428bca;" />Stats',
            value, value)
Example #8
0
class DemosTable(tables.Table):
    path = tables.URLColumn()
    description = HtmlColumn()

    class Meta:
        model = Demos
        fields = {'name', 'description', 'path'}
        sequence = ('name', 'description', 'path')
        template = 'django_tables2/bootstrap.html'
        attrs = {'class': 'table table-bordered table-striped table-hover'}
Example #9
0
    class Meta:
        model = Produto
        attrs = attrs = {"class": "paleblue"}
        sequence = ("title", "description", "price")
        exclude = ("id", )
        www = tables.URLColumn()


# table = ProdutoTable(Produto.objects.all())
# table.columns['title'].header
# u'Model Verbose Name'
Example #10
0
class CountryTable(tables.Table):
    description = tables.LinkColumn('country details',
                                    args=[A('id')],
                                    verbose_name="Country name")
    transfermarkt_hyperlink = tables.URLColumn(
        attrs={'a': {
            'target': '_blank'
        }})

    class Meta:
        model = Country
        template_name = "tables/responsive-table.html"
Example #11
0
class SeasonTable(tables.Table):
    description = tables.LinkColumn('season details',
                                    args=[A('id')],
                                    verbose_name="Season name")
    league = tables.LinkColumn('league details', args=[A('league.id')])
    transfermarkt_hyperlink = tables.URLColumn(
        attrs={'a': {
            'target': '_blank'
        }})

    class Meta:
        model = Season
        template_name = "tables/responsive-table.html"
Example #12
0
class QueueTable(tables.Table):
    number = tables.LinkColumn(
        'queue details',
        args=[A('id')],
        text=lambda record: 'Queue {0}'.format(record.number),
        verbose_name="Queue name")
    transfermarkt_hyperlink = tables.URLColumn(
        attrs={'a': {
            'target': '_blank'
        }})

    class Meta:
        model = Queue
        template_name = "tables/responsive-table.html"
Example #13
0
class MessagesTable(tables.Table):
    text = tables.Column(verbose_name="Текст сообщения")
    url = tables.URLColumn(verbose_name="Ссылка для перехода")
    creation_date = tables.DateTimeColumn(verbose_name="Дата отправки")

    class Meta:
        model = models.Message
        attrs = {"class": "paleblue"}
        fields = (
            "creation_date",
            "text",
            "url",
        )
        sequence = fields
Example #14
0
class TuneTable(tables.Table):
    sheet_music = tables.URLColumn()
    concepts = ForeignFieldList()
    id = ModifyColumn('Modify')
    title = ClickableColumn()

    class Meta:
        model = Tune
        exclude = ('user', )
        orderable = True
        sequence = ('date', '...', 'id')

    def render_sheet_music(self, value):
        return mark_safe('<a href="' + value + '">View</a>')
Example #15
0
class PlayerTable(tables.Table):
    player = tables.LinkColumn('player details',
                               args=[A('id')],
                               text=lambda record: '{0} {1}'.format(
                                   record.first_name, record.last_name))
    transfermarkt_hyperlink = tables.URLColumn(
        attrs={'a': {
            'target': '_blank'
        }})

    class Meta:
        model = Player
        # Change order of columns - player (explicitly created), rest of columns from DB
        sequence = ('player', '...')
        template_name = "tables/responsive-table.html"
Example #16
0
	class Meta:
		model = Person
		email = tables.EmailColumn()
		name = tables.URLColumn()
		order_by = '-name'
		name = tables.Column(footer='Total:')



		template = 'django_tables2/bootstrap.html'
		fields = [
            'name',
            'company',
            'email',
            'phone',
        ]
Example #17
0
class MatchTable(tables.Table):
    match = tables.LinkColumn('match details',
                              args=[A('id')],
                              order_by=("first_team", "second_team"),
                              text=lambda record: '{0} vs. {1}'.format(
                                  record.first_team, record.second_team))
    queue = tables.LinkColumn('queue details', args=[A('queue.id')])
    transfermarkt_hyperlink = tables.URLColumn(
        attrs={'a': {
            'target': '_blank'
        }})

    class Meta:
        model = Match
        # Change order of columns - match (explicitly created), rest of columns from DB
        sequence = ('match', '...')
        template_name = "tables/responsive-table.html"
Example #18
0
class TaskTable(tables.Table):
    task_name = tables.LinkColumn(
        "tasks:complete", accessor="task.name", args=[A("pk")]
    )
    form = tables.URLColumn(
        verbose_name="Form to Submit",
        accessor="task.resource",
    )
    date = tables.DateColumn(verbose_name="Due Date")

    class Meta:
        model = TaskDate
        fields = (
            "task_name",
            "form",
            "date",
            "task.owner",
            "task.description",
        )
        attrs = {"class": "table table-striped table-bordered"}
        empty_text = "There are no tasks matching the search criteria..."

    def __init__(self, complete=True, *args, **kwargs):
        extra_columns = []
        if complete:
            extra_columns.extend(
                [
                    (
                        "complete_result",
                        tables.LinkColumn(
                            "tasks:detail",
                            args=[A("complete_link")],
                            verbose_name="Complete",
                            empty_values=(),
                        ),
                    ),
                ]
            )
        kwargs["extra_columns"] = extra_columns
        super().__init__(*args, **kwargs)

    def render_form(self, record):
        task = record.task
        value = task.render_task_link
        return value
Example #19
0
class AccessionTable(tables.Table):
    """
    Table that is displayed on the accession list view
    """
    id = tables.LinkColumn("accession_detail",
                           args=[A('id')],
                           text=lambda record: record.pk,
                           verbose_name="ID",
                           order_by="pk")
    name = tables.Column(accessor="name", verbose_name="Name", order_by="name")
    country = tables.Column(accessor="country",
                            verbose_name="Country",
                            order_by="country")
    sitename = tables.Column(accessor="sitename",
                             verbose_name="Sitename",
                             order_by="sitename")
    collector = tables.Column(accessor="collector",
                              verbose_name="Collector",
                              order_by="collector")
    longitude = tables.Column(accessor="longitude",
                              verbose_name="Longitude",
                              order_by="longitude")
    latitude = tables.Column(accessor="latitude",
                             verbose_name="Latitude",
                             order_by="latitude")
    cs_number = tables.URLColumn({"target": "_blank"},
                                 lambda record: record.cs_number,
                                 accessor="cs_number_url",
                                 verbose_name="CS Number",
                                 order_by="cs_number")
    genotypes = tables.ManyToManyColumn(
        accessor="genotype_set", transform=lambda genotype: genotype.name)
    number_of_phenotypes = tables.Column(accessor="count_phenotypes",
                                         verbose_name='# Phenotypes')

    class Meta:
        attrs = {"class": "striped"}

    def order_number_of_phenotypes(self, QuerySet, is_descending):
        QuerySet = QuerySet.annotate(count=Count(
            'observationunit__phenotypevalue__phenotype',
            distinct=True)).order_by(('-' if is_descending else '') + 'count')
        return (QuerySet, True)
Example #20
0
class BestPlayersTable(tables.Table):
    name = tables.LinkColumn('player details',
                             args=[A('id')],
                             order_by=("first_name", "last_name"),
                             text=lambda record: '{0} {1}'.format(
                                 record.first_name, record.last_name))
    goals = tables.TemplateColumn('{{ record.goal_set.count }}')
    assists = tables.TemplateColumn('{{ record.assist_set.count }}')
    time_in_matches = tables.TemplateColumn(
        '{{ record.get_time_sum_from_all_matches }}')
    transfermarkt_hyperlink = tables.URLColumn(
        attrs={'a': {
            'target': '_blank'
        }})

    def order_time_in_matches(self, queryset, is_descending):
        queryset = queryset.annotate(
            time_in_matches=(Sum('matchplayer__time')
                             )).order_by(("-" if is_descending else "") +
                                         "time_in_matches")
        return queryset, True

    def order_goals(self, queryset, is_descending):
        queryset = queryset.annotate(
            goals=(Count('goal'))).order_by(("-" if is_descending else "") +
                                            "goals")
        return queryset, True

    def order_assists(self, queryset, is_descending):
        queryset = queryset.annotate(assists=(
            Count('assist'))).order_by(("-" if is_descending else "") +
                                       "assists")
        return queryset, True

    class Meta:
        model = Player
        # Change order of columns - name (explicitly created), rest of columns from DB
        sequence = ('name', '...')
        template_name = "tables/responsive-table.html"
Example #21
0
 class Meta:
     link = tables.URLColumn()
     model = Service
     fields = ('city', 'title', 'salary')
Example #22
0
 def __init__(self, *args, **kwargs):
     self.task = tables.URLColumn()
     super(ResultsTable, self).__init__(*args, **kwargs)
     self.counter = itertools.count()
Example #23
0
 class Meta:
     link = tables.URLColumn()
     model = Gift
     fields = ('city', 'title', 'gift_type')
Example #24
0
 class TestTable(tables.Table):
     url = tables.URLColumn()
Example #25
0
 class Table(tables.Table):
     url = tables.URLColumn(text=lambda record: record["name"])
Example #26
0
 class Table(tables.Table):
     url = tables.URLColumn(text="link")
Example #27
0
 class Meta:
     link = tables.URLColumn()
     model = Job
     fields = ('city', 'title', 'jobtype', 'salary')
Example #28
0
 class Meta:
     link = tables.URLColumn()
     model = Item
     fields = ('city', 'title', 'condition', 'price')
Example #29
0
 class Meta:
     link = tables.URLColumn()
     model = Rent
     fields = ('city', 'title', 'property_type', 'bathrooms', 'bedrooms',
               'price')