예제 #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"
예제 #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')
예제 #3
0
파일: views.py 프로젝트: rlebron88/toolbox
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
예제 #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"}
예제 #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>')
예제 #6
0
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")
예제 #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)
예제 #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'}
예제 #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'
예제 #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"
예제 #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"
예제 #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"
예제 #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
예제 #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>')
예제 #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"
예제 #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',
        ]
예제 #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"
예제 #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
예제 #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)
예제 #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"
예제 #21
0
 class Meta:
     link = tables.URLColumn()
     model = Service
     fields = ('city', 'title', 'salary')
예제 #22
0
 def __init__(self, *args, **kwargs):
     self.task = tables.URLColumn()
     super(ResultsTable, self).__init__(*args, **kwargs)
     self.counter = itertools.count()
예제 #23
0
 class Meta:
     link = tables.URLColumn()
     model = Gift
     fields = ('city', 'title', 'gift_type')
예제 #24
0
 class TestTable(tables.Table):
     url = tables.URLColumn()
예제 #25
0
 class Table(tables.Table):
     url = tables.URLColumn(text=lambda record: record["name"])
예제 #26
0
 class Table(tables.Table):
     url = tables.URLColumn(text="link")
예제 #27
0
 class Meta:
     link = tables.URLColumn()
     model = Job
     fields = ('city', 'title', 'jobtype', 'salary')
예제 #28
0
 class Meta:
     link = tables.URLColumn()
     model = Item
     fields = ('city', 'title', 'condition', 'price')
예제 #29
0
 class Meta:
     link = tables.URLColumn()
     model = Rent
     fields = ('city', 'title', 'property_type', 'bathrooms', 'bedrooms',
               'price')