From 20ea99ed29519da3da479622474e101171867044 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:12:22 -0500 Subject: [PATCH 1/2] test: failure to customize djangocms_blog feed --- apps/custom_djangocms_blog_feed/__init__.py | 0 apps/custom_djangocms_blog_feed/apps.py | 5 ++++ apps/custom_djangocms_blog_feed/feeds.py | 26 +++++++++++++++++++++ apps/custom_djangocms_blog_feed/urls.py | 16 +++++++++++++ taccsite_cms/custom_app_settings.example.py | 2 +- taccsite_cms/urls_custom.example.py | 4 ++-- 6 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 apps/custom_djangocms_blog_feed/__init__.py create mode 100644 apps/custom_djangocms_blog_feed/apps.py create mode 100644 apps/custom_djangocms_blog_feed/feeds.py create mode 100644 apps/custom_djangocms_blog_feed/urls.py diff --git a/apps/custom_djangocms_blog_feed/__init__.py b/apps/custom_djangocms_blog_feed/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/apps/custom_djangocms_blog_feed/apps.py b/apps/custom_djangocms_blog_feed/apps.py new file mode 100644 index 000000000..d9280a921 --- /dev/null +++ b/apps/custom_djangocms_blog_feed/apps.py @@ -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' diff --git a/apps/custom_djangocms_blog_feed/feeds.py b/apps/custom_djangocms_blog_feed/feeds.py new file mode 100644 index 000000000..a1d008ece --- /dev/null +++ b/apps/custom_djangocms_blog_feed/feeds.py @@ -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 diff --git a/apps/custom_djangocms_blog_feed/urls.py b/apps/custom_djangocms_blog_feed/urls.py new file mode 100644 index 000000000..ddf094867 --- /dev/null +++ b/apps/custom_djangocms_blog_feed/urls.py @@ -0,0 +1,16 @@ +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 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'), +] diff --git a/taccsite_cms/custom_app_settings.example.py b/taccsite_cms/custom_app_settings.example.py index 3ac04c50d..257edd8e5 100644 --- a/taccsite_cms/custom_app_settings.example.py +++ b/taccsite_cms/custom_app_settings.example.py @@ -1,3 +1,3 @@ -CUSTOM_APPS = ['apps.custom_example'] +CUSTOM_APPS = ['apps.custom_example', 'apps.custom_djangocms_blog_feed'] CUSTOM_MIDDLEWARE = [] STATICFILES_DIRS = () diff --git a/taccsite_cms/urls_custom.example.py b/taccsite_cms/urls_custom.example.py index d7b3795e4..3d8b0d08a 100644 --- a/taccsite_cms/urls_custom.example.py +++ b/taccsite_cms/urls_custom.example.py @@ -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')), ] From 102e941c7f59ee186e6549340fa7a24364cdb2e3 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:14:07 -0500 Subject: [PATCH 2/2] docs: full failure notes --- apps/custom_djangocms_blog_feed/urls.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/custom_djangocms_blog_feed/urls.py b/apps/custom_djangocms_blog_feed/urls.py index ddf094867..e2a846661 100644 --- a/apps/custom_djangocms_blog_feed/urls.py +++ b/apps/custom_djangocms_blog_feed/urls.py @@ -7,6 +7,7 @@ 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`