add rss
This commit is contained in:
parent
bd75ea5fa0
commit
8337c6eb87
3 changed files with 21 additions and 0 deletions
|
@ -22,6 +22,10 @@ class Document(SoftDeletableModel):
|
|||
tags = models.ManyToManyField(Tag, related_name="documents")
|
||||
uploaded = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
def get_absolute_url(self):
|
||||
from django.urls import reverse
|
||||
return reverse('pile:document', args=[str(self.id)])
|
||||
|
||||
class Meta:
|
||||
ordering = ['-id']
|
||||
|
||||
|
|
|
@ -7,4 +7,5 @@ urlpatterns = [
|
|||
path('', views.IndexView.as_view(), name='index'),
|
||||
path('tag/<name_or_id>', views.TagView.as_view(), name='tag'),
|
||||
path('item/<int:document_id>', views.DocumentView.as_view(), name='document'),
|
||||
path('feed', views.RecentlyUploadedFeed())
|
||||
]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Create your views here.
|
||||
from django.contrib.syndication.views import Feed
|
||||
from django.db.models import Count
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
@ -60,3 +61,18 @@ class DocumentView(BasePileView):
|
|||
'document': Document.objects.get(pk=document_id),
|
||||
**base_context_data
|
||||
}
|
||||
|
||||
|
||||
class RecentlyUploadedFeed(Feed):
|
||||
title = "The /-\\ pile"
|
||||
link = "https://pile.sbds.cz"
|
||||
description = "A list of most recently uploaded documents."
|
||||
|
||||
def items(self):
|
||||
return Document.objects.order_by('-uploaded')[:5]
|
||||
|
||||
def item_title(self, item):
|
||||
return item.title
|
||||
|
||||
def item_description(self, item):
|
||||
return item.description
|
||||
|
|
Loading…
Reference in a new issue