# Path: apps/taxonomy/serializers/act.py
# class ActSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:
#         model = Act
#         fields = [
#             'id', 'url', 'taxon_node', 'type', 'previous_value',
#             'remarks', 'citation_text', 'created_at'
#         ]
# 
# Path: apps/taxonomy/models.py
# class Act(models.Model):
#     taxon_node = models.ForeignKey(TaxonNode, related_name='acts')
#     type = models.CharField(max_length=63, choices=ACT_TYPES)
#     previous_value = models.CharField(max_length=255, null=True, blank=True)
#     remarks = models.TextField(null=True, blank=True)
#     citation_text = models.TextField(null=True, blank=True)
#     created_at = models.DateTimeField(auto_now_add=True)


import django_filters
from apps.taxonomy.serializers.act import ActSerializer
from apps.taxonomy.models import Act
from rest_framework import viewsets



class ActFilter(django_filters.FilterSet):
    min_datetime = django_filters.DateTimeFilter(name="created_at", lookup_type='gte')
    max_datetime = django_filters.DateTimeFilter(name="created_at", lookup_type='lte')
    tree = django_filters.NumberFilter(name="taxon_node__tree_id", lookup_type='exact')

    class Meta:
        model = Act
        fields = ['type', 'taxon_node', 'min_datetime', 'max_datetime', 'tree']


class ActView(viewsets.ReadOnlyModelViewSet):

# Path: apps/taxonomy/serializers/act.py
# class ActSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:
#         model = Act
#         fields = [
#             'id', 'url', 'taxon_node', 'type', 'previous_value',
#             'remarks', 'citation_text', 'created_at'
#         ]
# 
# Path: apps/taxonomy/models.py
# class Act(models.Model):
#     taxon_node = models.ForeignKey(TaxonNode, related_name='acts')
#     type = models.CharField(max_length=63, choices=ACT_TYPES)
#     previous_value = models.CharField(max_length=255, null=True, blank=True)
#     remarks = models.TextField(null=True, blank=True)
#     citation_text = models.TextField(null=True, blank=True)
#     created_at = models.DateTimeField(auto_now_add=True)


# Path: apps/taxonomy/views/act.py
import django_filters
from apps.taxonomy.serializers.act import ActSerializer
from apps.taxonomy.models import Act
from rest_framework import viewsets




class ActFilter(django_filters.FilterSet):
    min_datetime = django_filters.DateTimeFilter(name="created_at", lookup_type='gte')
    max_datetime = django_filters.DateTimeFilter(name="created_at", lookup_type='lte')
    tree = django_filters.NumberFilter(name="taxon_node__tree_id", lookup_type='exact')

    class Meta:
        model = Act
        fields = ['type', 'taxon_node', 'min_datetime', 'max_datetime', 'tree']


class ActView(viewsets.ReadOnlyModelViewSet):

    queryset = Act.objects.all().order_by('id')