filter fixes

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-19 10:49:01 +00:00
parent 8c8f2df5dd
commit cbb32b1c9d
14 changed files with 287 additions and 239 deletions

View File

@@ -46,9 +46,14 @@ class ClustersFilter(django_filters.FilterSet):
class ContentIdeasFilter(django_filters.FilterSet):
"""Custom filter for ContentIdeas with date range support"""
"""Custom filter for ContentIdeas with date range support.
Uses CharFilter for content_type and content_structure to accept any value
(database may have legacy values not in current model choices).
"""
created_at__gte = django_filters.IsoDateTimeFilter(field_name='created_at', lookup_expr='gte')
created_at__lte = django_filters.IsoDateTimeFilter(field_name='created_at', lookup_expr='lte')
content_type = django_filters.CharFilter(field_name='content_type')
content_structure = django_filters.CharFilter(field_name='content_structure')
class Meta:
model = ContentIdeas
@@ -1378,6 +1383,8 @@ class ClusterViewSet(SiteSectorModelViewSet):
'mapped': 'Mapped',
}
status_options = [
{'value': '', 'label': 'All Status'},
] + [
{'value': s, 'label': status_labels.get(s, s.title())}
for s in statuses
]
@@ -1428,6 +1435,8 @@ class ClusterViewSet(SiteSectorModelViewSet):
5: '5 - Very Hard',
}
difficulty_options = [
{'value': '', 'label': 'All Difficulty'},
] + [
{'value': str(d), 'label': difficulty_labels[d]}
for d in sorted(difficulty_levels)
]
@@ -1669,6 +1678,8 @@ class ContentIdeasViewSet(SiteSectorModelViewSet):
'completed': 'Completed',
}
status_options = [
{'value': '', 'label': 'All Status'},
] + [
{'value': s, 'label': status_labels.get(s, s.title())}
for s in statuses
]
@@ -1690,6 +1701,8 @@ class ContentIdeasViewSet(SiteSectorModelViewSet):
'taxonomy': 'Taxonomy',
}
content_type_options = [
{'value': '', 'label': 'All Types'},
] + [
{'value': t, 'label': type_labels.get(t, t.title())}
for t in content_types
]
@@ -1713,6 +1726,8 @@ class ContentIdeasViewSet(SiteSectorModelViewSet):
'tag_archive': 'Tag Archive', 'attribute_archive': 'Attribute Archive',
}
content_structure_options = [
{'value': '', 'label': 'All Structures'},
] + [
{'value': s, 'label': structure_labels.get(s, s.replace('_', ' ').title())}
for s in structures
]
@@ -1731,6 +1746,8 @@ class ContentIdeasViewSet(SiteSectorModelViewSet):
))
clusters = Clusters.objects.filter(id__in=cluster_ids).values('id', 'name').order_by('name')
cluster_options = [
{'value': '', 'label': 'All Clusters'},
] + [
{'value': str(c['id']), 'label': c['name']}
for c in clusters
]