diff --git a/src/fellchensammlung/feeds.py b/src/fellchensammlung/feeds.py new file mode 100644 index 0000000..bfa3f17 --- /dev/null +++ b/src/fellchensammlung/feeds.py @@ -0,0 +1,20 @@ +from django.contrib.syndication.views import Feed + +from django.urls import reverse +from .models import AdoptionNotice + + +class LatestAdoptionNoticesFeed(Feed): + title = "Nptfellchen" + link = "/rss/" + description = "Updates zu neuen Vermittlungen." + + def items(self): + return AdoptionNotice.objects.order_by("-created_at")[:5] + + def item_title(self, item): + return item.name + + def item_description(self, item): + return item.description + diff --git a/src/fellchensammlung/templates/fellchensammlung/header.html b/src/fellchensammlung/templates/fellchensammlung/header.html index b19fa0f..a4143ed 100644 --- a/src/fellchensammlung/templates/fellchensammlung/header.html +++ b/src/fellchensammlung/templates/fellchensammlung/header.html @@ -10,7 +10,7 @@ Suchen Vermittlung hinzufügen Über uns - RSS + RSS
diff --git a/src/fellchensammlung/urls.py b/src/fellchensammlung/urls.py index 9202abe..844dd1f 100644 --- a/src/fellchensammlung/urls.py +++ b/src/fellchensammlung/urls.py @@ -2,11 +2,13 @@ from django.urls import path, include from django_registration.backends.activation.views import RegistrationView from .forms import CustomRegistrationForm +from .feeds import LatestAdoptionNoticesFeed from . import views urlpatterns = [ path("", views.index, name="index"), + path("rss/", LatestAdoptionNoticesFeed(), name="rss"), # ex: /animal/5/ path("/", views.animal_detail, name="animal-detail"), # ex: /adoption_notice/7/