update
This commit is contained in:
54
fraud_platform/sitemaps.py
Normal file
54
fraud_platform/sitemaps.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""
|
||||
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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user