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)
 | 
			
		||||
    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):
 | 
			
		||||
    OSM = "OSM", _("Open Street Map")
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
from django.contrib.sitemaps import Sitemap
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
from .models import AdoptionNotice, RescueOrganization
 | 
			
		||||
from .models import AdoptionNotice, RescueOrganization, ImportantLocation, Animal
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class StaticViewSitemap(Sitemap):
 | 
			
		||||
@@ -8,7 +8,8 @@ class StaticViewSitemap(Sitemap):
 | 
			
		||||
    changefreq = "weekly"
 | 
			
		||||
 | 
			
		||||
    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):
 | 
			
		||||
        return reverse(item)
 | 
			
		||||
@@ -25,17 +26,6 @@ class AdoptionNoticeSitemap(Sitemap):
 | 
			
		||||
        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):
 | 
			
		||||
    priority = 0.3
 | 
			
		||||
    changefreq = "weekly"
 | 
			
		||||
@@ -45,3 +35,11 @@ class RescueOrganizationSitemap(Sitemap):
 | 
			
		||||
 | 
			
		||||
    def lastmod(self, obj):
 | 
			
		||||
        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 django.contrib.sitemaps.views import sitemap
 | 
			
		||||
from .sitemap import StaticViewSitemap, AdoptionNoticeSitemap, AnimalSitemap
 | 
			
		||||
from .sitemap import StaticViewSitemap, AdoptionNoticeSitemap, RescueOrganizationSitemap, SearchSitemap
 | 
			
		||||
 | 
			
		||||
sitemaps = {
 | 
			
		||||
    "static": StaticViewSitemap,
 | 
			
		||||
    "vermittlungen": AdoptionNoticeSitemap,
 | 
			
		||||
    "tiere": AnimalSitemap,
 | 
			
		||||
    "tierschutzorganisationen": RescueOrganizationSitemap,
 | 
			
		||||
    "orte": SearchSitemap
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
urlpatterns = [
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user