Merge lp:~widelands-dev/widelands-website/anti_spam_2 into lp:widelands-website

Proposed by kaputtnik
Status: Merged
Merged at revision: 424
Proposed branch: lp:~widelands-dev/widelands-website/anti_spam_2
Merge into: lp:widelands-website
Diff against target: 84 lines (+11/-7)
4 files modified
local_settings.py.sample (+5/-0)
pybb/feeds.py (+5/-4)
pybb/templatetags/pybb_extras.py (+1/-1)
templates/pybb/last_posts.html (+0/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands-website/anti_spam_2
Reviewer Review Type Date Requested Status
SirVer Approve
kaputtnik (community) Needs Resubmitting
Review via email: mp+308074@code.launchpad.net

Description of the change

- Fix Latest Posts box
- No hidden posts in feeds

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

one comment.

review: Needs Fixing
435. By kaputtnik

adjusted pybb_last_posts

Revision history for this message
kaputtnik (franku) wrote :

Yes, thanks for pointing me on this :-)

Sometimes i think too complicated...

review: Needs Resubmitting
Revision history for this message
SirVer (sirver) wrote :

one nit, otherwise lgtm.

review: Approve
Revision history for this message
kaputtnik (franku) wrote :

Thanks, merged and deployed.

Beside the blank line i have also changed the anti_spam lists in local_settings.py.sample to ['spam']. Otherwise they will always come true.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'local_settings.py.sample'
2--- local_settings.py.sample 2016-08-05 18:20:29 +0000
3+++ local_settings.py.sample 2016-10-11 16:44:39 +0000
4@@ -33,6 +33,11 @@
5 # This Backend shows Emails in console
6 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
7
8+# Anti spam keywords
9+# If these are found, the posts/topics in forum get hidden
10+ANTI_SPAM_BODY = ['']
11+ANTI_SPAM_TOPIC = ['']
12+
13 # Uncomment 'LOGGING = {...}' for debugging purposes when you have set DEBUG=False.
14 # Use then in the code:
15
16
17=== modified file 'pybb/feeds.py'
18--- pybb/feeds.py 2016-06-06 18:26:47 +0000
19+++ pybb/feeds.py 2016-10-11 16:44:39 +0000
20@@ -14,6 +14,7 @@
21 return self.one_title % obj.name
22
23 def items(self, obj):
24+
25 if obj == self.all_objects:
26 return obj.order_by('-created')[:15]
27 else:
28@@ -54,10 +55,10 @@
29 title_template = 'pybb/feeds/posts_title.html'
30 description_template = 'pybb/feeds/posts_description.html'
31
32- all_objects = Post.objects
33+ all_objects = Post.objects.filter(hidden=False)
34
35 def items_for_object(self,obj):
36- return Post.objects.filter( topic__forum = obj ).order_by('-created')[:15]
37+ return Post.objects.filter( hidden = False, topic__forum = obj ).order_by('-created')[:15]
38
39 def item_author_name(self, item):
40 """
41@@ -73,10 +74,10 @@
42 title_template = 'pybb/feeds/topics_title.html'
43 description_template = 'pybb/feeds/topics_description.html'
44
45- all_objects = Topic.objects
46+ all_objects = Topic.objects.exclude(posts__hidden = True)
47
48 def items_for_object(self,item):
49- return Topic.objects.filter( forum = item ).order_by('-created')[:15]
50+ return Topic.objects.exclude( posts__hidden = True ).filter( forum = item ).order_by('-created')[:15]
51
52 def item_author_name(self, item):
53 """
54
55=== modified file 'pybb/templatetags/pybb_extras.py'
56--- pybb/templatetags/pybb_extras.py 2016-03-02 21:02:38 +0000
57+++ pybb/templatetags/pybb_extras.py 2016-10-11 16:44:39 +0000
58@@ -79,7 +79,7 @@
59 import time
60 @register.inclusion_tag('pybb/last_posts.html', takes_context=True)
61 def pybb_last_posts(context, number = 5):
62- last_posts = Post.objects.order_by('-created').select_related()[:25]
63+ last_posts = Post.objects.filter(hidden=False).order_by('-created').select_related()[:25]
64 check = []
65 answer = []
66 for post in last_posts:
67
68=== modified file 'templates/pybb/last_posts.html'
69--- templates/pybb/last_posts.html 2016-10-08 09:30:34 +0000
70+++ templates/pybb/last_posts.html 2016-10-11 16:44:39 +0000
71@@ -9,13 +9,11 @@
72 <div class="columnModuleBox">
73 <ul>
74 {% for post in posts %}
75- {% if not post.hidden %}
76 <li>
77 {{ post.topic.forum.name }}<br />
78 <a href="{{ post.get_absolute_url }}" title="{{ post.topic.name }}">{{ post.topic.name|pybb_cut_string:30 }}</a><br />
79 by <a href="{% url 'profile_view' post.user %}">{{post.user.username}}</a> {{ post.created|minutes }} ago
80 </li>
81- {% endif %}
82 {% endfor %}
83 </ul>
84 </div>

Subscribers

People subscribed via source and target branches