# Path: blog/models.py
# class Category(models.Model):
#     """
#     A category into which entries can be filed.
# 
#     """
# 
#     title = models.CharField(max_length=250)
#     slug = models.SlugField(unique=True)
#     description = models.TextField()
#     description_html = models.TextField(editable=False, blank=True)
# 
#     class Meta:
#         verbose_name_plural = "Categories"
#         ordering = ("title",)
# 
#     def __str__(self) -> str:
#         return self.title
# 
#     def save(self, *args, **kwargs):
#         self.description_html = markup(self.description)
#         super().save(*args, **kwargs)
# 
#     def get_absolute_url(self) -> str:
#         return reverse(
#             "categories:category", kwargs={"slug": self.slug}, current_app="blog"
#         )
# 
#     def _get_live_entries(self) -> models.QuerySet:
#         return self.entry_set.filter(status=Entry.LIVE_STATUS)
# 
#     live_entries = property(_get_live_entries)
# 
# Path: blog/models.py
# class Entry(models.Model):
#     """
#     An entry in the blog.
# 
#     """
# 
#     LIVE_STATUS = 1
#     DRAFT_STATUS = 2
#     HIDDEN_STATUS = 3
#     STATUS_CHOICES = (
#         (LIVE_STATUS, "Live"),
#         (DRAFT_STATUS, "Draft"),
#         (HIDDEN_STATUS, "Hidden"),
#     )
# 
#     author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
#     pub_date = models.DateTimeField("Date posted", default=datetime.datetime.now)
#     updated_date = models.DateTimeField(blank=True, editable=False)
#     slug = models.SlugField(unique_for_date="pub_date")
#     status = models.IntegerField(choices=STATUS_CHOICES, default=LIVE_STATUS)
#     title = models.CharField(max_length=250)
# 
#     body = models.TextField()
#     body_html = models.TextField(editable=False, blank=True)
# 
#     excerpt = models.TextField(blank=True, null=True)
#     excerpt_html = models.TextField(editable=False, blank=True, null=True)
# 
#     categories = models.ManyToManyField("Category")
# 
#     live = LiveEntryManager()
#     objects = models.Manager()
# 
#     class Meta:
#         get_latest_by = "pub_date"
#         ordering = ("-pub_date",)
#         verbose_name_plural = "Entries"
# 
#     def __str__(self) -> str:
#         return self.title
# 
#     def save(self, *args, **kwargs):
#         self.body_html = markup(self.body)
#         if self.excerpt:
#             self.excerpt_html = markup(self.excerpt)
#         self.updated_date = datetime.datetime.now()
#         super().save(*args, **kwargs)
# 
#     def get_absolute_url(self) -> str:
#         return reverse(
#             "entries:entry",
#             kwargs={
#                 "year": self.pub_date.strftime("%Y"),
#                 "month": self.pub_date.strftime("%b").lower(),
#                 "day": self.pub_date.strftime("%d"),
#                 "slug": self.slug,
#             },
#         )


import datetime
import typing
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed
from django.http import HttpRequest
from django.utils.feedgenerator import Atom1Feed
from .models import Category
from .models import Entry




current_site = Site.objects.get_current()


class EntriesFeed(Feed):
    author_name = "James Bennett"
    copyright = "https://{}/about/copyright/".format(current_site.domain)
    description = "Latest entriess"
    feed_type = Atom1Feed
    item_copyright = "https://{}/about/copyright/".format(current_site.domain)
    item_author_name = "James Bennett"
    item_author_link = "https://{}/".format(current_site.domain)
    feed_url = "https://{}/feeds/entries/".format(current_site.domain)
    link = "https://{}/".format(current_site.domain)
    title = "James Bennett (b-list.org)"

    description_template = "feeds/entry_description.html"
    title_template = "feeds/entry_title.html"


# Path: blog/models.py
# class Category(models.Model):
#     """
#     A category into which entries can be filed.
# 
#     """
# 
#     title = models.CharField(max_length=250)
#     slug = models.SlugField(unique=True)
#     description = models.TextField()
#     description_html = models.TextField(editable=False, blank=True)
# 
#     class Meta:
#         verbose_name_plural = "Categories"
#         ordering = ("title",)
# 
#     def __str__(self) -> str:
#         return self.title
# 
#     def save(self, *args, **kwargs):
#         self.description_html = markup(self.description)
#         super().save(*args, **kwargs)
# 
#     def get_absolute_url(self) -> str:
#         return reverse(
#             "categories:category", kwargs={"slug": self.slug}, current_app="blog"
#         )
# 
#     def _get_live_entries(self) -> models.QuerySet:
#         return self.entry_set.filter(status=Entry.LIVE_STATUS)
# 
#     live_entries = property(_get_live_entries)
# 
# Path: blog/models.py
# class Entry(models.Model):
#     """
#     An entry in the blog.
# 
#     """
# 
#     LIVE_STATUS = 1
#     DRAFT_STATUS = 2
#     HIDDEN_STATUS = 3
#     STATUS_CHOICES = (
#         (LIVE_STATUS, "Live"),
#         (DRAFT_STATUS, "Draft"),
#         (HIDDEN_STATUS, "Hidden"),
#     )
# 
#     author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
#     pub_date = models.DateTimeField("Date posted", default=datetime.datetime.now)
#     updated_date = models.DateTimeField(blank=True, editable=False)
#     slug = models.SlugField(unique_for_date="pub_date")
#     status = models.IntegerField(choices=STATUS_CHOICES, default=LIVE_STATUS)
#     title = models.CharField(max_length=250)
# 
#     body = models.TextField()
#     body_html = models.TextField(editable=False, blank=True)
# 
#     excerpt = models.TextField(blank=True, null=True)
#     excerpt_html = models.TextField(editable=False, blank=True, null=True)
# 
#     categories = models.ManyToManyField("Category")
# 
#     live = LiveEntryManager()
#     objects = models.Manager()
# 
#     class Meta:
#         get_latest_by = "pub_date"
#         ordering = ("-pub_date",)
#         verbose_name_plural = "Entries"
# 
#     def __str__(self) -> str:
#         return self.title
# 
#     def save(self, *args, **kwargs):
#         self.body_html = markup(self.body)
#         if self.excerpt:
#             self.excerpt_html = markup(self.excerpt)
#         self.updated_date = datetime.datetime.now()
#         super().save(*args, **kwargs)
# 
#     def get_absolute_url(self) -> str:
#         return reverse(
#             "entries:entry",
#             kwargs={
#                 "year": self.pub_date.strftime("%Y"),
#                 "month": self.pub_date.strftime("%b").lower(),
#                 "day": self.pub_date.strftime("%d"),
#                 "slug": self.slug,
#             },
#         )


# Path: blog/feeds.py
import datetime
import typing
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed
from django.http import HttpRequest
from django.utils.feedgenerator import Atom1Feed
from .models import Category
from .models import Entry





current_site = Site.objects.get_current()


class EntriesFeed(Feed):
    author_name = "James Bennett"
    copyright = "https://{}/about/copyright/".format(current_site.domain)
    description = "Latest entriess"
    feed_type = Atom1Feed
    item_copyright = "https://{}/about/copyright/".format(current_site.domain)
    item_author_name = "James Bennett"
    item_author_link = "https://{}/".format(current_site.domain)
    feed_url = "https://{}/feeds/entries/".format(current_site.domain)
    link = "https://{}/".format(current_site.domain)
    title = "James Bennett (b-list.org)"

    description_template = "feeds/entry_description.html"
    title_template = "feeds/entry_title.html"


    def item_categories(self, item: Entry) -> typing.List[str]: