From 80874ac98c76d504e5bfd36cfd8b9476b94c8081 Mon Sep 17 00:00:00 2001 From: Bobby <30593201+luciferreeves@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:08:33 +0000 Subject: test spam c --- .github/workflows/main.yml | 3 --- blog/recommender.py | 3 +++ blog/views.py | 2 +- templates/blog/post.html | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30508f4c..064a6ffe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,4 @@ jobs: port: ${{ secrets.PORT }} script: | grep -qxF 'GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}' /home/ubuntu/.shifooenv || echo 'GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}' >> /home/ubuntu/.shifooenv - # Print the environment variables - test purpose - cat /home/ubuntu/.shifooenv - echo "Deploying the code" sh /home/ubuntu/deploy.sh diff --git a/blog/recommender.py b/blog/recommender.py index e08a2c2b..280fa4b0 100644 --- a/blog/recommender.py +++ b/blog/recommender.py @@ -14,6 +14,9 @@ def next_read(post): current_post = Post.objects.get(id=post.id) posts = Post.objects.filter(is_public=True).exclude(id=current_post.id) + if len(posts) < 2: + return None + # Our method is very simple. First we compare the bodies of the posts to # find the similarity between them. Then we sort the posts based on their # similarity and return the post with the highest similarity. diff --git a/blog/views.py b/blog/views.py index a05dc325..f7fec1b4 100644 --- a/blog/views.py +++ b/blog/views.py @@ -227,7 +227,7 @@ def comment(request, slug): r_spam = check_spam(comment=request.POST.get('body')) if r_spam != 'N': messages.error(request, r_spam, extra_tags='spam') - return redirect(reverse('blog:post', kwargs={'slug': slug}) + '#comment-' + str(comment.id)) + return redirect(reverse('blog:post', kwargs={'slug': slug}) + '#new-comment') # then we continue post = Post.objects.get(slug=slug) diff --git a/templates/blog/post.html b/templates/blog/post.html index 5c02ce2b..8da852a4 100644 --- a/templates/blog/post.html +++ b/templates/blog/post.html @@ -183,8 +183,7 @@ background: #ffffff0d; {% if messages %} {% for message in messages %} {% if 'spam' in message.tags %} -

Your comment was not allowed as it was marked as possible spam. If you think this is a mistake, please contact me at webmaster@thatcomputerscientist.com.

-

{{ message }}

+

Your comment was not allowed as it was marked as possible spam. If you think this is a mistake, please contact me at webmaster@thatcomputerscientist.com.

{% endif %} {% endfor %} {% endif %} -- cgit v1.2.3