Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: customize djangocms_blog feed ⚠️ #874

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
5 changes: 5 additions & 0 deletions apps/custom_djangocms_blog_feed/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _

class djangoCMSBlogFeedAppConfig(AppConfig):
name = 'apps.custom_djangocms_blog_feed'
26 changes: 26 additions & 0 deletions apps/custom_djangocms_blog_feed/feeds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from aldryn_apphooks_config.utils import get_app_instance
from django.utils.feedgenerator import Rss201rev2Feed

from djangocms_blog.feeds import LatestEntriesFeed as DjangoCMSBlogLatestEntriesFeed
from djangocms_blog.settings import get_setting
from djangocms_blog.cms_appconfig import BlogConfig

# XXX: This file is loaded, but it does NOT override the feed
# XXX: Logging via logger fails anywhere; via print fails inside any method
class LatestEntriesFeed(DjangoCMSBlogLatestEntriesFeed):
feed_type = Rss201rev2Feed
feed_items_number = get_setting("FEED_LATEST_ITEMS")

def __call__(self, request, *args, **kwargs):
namespace = get_setting("AUTO_NAMESPACE")

self.request = request
self.namespace = get_setting("AUTO_NAMESPACE")
self.config = BlogConfig.objects.get(namespace=namespace)

return super().__call__(request, *args, **kwargs)

def items(self):
items = super().items()

return items
17 changes: 17 additions & 0 deletions apps/custom_djangocms_blog_feed/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.urls import path

from .feeds import LatestEntriesFeed

# from apps.custom_example.views import CustomExampleView

app_name = 'custom_djangocms_blog_feed'
urlpatterns = [
# To render styled Blog feed
# XXX: Does NOT load page
# XXX: Does NOT style the feed
# XXX: Does NOT customize the feed
# FAQ: See errors at `/blog/feed/`, items at `/blog/feed/fb`
# FAQ: See Blog app feed root at `/news/feed/`, items at `/news/feed/fb`
path('feed/', LatestEntriesFeed(), name='feed'),
# path('feed/', CustomExampleView, name='feed'),
]
2 changes: 1 addition & 1 deletion taccsite_cms/custom_app_settings.example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CUSTOM_APPS = ['apps.custom_example']
CUSTOM_APPS = ['apps.custom_example', 'apps.custom_djangocms_blog_feed']
CUSTOM_MIDDLEWARE = []
STATICFILES_DIRS = ()
4 changes: 2 additions & 2 deletions taccsite_cms/urls_custom.example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.urls import path, include
from django.urls import re_path, include

custom_urls = [
path('custom_test/', include('apps.custom_example.urls', namespace='custom_test')),
re_path(r'^custom_test/', include('apps.custom_example.urls', namespace='custom_test')),
]