From ab6f26c046c16405db397438dc4ed691b5a54db6 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 17 Jun 2024 16:28:44 +1000 Subject: [PATCH 1/3] Update requirements.txt requests 2.32.0 was yanked. --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 38747b9..7da8b1c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,9 +4,9 @@ Django==4.2.11 environs==9.5.0 feedparser==6.0.10 psycopg2==2.9.5 -requests==2.32.0 +requests==2.32.3 # dev black==24.3.0 -pylint==3.0.3 \ No newline at end of file +pylint==3.0.3 -- 2.39.5 From 365b7e7d78188e10a6dfbf12de5dd7139fa3bc81 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 24 Jun 2024 12:22:35 +1000 Subject: [PATCH 2/3] don't use entire post if it is in the "summary". --- blogs/management/commands/check_feeds.py | 64 +++++++++++++++--------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/blogs/management/commands/check_feeds.py b/blogs/management/commands/check_feeds.py index 8283594..fad09c8 100644 --- a/blogs/management/commands/check_feeds.py +++ b/blogs/management/commands/check_feeds.py @@ -117,7 +117,7 @@ class Command(BaseCommand): if not opt_out: author_name = getattr( article, "author", None - ) or getattr(blog, "author", None) + ) or getattr(blog, "author", "") description = ( html.strip_tags(article.summary) @@ -125,20 +125,26 @@ class Command(BaseCommand): hasattr(article, "summary") and len(article.summary) > 0 ) - else html.strip_tags(article.description) - if ( - hasattr(article, "description") - and len(article.summary) + else ( + html.strip_tags(article.description) + if ( + hasattr(article, "description") + and len(article.summary) + ) + else ( + html.strip_tags(article.content[0].value) + if ( + hasattr(article, "content") + and len(article.content) + ) + else None + ) ) - else html.strip_tags(article.content[0].value)[:200] - if ( - hasattr(article, "content") - and len(article.content) - ) - else "" ) if description: - description += "..." + description[:200] += "..." + else: + description = "" instance = models.Article.objects.create( title=article.title, @@ -168,7 +174,9 @@ class Command(BaseCommand): if newish: instance.announce() blog.set_success( - updateddate=date_to_tz_aware(article.updated_parsed) + updateddate=date_to_tz_aware( + article.updated_parsed + ) ) except Exception as e: @@ -191,7 +199,7 @@ class Command(BaseCommand): | Q(guid=getattr(edition, "id", edition.link)) ).exists(): author_name = getattr(edition, "author", None) or getattr( - edition, "author", None + edition, "author", "" ) description = ( @@ -199,20 +207,26 @@ class Command(BaseCommand): if ( hasattr(edition, "summary") and len(edition.summary) ) - else html.strip_tags(edition.description) - if ( - hasattr(edition, "description") - and len(edition.description) + else ( + html.strip_tags(edition.description) + if ( + hasattr(edition, "description") + and len(edition.description) + ) + else ( + html.strip_tags(edition.content[0].value) + if ( + hasattr(article, "content") + and len(article.content) + ) + else None + ) ) - else html.strip_tags(edition.content[0].value)[:200] + "..." - if ( - hasattr(article, "content") - and len(article.content) - ) - else "" ) if description: - description += "..." + description[:200] += "..." + else: + description = "" instance = models.Edition.objects.create( title=edition.title, -- 2.39.5 From 88d56e5e04fb14e406eb85f83e74823f7a08e7a6 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 24 Jun 2024 12:23:01 +1000 Subject: [PATCH 3/3] formatting --- ausglamr/urls.py | 7 +++++-- blogs/apps.py | 1 + blogs/forms.py | 4 ++-- blogs/views/feeds.py | 8 ++------ blogs/views/public.py | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ausglamr/urls.py b/ausglamr/urls.py index d1953ff..983a951 100644 --- a/ausglamr/urls.py +++ b/ausglamr/urls.py @@ -1,6 +1,7 @@ """ URL configuration for ausglamr project. """ + from django.contrib import admin from django.urls import path, re_path from django.views.generic import TemplateView @@ -65,6 +66,8 @@ urlpatterns = [ views.UnsubscribeEmail.as_view(), name="unsubscribe-email", ), - path('robots.txt', TemplateView.as_view(template_name='robots.txt', - content_type='text/plain')), + path( + "robots.txt", + TemplateView.as_view(template_name="robots.txt", content_type="text/plain"), + ), ] diff --git a/blogs/apps.py b/blogs/apps.py index db6c77b..6b1c2b9 100644 --- a/blogs/apps.py +++ b/blogs/apps.py @@ -1,4 +1,5 @@ """django apps""" + from django.apps import AppConfig diff --git a/blogs/forms.py b/blogs/forms.py index 3369745..bbb52c2 100644 --- a/blogs/forms.py +++ b/blogs/forms.py @@ -141,8 +141,8 @@ class ContactForm(forms.Form): bot_check = forms.CharField( label="What is usually stored in a library?", max_length=10, - help_text="Checking that you are human" - ) + help_text="Checking that you are human", + ) def clean_bot_check(self): """validate the bot check""" diff --git a/blogs/views/feeds.py b/blogs/views/feeds.py index 3c50356..3687b3e 100644 --- a/blogs/views/feeds.py +++ b/blogs/views/feeds.py @@ -94,9 +94,7 @@ class EventFeed(Feed): return ( item.description if hasattr(item, "description") - else item.details - if hasattr(item, "details") - else None + else item.details if hasattr(item, "details") else None ) def item_link(self, item): @@ -215,9 +213,7 @@ class CombinedFeed(Feed): return ( item.description if hasattr(item, "description") - else item.details - if hasattr(item, "details") - else None + else item.details if hasattr(item, "details") else None ) def item_link(self, item): diff --git a/blogs/views/public.py b/blogs/views/public.py index e4bccd8..5ecf1aa 100644 --- a/blogs/views/public.py +++ b/blogs/views/public.py @@ -194,9 +194,9 @@ class RegisterBlog(View): data["blog_info"] = blog_info else: - data[ - "error" - ] = "Could not auto-discover your feed info, please enter manually" + data["error"] = ( + "Could not auto-discover your feed info, please enter manually" + ) return render(request, "blogs/confirm-register.html", data) -- 2.39.5