Compare commits

..

17 commits
docs ... main

Author SHA1 Message Date
Hugh Rundle 812fc0f2a4 Merge pull request 'fix blog announcements and update tests' (#21) from fixbyline into main
Reviewed-on: #21
2025-02-03 16:32:12 +11:00
Hugh Rundle 8dc69f2a9e
fix blog announcements and update tests
Blog announcements were using the string "None" as the author, now they should not.
Updated tests accordingly.
Fixed email test being captured by bot trap.
2025-02-03 16:26:06 +11:00
Hugh Rundle cda4b61b4b Merge pull request 'Reference parent conference in CFP section of weekly email' (#20) from admin into main
Reviewed-on: #20
2024-11-09 10:02:07 +11:00
Hugh Rundle 56094b9e7e Merge branch 'main' into admin 2024-11-09 10:01:40 +11:00
Hugh Rundle 507d6d3508
close p tag properly 2024-11-09 09:59:57 +11:00
Hugh Rundle 5ce0a679fb
Add event detail to call for papers in weekly email
fixes #18
2024-11-09 09:58:40 +11:00
Hugh Rundle e814c9f981 Merge pull request 'add search in admin models' (#19) from admin into main
Reviewed-on: #19
2024-11-09 09:52:56 +11:00
Hugh Rundle da58002f2f
clean up readme 2024-11-09 09:51:49 +11:00
Hugh Rundle 60451f565a
Merge branch 'main' into admin 2024-11-09 09:50:18 +11:00
Hugh Rundle 2e0bcb1c01
Merge branch 'main' of git.suboptimal.solutions:hugh/ausglamr 2024-11-09 09:49:53 +11:00
Hugh Rundle 16561eba6f
add search to admin screens 2024-11-09 09:44:36 +11:00
Hugh Rundle 9a355ff2a0 Merge pull request 'Bump django from 4.2.11 to 4.2.14' (#16) from dependabot/pip/django-4.2.14 into main
Reviewed-on: #16
2024-07-30 20:28:34 +10:00
Hugh Rundle 1864761a47 Merge branch 'main' into dependabot/pip/django-4.2.14 2024-07-30 20:28:03 +10:00
Hugh Rundle cd42612596 Merge pull request 'update docs and glamr-dev' (#17) from docs into main
Reviewed-on: #17
2024-07-30 20:27:15 +10:00
Hugh Rundle c8fc3b4c45
Merge pull request #17 from hughrun/hughrun-patch-2
Update README.md to point to new repo
2024-07-29 20:08:49 +10:00
Hugh Rundle e8bebca7b4
Update README.md to point to new repo 2024-07-29 20:08:30 +10:00
dependabot[bot] d57c44cc85
Bump django from 4.2.11 to 4.2.14
Bumps [django](https://github.com/django/django) from 4.2.11 to 4.2.14.
- [Commits](https://github.com/django/django/compare/4.2.11...4.2.14)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-10 22:08:59 +00:00
10 changed files with 75 additions and 20 deletions

View file

@ -131,6 +131,7 @@ class Blog(admin.ModelAdmin):
"active",
)
ordering = ["approved", "-suspended", "-failing"]
search_fields = ["title", "author_name", "url"]
actions = [approve, unapprove, suspend, unsuspend, activate, disable]
@ -140,6 +141,7 @@ class Article(admin.ModelAdmin):
date_hierarchy = "pubdate"
list_display = ("title", "blog_title", "pubdate")
search_fields = ["title", "author_name", "blog_title", "url"]
def blog_title(self, obj): # pylint: disable=no-self-use
"""get the title of the parent blog"""
@ -151,6 +153,7 @@ class Tag(admin.ModelAdmin):
"""display settings for tags"""
list_display = ("name",)
search_fields = ["name"]
@admin.register(models.Event)
@ -166,6 +169,7 @@ class Event(admin.ModelAdmin):
"start_date",
)
ordering = ["approved", "announcements"]
search_fields = ["name", "description", "url"]
actions = [approve, unapprove]
@ -176,6 +180,7 @@ class CallForPapers(admin.ModelAdmin):
list_display = ("name", "event", "approved", "closing_date")
list_select_related = ("event",)
ordering = ["approved", "closing_date"]
search_fields = ["event__name", "event__url", "details"]
actions = [approve, unapprove]
@ -185,6 +190,7 @@ class Group(admin.ModelAdmin):
list_display = ("name", "approved", "category", "description")
ordering = ["approved", "name"]
search_fields = ["name", "description", "url"]
actions = [approve, unapprove]
@ -200,6 +206,7 @@ class Newsletter(admin.ModelAdmin):
"active",
)
ordering = ["approved", "-failing"]
search_fields = ["name", "description", "url", "author_name"]
actions = [approve, unapprove, suspend, activate, disable]
@ -209,6 +216,7 @@ class Edition(admin.ModelAdmin):
date_hierarchy = "pubdate"
list_display = ("title", "newsletter_name", "pubdate")
search_fields = ["title", "description", "url", "newsletter__name", "author_name"]
def newsletter_name(self, obj): # pylint: disable=no-self-use
"""get the title of the parent newsletter"""

View file

@ -132,13 +132,9 @@ class Command(BaseCommand):
open_cfps = ""
for instance in cfps:
c_date = instance.closing_date
title_string = (
f"<h4><a href='{instance.event.url}'>{instance.name}</a></h4>"
)
title_string = f"<h4><a href='{instance.event.url}'>{instance.event.name} - {instance.name}</a></h4>"
dates_string = f"<p><strong>Closes:</strong><em>{c_date:%a} {c_date.day} {c_date:%B}</em></p>"
description_string = (
f"<p style='margin-bottom:24px;'>{instance.details}</p>"
)
description_string = f"<p>{instance.details}</p><p style='margin-bottom:24px;'>{instance.event.description}</p>"
string_list = [title_string, dates_string, description_string]
string = "".join(string_list)

View file

@ -79,8 +79,7 @@ class Blog(BlogData):
author = ""
category = Category(self.category).label
status = f"{self.title}{author} has been added to Aus GLAMR! \
\n\nIt's about {category}\n\n{self.url}"
status = f"{self.title}{author} has been added to Aus GLAMR! \n\nIt's about {category}\n\n{self.url}"
Announcement.objects.create(status=status)
self.announced = True

View file

@ -15,10 +15,19 @@ class BlogTestCase(TestCase):
def setUp(self):
"""set up test blog"""
self.blog = models.Blog.objects.create(
title="mya awesome blog",
title="my awesome blog",
url="https://test.com",
feed="https://test.com/feed.xml",
category="LIB",
author_name="Hugh",
)
self.blog_no_author = models.Blog.objects.create(
title="my awesome archives",
url="https://test2.com",
feed="https://test2.com/feed.xml",
category="ARC",
author_name="",
)
def test_get_absolute_url(self):
@ -46,6 +55,22 @@ class BlogTestCase(TestCase):
self.blog.set_failing()
self.assertEqual(self.blog.failing, True)
def test_announce_blog(self):
"""test announcing the blog"""
self.blog.announce()
status = f"my awesome blog by Hugh has been added to Aus GLAMR! \n\nIt's about Libraries\n\nhttps://test.com"
announcement = models.Announcement.objects.first()
self.assertEqual(status, announcement.status)
def test_announce_blog_no_author(self):
"""test announcing the blog with a blank blog author name"""
self.blog_no_author.announce()
status = f"my awesome archives has been added to Aus GLAMR! \n\nIt's about Archives\n\nhttps://test2.com"
announcement = models.Announcement.objects.first()
self.assertEqual(status, announcement.status)
def test_announce_article(self):
"""announcing a blog article"""
@ -59,7 +84,7 @@ class BlogTestCase(TestCase):
)
article.announce()
status = f"My article (Hugh on mya awesome blog)\n\nhttps://example.blog/1"
status = f"My article (Hugh on my awesome blog)\n\nhttps://example.blog/1"
self.assertTrue(models.Announcement.objects.filter(status=status).exists())

View file

@ -70,7 +70,10 @@ class UtilityTests(TestCase):
self.assertEqual(data["description"], "A short summary of my blog")
def test_get_blog_info_no_feed(self):
"""test get blog info"""
"""
test get blog info
note get_blog_info only checks <head>, not rss feed
"""
with open(
pathlib.Path(__file__).parent.joinpath("data/example.html"),
@ -152,7 +155,7 @@ class UtilityTests(TestCase):
data = utilities.get_blog_info("http://test.test")
self.assertEqual(data["title"], "My test website with an RSS feed")
self.assertEqual(data["author_name"], "Hugh Rundle")
self.assertEqual(data["author_name"], "")
self.assertEqual(data["description"], "A short summary of my blog")
def test_get_blog_info_with_incomplete_head_and_partial_feed(self):
@ -171,7 +174,7 @@ class UtilityTests(TestCase):
data = utilities.get_blog_info("http://test.test")
self.assertEqual(data["title"], "My test website with an RSS feed")
self.assertEqual(data["author_name"], None)
self.assertEqual(data["author_name"], "")
self.assertEqual(data["description"], None)
def test_get_webfinger_subscribe_uri(self):

View file

@ -222,6 +222,7 @@ class PublicTests(TestCase):
form.data["from_email"] = "example@example.mail"
form.data["subject"] = "Hello"
form.data["message"] = "Hi there"
form.data["bot_check"] = "books"
request = self.factory.post("contact/", form.data)
request.user = AnonymousUser()
@ -234,6 +235,24 @@ class PublicTests(TestCase):
# Verify that the subject of the first message is correct.
self.assertEqual(mail.outbox[0].subject, "Message via Aus GLAMR: Hello")
def test_contact_from_bot(self):
"""post message"""
view = views.Contact.as_view()
form = forms.ContactForm()
form.data["from_email"] = "example@example.mail"
form.data["subject"] = "Hello"
form.data["message"] = "Hi there"
form.data["bot_check"] = "i am a stupid bot"
request = self.factory.post("contact/", form.data)
request.user = AnonymousUser()
view(request)
# Test that one message has been sent.
self.assertEqual(len(mail.outbox), 0)
def test_search(self):
"""post search query"""

View file

@ -4,6 +4,7 @@ import re
from bs4 import BeautifulSoup
import feedparser
import logging
import requests
from django.conf import settings
@ -65,17 +66,21 @@ def get_blog_info(url):
) # use the title from the feed
blog_info["description"] = description or blog_info.get("description", "")
blog_info["author_name"] = blog_info.get("author", author)
else:
return False # if there is no feed info we need to put the onus back on the user to fill in the data
normalised_author = ""
if author:
normalised_author = author.replace("(noreply@blogger.com)", "")
normalised_author = blog_info["author_name"] or None
if normalised_author:
normalised_author = normalised_author.replace("(noreply@blogger.com)", "")
if normalised_author.strip() == "Unknown":
normalised_author = ""
blog_info["author_name"] = normalised_author
else:
normalised_author = ""
blog_info["author_name"] = normalised_author
return blog_info

View file

@ -77,7 +77,7 @@ case "$CMD" in
runweb python manage.py send_weekly_email
;;
test)
runweb python manage.py test "$@"
runweb python manage.py test blogs/tests "$@"
;;
*)
set +x

View file

@ -1,6 +1,6 @@
beautifulsoup4==4.12.2
gunicorn==22.0.0
Django==4.2.11
Django==4.2.14
environs==9.5.0
feedparser==6.0.10
psycopg2==2.9.5