55 lines
1.2 KiB
Python
55 lines
1.2 KiB
Python
"""
|
|
Sitemap configuration for SEO.
|
|
"""
|
|
from django.contrib.sitemaps import Sitemap
|
|
from django.urls import reverse
|
|
from reports.models import ScamReport
|
|
|
|
|
|
class StaticViewSitemap(Sitemap):
|
|
"""Sitemap for static pages."""
|
|
priority = 1.0
|
|
changefreq = 'monthly'
|
|
|
|
def items(self):
|
|
return [
|
|
'reports:home',
|
|
'reports:list',
|
|
'reports:create',
|
|
'reports:contact',
|
|
'reports:search',
|
|
'legal:privacy',
|
|
'legal:terms',
|
|
]
|
|
|
|
def location(self, item):
|
|
return reverse(item)
|
|
|
|
|
|
class ScamReportSitemap(Sitemap):
|
|
"""Sitemap for scam reports."""
|
|
changefreq = 'weekly'
|
|
priority = 0.8
|
|
|
|
def items(self):
|
|
# Only include public, verified reports
|
|
return ScamReport.objects.filter(
|
|
is_public=True,
|
|
status='verified'
|
|
).order_by('-created_at')
|
|
|
|
def lastmod(self, obj):
|
|
return obj.updated_at or obj.created_at
|
|
|
|
def location(self, obj):
|
|
from django.urls import reverse
|
|
return reverse('reports:detail', kwargs={'pk': obj.pk})
|
|
|
|
|
|
# Combine sitemaps
|
|
sitemaps = {
|
|
'static': StaticViewSitemap,
|
|
'reports': ScamReportSitemap,
|
|
}
|
|
|