from django.contrib import sitemaps
from django.urls import reverse

from .models import Category

class StaticViewSitemap(sitemaps.Sitemap):
    priority = 0.5
    protocol = "https"
    changefreq = "daily"

    def items(self):
        return ["home", "cette_semaine", "ce_mois_ci", "aujourdhui", "a_venir", "about", "contact"]

    def location(self, item):
        return reverse(item)

class HomeCategorySitemap(sitemaps.Sitemap):
    priority = 0.5
    protocol = "https"
    changefreq = "daily"
    path = "home_category"

    def items(self):
        result = []
        return Category.objects.values_list("slug", flat=True)

    def location(self, item):
        return reverse(self.path, kwargs={'cat': item})

class MonthCategorySitemap(HomeCategorySitemap):
    priority = 0.3
    protocol = "https"
    path = "ce_mois_ci_category"

class WeekCategorySitemap(HomeCategorySitemap):
    priority = 0.4
    protocol = "https"
    path = "cette_semaine_category"

class UpcomingCategorySitemap(HomeCategorySitemap):
    priority = 0.4
    protocol = "https"
    path = "a_venir_category"
