# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later

import django_tables2 as tables

from .models import Food


class FoodTable(tables.Table):
    """
    List all foods.
    """
    class Meta:
        model = Food
        template_name = 'django_tables2/bootstrap4.html'
        fields = ('name', 'owner', 'allergens', 'expiry_date')
        row_attrs = {
            'class': 'table-row',
            'data-href': lambda record: 'detail/' + str(record.pk),
            'style': 'cursor:pointer',
        }