Integrated feeds on homepage into a new feed
This commit is contained in:
parent
a6d60dae6f
commit
60030f14cd
|
@ -9,6 +9,7 @@ from django.views.generic import TemplateView
|
|||
from django.views import defaults as default_views
|
||||
from mhackspace.contact.views import contact
|
||||
from mhackspace.members.views import MemberListView
|
||||
from mhackspace.base.feeds import LatestEntriesFeed
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', TemplateView.as_view(template_name='pages/home.html'), name='home'),
|
||||
|
@ -29,6 +30,7 @@ urlpatterns = [
|
|||
url(r'^accounts/', include('allauth.urls')),
|
||||
|
||||
# Your stuff: custom urls includes go here
|
||||
url(r'^latest/$', LatestEntriesFeed()),
|
||||
|
||||
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
from django.contrib.syndication.views import Feed
|
||||
from django.urls import reverse
|
||||
from mhackspace.feeds.models import Article
|
||||
|
||||
class LatestEntriesFeed(Feed):
|
||||
title = "Maidstone hackspace site news"
|
||||
link = "/latest/"
|
||||
description = "Latest creations from our users."
|
||||
|
||||
def items(self):
|
||||
return Article.objects.all()[:5]
|
||||
|
||||
def item_title(self, item):
|
||||
return item.title
|
||||
|
||||
def item_description(self, item):
|
||||
return item.description
|
||||
|
||||
def item_link(self, item):
|
||||
return item.url
|
|
@ -1,6 +1,6 @@
|
|||
from autofixture import AutoFixture
|
||||
from django.core.management.base import BaseCommand
|
||||
from mhackspace.feeds.models import Article
|
||||
from mhackspace.feeds.models import Article, Feed
|
||||
from mhackspace.users.models import User
|
||||
|
||||
|
||||
|
@ -11,7 +11,10 @@ class Command(BaseCommand):
|
|||
users = AutoFixture(User)
|
||||
users.create(10)
|
||||
|
||||
feeds = AutoFixture(User)
|
||||
feed = AutoFixture(Feed)
|
||||
feed.create(10)
|
||||
|
||||
feeds = AutoFixture(Article)
|
||||
feeds.create(10)
|
||||
|
||||
self.stdout.write(
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="card-block">
|
||||
<a href="{{ article.url }}" class="card-link"><h4 class="card-title">{{ article.title }}</h4></a>
|
||||
<p class="card-text">{{ article.feed.author }}</p>
|
||||
<p class="card-text">{{ article.description|striptags }}</p>
|
||||
<p class="card-text">{{ article.description|striptags|truncatewords:30 }}</p>
|
||||
<a href="{{ article.url }}" class="card-link">View Original</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue