feat: add important locations and buying to sitemap and fix
This commit is contained in:
@@ -107,6 +107,9 @@ class ImportantLocation(models.Model):
|
|||||||
slug = models.SlugField(unique=True)
|
slug = models.SlugField(unique=True)
|
||||||
name = models.CharField(max_length=200)
|
name = models.CharField(max_length=200)
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse('search-by-location', kwargs={'important_location_slug': self.slug})
|
||||||
|
|
||||||
|
|
||||||
class ExternalSourceChoices(models.TextChoices):
|
class ExternalSourceChoices(models.TextChoices):
|
||||||
OSM = "OSM", _("Open Street Map")
|
OSM = "OSM", _("Open Street Map")
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
from django.contrib.sitemaps import Sitemap
|
from django.contrib.sitemaps import Sitemap
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from .models import AdoptionNotice, RescueOrganization
|
from .models import AdoptionNotice, RescueOrganization, ImportantLocation, Animal
|
||||||
|
|
||||||
|
|
||||||
class StaticViewSitemap(Sitemap):
|
class StaticViewSitemap(Sitemap):
|
||||||
@@ -8,7 +8,8 @@ class StaticViewSitemap(Sitemap):
|
|||||||
changefreq = "weekly"
|
changefreq = "weekly"
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
return ["index", "search", "map", "about", "rescue-organizations"]
|
return ["index", "search", "map", "about", "rescue-organizations", "buying", "imprint", "terms-of-service",
|
||||||
|
"privacy"]
|
||||||
|
|
||||||
def location(self, item):
|
def location(self, item):
|
||||||
return reverse(item)
|
return reverse(item)
|
||||||
@@ -25,17 +26,6 @@ class AdoptionNoticeSitemap(Sitemap):
|
|||||||
return obj.updated_at
|
return obj.updated_at
|
||||||
|
|
||||||
|
|
||||||
class AnimalSitemap(Sitemap):
|
|
||||||
priority = 0.2
|
|
||||||
changefreq = "daily"
|
|
||||||
|
|
||||||
def items(self):
|
|
||||||
return AdoptionNotice.objects.all()
|
|
||||||
|
|
||||||
def lastmod(self, obj):
|
|
||||||
return obj.updated_at
|
|
||||||
|
|
||||||
|
|
||||||
class RescueOrganizationSitemap(Sitemap):
|
class RescueOrganizationSitemap(Sitemap):
|
||||||
priority = 0.3
|
priority = 0.3
|
||||||
changefreq = "weekly"
|
changefreq = "weekly"
|
||||||
@@ -45,3 +35,11 @@ class RescueOrganizationSitemap(Sitemap):
|
|||||||
|
|
||||||
def lastmod(self, obj):
|
def lastmod(self, obj):
|
||||||
return obj.updated_at
|
return obj.updated_at
|
||||||
|
|
||||||
|
|
||||||
|
class SearchSitemap(Sitemap):
|
||||||
|
priority = 0.5
|
||||||
|
chanfreq = "daily"
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
return ImportantLocation.objects.all()
|
||||||
|
@@ -7,12 +7,14 @@ from . import views, registration_views
|
|||||||
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
|
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
|
||||||
|
|
||||||
from django.contrib.sitemaps.views import sitemap
|
from django.contrib.sitemaps.views import sitemap
|
||||||
from .sitemap import StaticViewSitemap, AdoptionNoticeSitemap, AnimalSitemap
|
from .sitemap import StaticViewSitemap, AdoptionNoticeSitemap, RescueOrganizationSitemap, SearchSitemap
|
||||||
|
|
||||||
sitemaps = {
|
sitemaps = {
|
||||||
"static": StaticViewSitemap,
|
"static": StaticViewSitemap,
|
||||||
"vermittlungen": AdoptionNoticeSitemap,
|
"vermittlungen": AdoptionNoticeSitemap,
|
||||||
"tiere": AnimalSitemap,
|
"tierschutzorganisationen": RescueOrganizationSitemap,
|
||||||
|
"orte": SearchSitemap
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
Reference in New Issue
Block a user