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

Proposed by kaputtnik
Status: Merged
Merged at revision: 521
Proposed branch: lp:~widelands-dev/widelands-website/pybb_cleanup
Merge into: lp:widelands-website
Diff against target: 1383 lines (+209/-766)
22 files modified
mainpage/templates/mainpage/forum_navigation.html (+3/-1)
pybb/admin.py (+11/-6)
pybb/forms.py (+1/-12)
pybb/migrations/0005_auto_20181221_1047.py (+30/-0)
pybb/models.py (+1/-45)
pybb/settings.py (+1/-10)
pybb/signals.py (+1/-1)
pybb/static/css/forum.css (+10/-1)
pybb/templates/pybb/category.html (+2/-2)
pybb/templates/pybb/forum.html (+10/-10)
pybb/templates/pybb/index.html (+2/-2)
pybb/templates/pybb/inlines/display_category.html (+39/-30)
pybb/templates/pybb/inlines/post.html (+70/-108)
pybb/templates/pybb/inlines/topic_row.html (+0/-43)
pybb/templates/pybb/pagination.html (+0/-41)
pybb/templates/pybb/topic.html (+16/-174)
pybb/templatetags/pybb_extras.py (+3/-167)
pybb/urls.py (+0/-1)
pybb/util.py (+0/-63)
pybb/views.py (+8/-45)
settings.py (+1/-1)
wlprofile/models.py (+0/-3)
To merge this branch: bzr merge lp:~widelands-dev/widelands-website/pybb_cleanup
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+363742@code.launchpad.net

Description of the change

A big cleanup on pybb:

- removed model pybb Privatemessage and all related functions since we use Django Messages
- removed field moderators from pybb Forum, since we use django Group for this
- removed other unused functions
- removed pybb pagination and related functions since we use dj_pagination for that
- removed option PYBB_FREEZE_FIRST_POST. This was meant to show the first post of a topic on each sub page. We never used this and i never saw this in other forums.
- removed some templates which were not used

Additional changes:
- added table headers 'Forum' and 'Last Post on Topic' to forum categories
- added table headers 'Forum' and 'Last Post' to topics overview
- changed appearance of the link to last post in topics overview (see https://bugs.launchpad.net/widelands-website/+bug/1762164/comments/9)
- changed the admin site for pybb topics: Instead showing the topic subscribers, the related posts of a topic are shown
- it is now possible to search for a topics name in the admin page for pybb post

To get this in:
make a database backup
merge the branch
run python manage.py migrate
run python mangage.py collectstatic -l
restart wlwebsite

After success, check the database: The table pybb_privatemessage may has to be removed by hand

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

Looks good to me. Can you spin up the alpha site for some testing?

Revision history for this message
kaputtnik (franku) wrote :

alpha is up :-)

531. By kaputtnik

removed test string in topics header

Revision history for this message
GunChleoc (gunchleoc) wrote :

Super. Folgendes fiel mir beim Testen auf:

- Die Forumsicons sind klein und oval statt groß und rund.
  Die Topic-Icons sind zwar rund, aber auch kleiner als vorher.

- Die Vorschau auf neue Posts hat Markdown mit drun - gibt es einen strip-Befehl in Django dafür?

Ansonsten funzt alles :)

532. By kaputtnik

fixed icon sizes for unread posts; removed inline style defs

Revision history for this message
kaputtnik (franku) wrote :

Die icons sollten gefixt sein. Evtll musst Du die Seite neu laden.

> - Die Vorschau auf neue Posts hat Markdown mit drun - gibt es einen strip-Befehl in Django dafür?

Ich verstehe nicht ganz was du mit Vorschau meinst. Die emails? Das ließe sich leicht ändern: Posts werden in drei Versionen gespeichert, siehe zb:

http://alpha.widelands.org/admin/pybb/post/79/change/

Wir könnten die reine Text version verwenden. Die html version würde ich nicht nehmen, da ein böser mensch evtll. einen post mit schädlichem content verfassen könnte, der dann in deinem E-Mailprogramm landet. Aber damit kenne ich mich nicht aus. Ich frage mal janus.

Das würde ich aber lieber in einem anderen branch machen.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Icons sind jetzt OK.

Vorschau ist das hier: https://launchpadlibrarian.net/413400282/vorschau.png

Revision history for this message
kaputtnik (franku) wrote :

Ah, ok will look into it.

533. By kaputtnik

use body_text for display

Revision history for this message
kaputtnik (franku) wrote :

Updated alpha. Just using the text version now.

Can you look again to it?

Thanks :-)

Revision history for this message
GunChleoc (gunchleoc) wrote :

Perfect - ship it! :)

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

Thanks :-)

Will do it in the evening.

Revision history for this message
kaputtnik (franku) wrote :

Merged and deployed.

Revision history for this message
kaputtnik (franku) wrote :

One may need to reload the page (STRG +F5)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mainpage/templates/mainpage/forum_navigation.html'
2--- mainpage/templates/mainpage/forum_navigation.html 2018-12-12 13:46:48 +0000
3+++ mainpage/templates/mainpage/forum_navigation.html 2019-03-02 13:44:23 +0000
4@@ -8,7 +8,9 @@
5 <a href="{% url 'pybb_forum' forum.id %}" style="color: rgba(254, 234, 138, 1);">{{ forum.name }}</a>
6 </li>
7 {% else %}
8- <li><a href="{% url 'pybb_forum' forum.id %}">{{ forum.name }}</a></li>
9+ <li>
10+ <a href="{% url 'pybb_forum' forum.id %}">{{ forum.name }}</a>
11+ </li>
12 {% endif %}
13 {% endfor %}
14 </ul>
15
16=== modified file 'pybb/admin.py'
17--- pybb/admin.py 2018-12-11 13:01:59 +0000
18+++ pybb/admin.py 2019-03-02 13:44:23 +0000
19@@ -44,13 +44,18 @@
20 (_('Additional options'), {
21 'description': 'Position is the position inside the category. \
22 This has effect on ordering in forums overview and the navigation bar.',
23- 'fields': ('position', 'description', 'moderators')
24+ 'fields': ('position', 'description')
25 }
26 ),
27 )
28-
29-class SubscribersInline(admin.TabularInline):
30- model = Topic.subscribers.through
31+
32+
33+class PostInline(admin.TabularInline):
34+ model = Post
35+ readonly_fields = ('user', 'markup', 'created',)
36+ exclude = ('created', 'updated', 'body',)
37+ ordering = ('-created',)
38+
39
40 class TopicAdmin(admin.ModelAdmin):
41 list_display = ['name', 'forum', 'created', 'head', 'is_hidden']
42@@ -58,6 +63,7 @@
43 ordering = ['-created']
44 date_hierarchy = 'created'
45 search_fields = ['name']
46+ inlines = [PostInline,]
47 fieldsets = (
48 (None, {
49 'fields': ('forum', 'name', 'user', ('created', 'updated'))
50@@ -67,7 +73,6 @@
51 'fields': (('views',), ('sticky', 'closed'),)
52 }),
53 )
54- inlines = [ SubscribersInline, ]
55
56
57 class PostAdmin(admin.ModelAdmin):
58@@ -75,7 +80,7 @@
59 list_per_page = 20
60 ordering = ['-created']
61 date_hierarchy = 'created'
62- search_fields = ['body']
63+ search_fields = ['body', 'topic__name']
64 actions = [delete_selected, unhide_post]
65 fieldsets = (
66 (None, {
67
68=== modified file 'pybb/forms.py'
69--- pybb/forms.py 2018-10-03 09:01:09 +0000
70+++ pybb/forms.py 2019-03-02 13:44:23 +0000
71@@ -7,7 +7,7 @@
72 from django.utils.translation import ugettext as _
73 from django.contrib.auth.models import User
74
75-from pybb.models import Topic, Post, PrivateMessage, Attachment
76+from pybb.models import Topic, Post, Attachment
77 from pybb import settings as pybb_settings
78 from django.conf import settings
79
80@@ -87,14 +87,3 @@
81 post.updated = datetime.now()
82 post.save(*args, **kwargs)
83 return post
84-
85-
86-class UserSearchForm(forms.Form):
87- query = forms.CharField(required=False, label='')
88-
89- def filter(self, qs):
90- if self.is_valid():
91- query = self.cleaned_data['query']
92- return qs.filter(username__contains=query)
93- else:
94- return qs
95
96=== added file 'pybb/migrations/0005_auto_20181221_1047.py'
97--- pybb/migrations/0005_auto_20181221_1047.py 1970-01-01 00:00:00 +0000
98+++ pybb/migrations/0005_auto_20181221_1047.py 2019-03-02 13:44:23 +0000
99@@ -0,0 +1,30 @@
100+# -*- coding: utf-8 -*-
101+# Generated by Django 1.11.12 on 2018-12-21 10:47
102+from __future__ import unicode_literals
103+
104+from django.db import migrations
105+
106+
107+class Migration(migrations.Migration):
108+
109+ dependencies = [
110+ ('pybb', '0004_auto_20181209_1334'),
111+ ]
112+
113+ operations = [
114+ migrations.RemoveField(
115+ model_name='privatemessage',
116+ name='dst_user',
117+ ),
118+ migrations.RemoveField(
119+ model_name='privatemessage',
120+ name='src_user',
121+ ),
122+ migrations.RemoveField(
123+ model_name='forum',
124+ name='moderators',
125+ ),
126+ migrations.DeleteModel(
127+ name='PrivateMessage',
128+ ),
129+ ]
130
131=== modified file 'pybb/models.py'
132--- pybb/models.py 2018-12-18 18:42:06 +0000
133+++ pybb/models.py 2019-03-02 13:44:23 +0000
134@@ -12,7 +12,7 @@
135 from django.conf import settings
136
137 from pybb.markups import mypostmarkup
138-from pybb.util import urlize, memoize_method, unescape
139+from pybb.util import urlize, unescape
140 from pybb import settings as pybb_settings
141
142 from django.conf import settings
143@@ -85,8 +85,6 @@
144 name = models.CharField(_('Name'), max_length=80)
145 position = models.IntegerField(_('Position'), blank=True, default=0)
146 description = models.TextField(_('Description'), blank=True, default='')
147- moderators = models.ManyToManyField(
148- User, blank=True, verbose_name=_('Moderators'))
149 updated = models.DateTimeField(_('Updated'), null=True)
150 moderator_group = models.ForeignKey(
151 Group,
152@@ -361,48 +359,6 @@
153 return u'T[%d], U[%d]: %s' % (self.topic.id, self.user.id, unicode(self.time))
154
155
156-class PrivateMessage(RenderableItem):
157-
158- dst_user = models.ForeignKey(User, verbose_name=_(
159- 'Recipient'), related_name='dst_users')
160- src_user = models.ForeignKey(User, verbose_name=_(
161- 'Author'), related_name='src_users')
162- read = models.BooleanField(_('Read'), blank=True, default=False)
163- created = models.DateTimeField(_('Created'), blank=True)
164- markup = models.CharField(_('Markup'), max_length=15,
165- default=pybb_settings.DEFAULT_MARKUP, choices=MARKUP_CHOICES)
166- subject = models.CharField(_('Subject'), max_length=255)
167- body = models.TextField(_('Message'))
168- body_html = models.TextField(_('HTML version'))
169- body_text = models.TextField(_('Text version'))
170-
171- class Meta:
172- ordering = ['-created']
173- verbose_name = _('Private message')
174- verbose_name_plural = _('Private messages')
175-
176- # TODO: summary and part of the save method is the same as in the Post model
177- # move to common functions
178- def summary(self):
179- LIMIT = 50
180- tail = len(self.body) > LIMIT and '...' or ''
181- return self.body[:LIMIT] + tail
182-
183- def __unicode__(self):
184- return self.subject
185-
186- def save(self, *args, **kwargs):
187- if self.created is None:
188- self.created = datetime.now()
189- self.render()
190-
191- new = self.id is None
192- super(PrivateMessage, self).save(*args, **kwargs)
193-
194- def get_absolute_url(self):
195- return reverse('pybb_show_pm', args=[self.id])
196-
197-
198 class Attachment(models.Model):
199 post = models.ForeignKey(Post, verbose_name=_(
200 'Post'), related_name='attachments')
201
202=== modified file 'pybb/settings.py'
203--- pybb/settings.py 2016-12-13 18:28:51 +0000
204+++ pybb/settings.py 2019-03-02 13:44:23 +0000
205@@ -6,27 +6,18 @@
206
207 TOPIC_PAGE_SIZE = get('PYBB_TOPIC_PAGE_SIZE', 10)
208 FORUM_PAGE_SIZE = get('PYBB_FORUM_PAGE_SIZE', 20)
209-USERS_PAGE_SIZE = get('PYBB_USERS_PAGE_SIZE', 20)
210 AVATARS_UPLOAD_TO = get('PYBB_AVATARS_UPLOAD_TO', 'pybb/avatars')
211 AVATAR_WIDTH = get('PYBB_AVATAR_WIDTH', 60)
212 AVATAR_HEIGHT = get('PYBB_AVATAR_HEIGHT', 60)
213 DEFAULT_TIME_ZONE = get('PYBB_DEFAULT_TIME_ZONE', 3)
214 SIGNATURE_MAX_LENGTH = get('PYBB_SIGNATURE_MAX_LENGTH', 1024)
215 SIGNATURE_MAX_LINES = get('PYBB_SIGNATURE_MAX_LINES', 3)
216-QUICK_TOPICS_NUMBER = get('PYBB_QUICK_TOPICS_NUMBER', 10)
217-QUICK_POSTS_NUMBER = get('PYBB_QUICK_POSTS_NUMBER', 10)
218 READ_TIMEOUT = get('PYBB_READ_TIMEOUT', 3600 * 24 * 7)
219-HEADER = get('PYBB_HEADER', 'PYBB')
220-TAGLINE = get('PYBB_TAGLINE', 'Django based forum engine')
221 DEFAULT_MARKUP = get('PYBB_DEFAULT_MARKUP', 'bbcode')
222-NOTICE = get('PYBB_NOTICE', '')
223-HOST = get('PYBB_HOST', 'localhost:8000')
224-FREEZE_FIRST_POST = get('PYBB_FREEZE_FIRST_POST', True)
225-ADMIN_URL = get('PYBB_ADMIN_URL', '/admin/')
226-EMAIL_DEBUG = get('PYBB_EMAIL_DEBUG', False)
227 ATTACHMENT_UPLOAD_TO = get('PYBB_ATTACHMENT_UPLOAD_TO', 'pybb/attachments')
228 ATTACHMENT_SIZE_LIMIT = get('PYBB_ATTACHMENT_SIZE_LIMIT', 1024 * 1024)
229 ATTACHMENT_ENABLE = get('PYBB_ATTACHMENT_ENABLE', True)
230+INTERNAL_PERM = get('INTERNAL_PERM', 'pybb.can_access_internal')
231
232 # That is used internally
233 DISABLE_NOTIFICATION = False
234
235=== modified file 'pybb/signals.py'
236--- pybb/signals.py 2016-12-13 18:28:51 +0000
237+++ pybb/signals.py 2019-03-02 13:44:23 +0000
238@@ -1,7 +1,7 @@
239 from django.db.models.signals import post_save
240 from django.contrib.auth.models import User
241
242-from pybb.models import Post, PrivateMessage
243+from pybb.models import Post
244
245
246 def post_saved(instance, **kwargs):
247
248=== modified file 'pybb/static/css/forum.css'
249--- pybb/static/css/forum.css 2018-11-22 17:50:41 +0000
250+++ pybb/static/css/forum.css 2019-03-02 13:44:23 +0000
251@@ -25,6 +25,10 @@
252 border: none;
253 }
254
255+.forum th {
256+ font-weight: normal;
257+}
258+
259 .forum td {
260 vertical-align: middle;
261 padding: 8px;
262@@ -35,11 +39,16 @@
263 /********************/
264
265 .forumIcon {
266- width: 50px;
267+ width: 64px;
268+}
269+
270+.forumIcon img {
271+ padding: 0px;
272 }
273
274 .forumTitle {
275 width: 40%;
276+ text-align: left;
277 }
278
279 .forumCount {
280
281=== modified file 'pybb/templates/pybb/category.html'
282--- pybb/templates/pybb/category.html 2018-11-22 11:08:51 +0000
283+++ pybb/templates/pybb/category.html 2019-03-02 13:44:23 +0000
284@@ -14,9 +14,9 @@
285 </div>
286
287 <div class="center green">
288- <img src="{% static 'forum/img/folder_big_work_star.png' %}" style="width: 48px; height:48px; margin: 0px;" alt="" class="middle" />
289+ <img src="{% static 'forum/img/folder_big_work_star.png' %}" alt="Has unread posts" class="middle" />
290 = Unread posts
291- <img src="{% static 'forum/img/folder_big_work.png' %}" style="width: 48px; height:48px; margin: 0px;" alt="" class="middle" />
292+ <img src="{% static 'forum/img/folder_big_work.png' %}" alt="Hasn't unread posts" class="middle" />
293 = No unread posts
294 </div>
295 {% endblock %}
296
297=== modified file 'pybb/templates/pybb/forum.html'
298--- pybb/templates/pybb/forum.html 2018-12-10 16:37:12 +0000
299+++ pybb/templates/pybb/forum.html 2019-03-02 13:44:23 +0000
300@@ -43,21 +43,21 @@
301 <table class="forum">
302 <thead>
303 <tr>
304- <td class="forumIcon"></td>
305- <td class="forumTitle small">Title</td>
306- <td class="forumCount"></td>
307- <td class="lastPost small">Last Post by</td>
308+ <th class="forumIcon"></th>
309+ <th class="forumTitle small">Topic</th>
310+ <th class="forumCount"></th>
311+ <th class="lastPost small">Last Post</th>
312 </tr>
313 </thead>
314 <tbody>
315 {% for topic in object_list %}
316 <tr class="{% cycle 'odd' 'even' %}">
317 {% if not topic.is_hidden %}
318- <td class="forumIcon center">
319+ <td class="center">
320 {% if topic|pybb_has_unreads:user %}
321- <img src="{% static 'forum/img/doc_big_work_star.png' %}" style="margin: 0px;" alt="" class="middle" />
322+ <img src="{% static 'forum/img/doc_big_work_star.png' %}" alt="Has unread posts" class="middle" />
323 {% else %}
324- <img src="{% static 'forum/img/doc_big_work.png' %}" style="margin: 0px;" alt="" class="middle" />
325+ <img src="{% static 'forum/img/doc_big_work.png' %}" alt="Hasn't unread posts" class="middle" />
326 {% endif %}
327 </td>
328 <td class="forumTitle">
329@@ -71,9 +71,9 @@
330 Views: {{ topic.views }}
331 </td>
332 <td class="lastPost">
333- {%if topic.last_post %}
334- {{ topic.last_post.user|user_link }} <a href="{{ topic.last_post.get_absolute_url }}">&#187;</a><br />
335- <span class="small">on {{ topic.last_post.created|custom_date:user }}</span>
336+ {% if topic.last_post %}
337+ <a href="{{ topic.last_post.get_absolute_url }}">{{ topic.last_post.body_text|truncatechars:30 }}</a><br />
338+ <span class="small">by {{ topic.last_post.user|user_link }} on {{ topic.last_post.created|custom_date:user }}</span>
339 {% endif %}
340 </td>
341 {% elif user_is_mod %}
342
343=== modified file 'pybb/templates/pybb/index.html'
344--- pybb/templates/pybb/index.html 2018-11-22 11:08:51 +0000
345+++ pybb/templates/pybb/index.html 2019-03-02 13:44:23 +0000
346@@ -15,9 +15,9 @@
347 {% endfor %}
348
349 <div class="center green">
350- <img src="{% static 'forum/img/folder_big_work_star.png' %}" style="width: 48px; height:48px; margin: 0px;" alt="" class="middle" />
351+ <img src="{% static 'forum/img/folder_big_work_star.png' %}" alt="Has unread posts" class="middle" />
352 = Unread posts
353- <img src="{% static 'forum/img/folder_big_work.png' %}" style="width: 48px; height:48px; margin: 0px;" alt="" class="middle" />
354+ <img src="{% static 'forum/img/folder_big_work.png' %}" alt="Hasn't unread posts" class="middle" />
355 = No unread posts
356 </div>
357
358
359=== modified file 'pybb/templates/pybb/inlines/display_category.html'
360--- pybb/templates/pybb/inlines/display_category.html 2018-11-28 19:44:44 +0000
361+++ pybb/templates/pybb/inlines/display_category.html 2019-03-02 13:44:23 +0000
362@@ -12,35 +12,44 @@
363
364 <table class="forum">
365 {# List all forums #}
366- {% for forum in category.forums.all %}
367- <tr class="{% cycle 'odd' 'even' %}">
368- <td class="forumIcon center">
369- {% if forum|pybb_has_unreads:user %}
370- <img src="{% static 'forum/img/folder_big_work_star.png' %}" style="width: 48px; height:48px; margin: 0px;" alt="" />
371- {% else %}
372- <img src="{% static 'forum/img/folder_big_work.png' %}" style="width: 48px; height:48px; margin: 0px;" alt="" />
373- {% endif %}
374- </td>
375- <td class="forumTitle">
376- <a href="{{ forum.get_absolute_url }}">{{ forum.name }}</a>
377- <br />
378- <span class="small">{{ forum.description }}</span>
379- </td>
380- <td class="forumCount center small" style="width: 120px;">
381- Topics: {{ forum.topics.count }}<br/>
382- Posts: {{ forum.posts.count }}
383- </td>
384- <td class="lastPost">
385- {% if forum.last_post %}
386- {% with last_post=forum.last_post %}
387- <a href="{{last_post.get_absolute_url}}">{{ last_post.topic.name }}</a><br />
388- <span class="small">by {{ last_post.user|user_link }}<br />
389- on {{ last_post.created|custom_date:user}}</span>
390- {% endwith %}
391- {% else %}
392- &nbsp;
393- {% endif %}
394- </td>
395- </tr>
396+ <thead>
397+ <tr>
398+ <th class="forumIcon"></th>
399+ <th class="forumTitle small">Forum</th>
400+ <th class="forumCount"></th>
401+ <th class="lastPost small">Last Post on Topic</th>
402+ </tr>
403+ </thead>
404+ <tbody>
405+ {% for forum in category.forums.all %}
406+ <tr class="{% cycle 'odd' 'even' %}">
407+ <td class="center">
408+ {% if forum|pybb_has_unreads:user %}
409+ <img src="{% static 'forum/img/folder_big_work_star.png' %}" alt="Has unread posts" />
410+ {% else %}
411+ <img src="{% static 'forum/img/folder_big_work.png' %}" alt="Hasn't unread posts" />
412+ {% endif %}
413+ </td>
414+ <td class="forumTitle">
415+ <a href="{{ forum.get_absolute_url }}">{{ forum.name }}</a>
416+ <br />
417+ <span class="small">{{ forum.description }}</span>
418+ </td>
419+ <td class="forumCount center small" style="width: 120px;">
420+ Topics: {{ forum.topics.count }}<br/>
421+ Posts: {{ forum.posts.count }}
422+ </td>
423+ <td class="lastPost">
424+ {% if forum.last_post %}
425+ {% with last_post=forum.last_post %}
426+ <a href="{{last_post.get_absolute_url}}">{{ last_post.topic.name|truncatechars:30 }}</a><br />
427+ <span class="small">by {{ last_post.user|user_link }} on {{ last_post.created|custom_date:user}}</span>
428+ {% endwith %}
429+ {% else %}
430+ &nbsp;
431+ {% endif %}
432+ </td>
433+ </tr>
434 {% endfor %}
435+ </tbody>
436 </table>
437
438=== modified file 'pybb/templates/pybb/inlines/post.html'
439--- pybb/templates/pybb/inlines/post.html 2018-12-10 16:37:12 +0000
440+++ pybb/templates/pybb/inlines/post.html 2019-03-02 13:44:23 +0000
441@@ -3,115 +3,77 @@
442 {% endcomment %}
443
444 {% load i18n %}
445-{% load humanize %}
446 {% load pybb_extras %}
447-{% load wiki_extras %}
448 {% load wlprofile_extras %}
449 {% load custom_date %}
450 {% load static %}
451- <a name="post-{{ post.id }}"></a>
452- <table class="{% cycle "odd" "even" %}" width="100%">
453- <tr>
454- <td class="author">{{ post.user|user_link }}</td>
455- <td width="85%" class="at">
456- <table width="100%" cellpadding="0" cellspacing="0" style="table-layout: fixed; border: 0px;">
457- <tr>
458- <td style="text-align: left; border: 0px;">
459- <a href="{{post.get_absolute_url}}">
460- <img src="{% static 'forum/img/en/permalink.png' %}" height="25" alt ="{% trans "Permalink" %}" />
461- </a>
462- </td>
463- <td style="text-align: right; border: 0px;">
464- <strong>Posted at:</strong> {{ post.created|custom_date:user}}
465- </td>
466- </tr>
467- </table>
468- </td>
469- </tr>
470- <tr>
471- <td class="userinfo">
472- <div class="userinfo">
473- {% if post.user.wlprofile.avatar %}
474- <div class="avatar">
475- <a href="{% url 'profile_view' post.user %}">
476- <img src="{{ post.user.wlprofile.avatar.url }}" alt="Avatar" />
477- </a>
478- </div>
479- {% endif %}
480- <strong>Joined:</strong> {{ post.user.date_joined|custom_date:user|title }}<br />
481- <strong>Posts:</strong> {{ post.user.wlprofile.post_count }}<br />
482- <img src="{% static 'img/{{ post.user.wlprofile.user_status.image }}" alt="Ranking" />
483- <br />
484- <strong>{{ post.user.wlprofile.user_status.text }}</strong><br />
485- {% if post.user.wlprofile.location %}
486- <strong>Location:</strong> {{ post.user.wlprofile.location }}<br />
487- {% endif %}
488- </div>
489- </td>
490- <td width="85%" class="content top">
491- {{ post.body_html|safe }}
492- {% if user.is_authenticated %}
493- {% ifequal user.wlprofile.show_signatures 1 %}
494- {% if post.user.wlprofile.signature %}
495- <div class="signature">
496- <span class="line">__________________</span>
497- {{ post.user.wlprofile.signature|urlize|linebreaks }}
498- </div>
499- {% endif %}
500- {% endifequal %}
501- {% else %}
502- {% if post.user.wlprofile.signature %}
503- <div class="signature">
504- <span class="line">__________________</span>
505- {{ post.user.wlprofile.signature|urlize|linebreaks }}
506- </div>
507- {% endif %}
508- {% endif %}
509- {% if post.updated %}
510- <div class="updated-message"><strong>{% trans "Edited" %}:</strong> {{ post.updated|custom_date:user|title}}</div>
511- {% endif %}
512-
513- {% if post.attachment_cache %}
514- {% for attach in post.attachment_cache %}
515- {% trans "Attachment" %}: <a href="{{ attach.get_absolute_url }}">{{ attach.name }}</a> ({{ attach.size_display }})
516- {% endfor %}
517- {% endif %}
518- </td>
519- </tr>
520- <tr>
521- <td class="toplink">
522- <a href="#top">
523- <img src="{% static 'forum/img/en/top.png' %}" height="25" alt ="{% trans "Top" %}" />
524- </a>
525- </td>
526-
527- <td>
528- <div class="tools" style="float: left;">
529- {% if user.is_authenticated %}
530- {% ifnotequal user post.user %}
531- <a href="{% url 'messages_compose_to' post.user %}">
532- <img src="{% static 'forum/img/en/send_pm.png' %}" height="25" alt ="{% trans "Send PM" %}" />
533- </a>
534- {% endifnotequal %}
535- {% endif %}
536- {% if user_is_mod or post|pybb_posted_by:user %}
537- <a href="{% url 'pybb_edit_post' post.id %}">
538- <img src="{% static 'forum/img/en/edit.png' %}" height="25" alt ="{% trans "Edit" %}" />
539- </a>
540- {% endif %}
541- {% if user_is_mod or post|pybb_equal_to:last_post %}
542- {% if user_is_mod or post.user|pybb_equal_to:user %}
543- <a href="{% url 'pybb_delete_post' post.id %}">
544- <img src="{% static 'forum/img/en/delete.png' %}" height="25" alt ="{% trans "Delete" %}" />
545- </a>
546- {% endif %}
547- </div>
548- <div class="tools" style="float: right;">
549- <a href="{% url 'pybb_add_post' topic.id %}?quote_id={{ post.id }}">
550- <img src="{% static 'forum/img/en/quote.png' %}" height="25" alt ="{% trans "Quote" %}" />
551- </a>
552- {% endif %}
553- </div>
554- </td>
555- </tr>
556- </table>
557+
558+<td class="author">
559+ {{ post.user|user_link }}<br />
560+ {% if post.user.wlprofile.avatar %}
561+ <a href="{% url 'profile_view' post.user %}">
562+ <img src="{{ post.user.wlprofile.avatar.url }}" alt="Avatar" />
563+ </a>
564+ {% endif %}
565+ <div class="authorStats">
566+ <strong>Joined:</strong> {{ post.user.date_joined|custom_date:user|title }}<br />
567+ <strong>Posts:</strong> {{ post.user.wlprofile.post_count }}<br />
568+ <img src="{% static 'img/'%}{{ post.user.wlprofile.user_status.image }}" alt="Ranking" /><br />
569+ <strong>{{ post.user.wlprofile.user_status.text }}</strong><br />
570+ {% if post.user.wlprofile.location %}
571+ <strong>Location:</strong> {{ post.user.wlprofile.location }}<br />
572+ {% endif %}
573+ </div>
574+</td>
575+<td class="post">
576+ <a id="post-{{ post.id }}" href="{{post.get_absolute_url}}" title="{% trans "Permalink" %}" class="posRight small permalink">&nbsp;</a>
577+ <span class="small">Posted at: {{ post.created|custom_date:user}}</span>
578+ <hr />
579+ <div class="post">
580+ {{ post.body_html|safe }}
581+ </div>
582+
583+ {% if post.attachment_cache %}
584+ {% for attach in post.attachment_cache %}
585+ {% trans "Attachment" %}: <a href="{{ attach.get_absolute_url }}">{{ attach.name }}</a> ({{ attach.size_display }})
586+ {% endfor %}
587+ {% endif %}
588+
589+ {% if post.updated %}
590+ <span class="small">{% trans "Edited" %}: {{ post.updated|custom_date:user|title}}</span>
591+ {% endif %}
592+ <hr />
593+ {% if user.is_authenticated %}
594+ {% ifequal user.wlprofile.show_signatures 1 %}
595+ {% if post.user.wlprofile.signature %}
596+ {{ post.user.wlprofile.signature|urlize|linebreaks }}
597+ {% endif %}
598+ {% endifequal %}
599+ {% else %}
600+ {% if post.user.wlprofile.signature %}
601+ {{ post.user.wlprofile.signature|urlize|linebreaks }}
602+ {% endif %}
603+ {% endif %}
604+
605+ <a class="button posRight" href="#top">
606+ <img src="{% static 'forum/img/top.png' %}" alt ="" class="middle" />
607+ <span class="middle">{% trans "Top" %}</span>
608+ </a>
609+
610+ <a class="button" href="{% url 'pybb_add_post' topic.id %}?quote_id={{ post.id }}">
611+ <img src="{% static 'forum/img/quote.png' %}" alt ="" class="middle" />
612+ <span class="middle">{% trans "Quote" %}</span>
613+ </a>
614+ {% if user_is_mod or post|pybb_posted_by:user %}
615+ <a class="button" href="{% url 'pybb_edit_post' post.id %}">
616+ <img src="{% static 'forum/img/edit.png' %}" alt ="" class="middle" />
617+ <span class="middle">{% trans "Edit" %}</span>
618+ </a>
619+ {% if user_is_mod or post|pybb_equal_to:last_post %}
620+ <a class="button" href="{% url 'pybb_delete_post' post.id %}">
621+ <img src="{% static 'forum/img/delete.png' %}" alt ="" class="middle" />
622+ <span class="middle">{% trans "Delete" %}</span>
623+ </a>
624+ {% endif %}
625+ {% endif %}
626+</td>
627
628=== removed file 'pybb/templates/pybb/inlines/topic_row.html'
629--- pybb/templates/pybb/inlines/topic_row.html 2018-11-22 11:08:51 +0000
630+++ pybb/templates/pybb/inlines/topic_row.html 1970-01-01 00:00:00 +0000
631@@ -1,43 +0,0 @@
632-{% comment %}
633- vim:ft=htmldjango:
634-{% endcomment %}
635-{% load humanize %}
636-{% load pybb_extras %}
637-{% load wlprofile_extras %}
638-{% load custom_date %}
639-{% load static %}
640-
641- <tr class="topic_description {% cycle "odd" "even" %}">
642- <td align="center" valign="middle">
643- {% if topic|pybb_has_unreads:user %}
644- <img src="{% static 'forum/img/folder_new.png' %}" style="margin: 0px;" alt="" align="middle" />
645- {% else %}
646- <img src="{% static 'forum/img/folder.png' %}" style="margin: 0px;" alt="" align="middle" />
647- {% endif %}
648- </td>
649- <td id="name">
650- <span class="name">
651- <a href="{{ topic.get_absolute_url }}">
652- {% comment %}
653- oehm ja, geht nicht weil ka muss ich guggn, die frage ist. soll es fuer alle gelten oder nur fuer eine topic
654- {% endcomment %}
655- {% if subscribed %}<img src="{% static 'forum/img/en/subscribe_small.png' %}" height="20" alt="subscribe" style="float:left" />{% endif %}
656- {% if topic.sticky %}<img src="{% static 'forum/img/en/stick_topic_small.png' %}" height="20" alt ="Sticky" style="float:left;" /> {% endif %}
657- {% if topic.closed %}<img src="{% static 'forum/img/en/close_small.png' %}" height="20" alt ="Closed" style="float:left; " /> {% endif %}
658- &nbsp;{{ topic.name }}
659- </a>
660- </span>
661- </td>
662- <td><span class="creator">{{ topic.user|user_link }}</span></td>
663- <td><span class="at">{{ topic.created|custom_date:user }}</span></td>
664- <td><span class="count">{{ topic.post_count }}</span></td>
665- <td><span class="views">{{ topic.views }}</span></td>
666- <td>
667- {%if topic.last_post %}
668- {{ topic.last_post.created|custom_date:user }}
669- <br />
670- by {{ topic.last_post.user|user_link }}
671- {% endif %}
672- </td>
673- </tr>
674-
675
676=== removed file 'pybb/templates/pybb/pagination.html'
677--- pybb/templates/pybb/pagination.html 2010-09-29 00:00:45 +0000
678+++ pybb/templates/pybb/pagination.html 1970-01-01 00:00:00 +0000
679@@ -1,41 +0,0 @@
680-{% load i18n %}
681-<div class="pagination" style="float:left">
682- <span class="summary">{{ label }} <strong>{{ page.start_index }}</strong>&mdash;<strong>{{ page.end_index }}</strong> {% trans "of" %} <strong>{{ paginator.count }}</strong> {{ label }}&nbsp;&nbsp;&nbsp;&nbsp;</span>
683- {% if page.has_previous %}
684- {% ifequal page.previous_page_number 1 %}
685- <a href="?page={{ page.previous_page_number }}" class="prev">&lsaquo;&lsaquo; </a>
686- {% else %}
687- <a href="?page=1" class="prev">&lsaquo;&lsaquo;&lsaquo;&lsaquo; </a>
688- <a href="?page={{ page.previous_page_number }}" class="prev">&lsaquo;&lsaquo; </a>
689- {% endifequal %}
690- {% else %}
691- {% ifnotequal paginator.num_pages 1 %}
692- <span class="disabled prev">&lsaquo;&lsaquo; </span>
693- {% endifnotequal %}
694- {% endif %}
695- {% for pages in paginator.page_range %}
696- {% if pages %}
697- {% ifequal paginator.num_pages 1 %}
698- ...
699- {% else %}
700- {% ifequal pages page.number %}
701- <span class="current page">| {{ page.number }} |</span>
702- {% else %}
703- <a href="?page={{ pages }}" class="page">{{ pages }}</a>
704- {% endifequal %}
705- {% endifequal %}
706- {% endif %}
707- {% endfor %}
708- {% if page.has_next %}
709- {% ifequal page.next_page_number paginator.num_pages %}
710- <a href="?page={{ page.next_page_number }}" class="next"> &rsaquo;&rsaquo;</a>
711- {% else %}
712- <a href="?page={{ page.next_page_number }}" class="next"> &rsaquo;&rsaquo;</a>
713- <a href="?page={{ paginator.num_pages }}" class="next"> &rsaquo;&rsaquo;&rsaquo;&rsaquo;</a>
714- {% endifequal %}
715- {% else %}
716- {% ifnotequal paginator.num_pages 1 %}
717- <span class="disabled next"> &rsaquo;&rsaquo;</span>
718- {% endifnotequal %}
719- {% endif %}
720-</div>
721
722=== modified file 'pybb/templates/pybb/topic.html'
723--- pybb/templates/pybb/topic.html 2018-12-10 16:37:12 +0000
724+++ pybb/templates/pybb/topic.html 2019-03-02 13:44:23 +0000
725@@ -1,8 +1,6 @@
726 {% extends 'pybb/base.html' %}
727 {% load pybb_extras %}
728 {% load i18n %}
729-{% load humanize %}
730-{% load wiki_extras %}
731 {% load wlprofile_extras %}
732 {% load custom_date %}
733 {% load pagination_tags %}
734@@ -19,7 +17,7 @@
735 {% endblock %}
736
737 {% block content_header %}
738- <h1>Topic: {{ topic }} </h1>
739+ <h1>Topic: {{ topic }}</h1>
740 {% endblock %}
741
742 {% block content_main %}
743@@ -93,177 +91,21 @@
744 </div>
745 {% autopaginate posts page_size as object_list %}
746 {% paginate using "pagination/pagination_mod.html" %}
747-
748- {% if first_post %}
749- {% ifnotequal first_post posts.0 %}
750- {% with first_post as post %}
751- {% trans "First Post" %}:
752- <table class="forum">
753- <tbody>
754- <tr class="odd">
755- <td class="author">
756- {{ post.user|user_link }}<br />
757- {% if post.user.wlprofile_extras.avatar %}
758- <a href="{% url 'profile_view' post.user %}">
759- <img src="{{ post.user.wlprofile.avatar.url }}" alt="Avatar" />
760- </a>
761- {% endif %}
762- <div class="authorStats">
763- <strong>Joined:</strong> {{ post.user.date_joined|custom_date:user|title }}<br />
764- <strong>Posts:</strong> {{ post.user.wlprofile.post_count }}<br />
765- <img src="{% static 'img/' %}{{ post.user.wlprofile.user_status.image }}" alt="Ranking" /><br />
766- <strong>{{ post.user.wlprofile.user_status.text }}</strong><br />
767- {% if post.user.wlprofile.location %}
768- <strong>Location:</strong> {{ post.user.wlprofile.location }}<br />
769- {% endif %}
770- </div>
771- </td>
772- <td class="post">
773- <a id="post-{{ post.id }}" href="{{post.get_absolute_url}}" title="{% trans "Permalink" %}" class="posRight small permalink">&nbsp;</a>
774- <span class="small">Posted at: {{ post.created|custom_date:user}}</span>
775- <hr />
776- <div class="post">
777- {{ post.body_html|safe }}
778- </div>
779-
780- {% if post.attachment_cache %}
781- {% for attach in post.attachment_cache %}
782- {% trans "Attachment" %}: <a href="{{ attach.get_absolute_url }}">{{ attach.name }}</a> ({{ attach.size_display }})
783- {% endfor %}
784- {% endif %}
785-
786- {% if post.updated %}
787- <span class="small">{% trans "Edited" %}: {{ post.updated|custom_date:user|title}}</span>
788- {% endif %}
789- <hr />
790- {% if user.is_authenticated %}
791- {% ifequal user.wlprofile.show_signatures 1 %}
792- {% if post.user.wlprofile.signature %}
793- {{ post.user.wlprofile.signature|urlize|linebreaks }}
794- {% endif %}
795- {% endifequal %}
796- {% else %}
797- {% if post.user.wlprofile.signature %}
798- {{ post.user.wlprofile.signature|urlize|linebreaks }}
799- {% endif %}
800- {% endif %}
801-
802- <button onclick="window.location.href='#top';" class="posRight">
803- <img src="{% static 'forum/img/top.png' %}" alt ="" class="middle" />
804- <span class="middle">{% trans "Top" %}</span>
805- </button>
806-
807- <button onclick="window.location.href='{% url 'pybb_add_post' topic.id %}?quote_id={{ post.id }}';">
808- <img src="{% static 'forum/img/quote.png' %}" alt ="" class="middle" />
809- <span class="middle">{% trans "Quote" %}</span>
810- </button>
811- {% if user_is_mod or post|pybb_posted_by:user %}
812- <button onclick="window.location.href='{% url 'pybb_edit_post' post.id %}';">
813- <img src="{% static 'forum/img/edit.png' %}" alt ="" class="middle" />
814- <span class="middle">{% trans "Edit" %}</span>
815- </button>
816- {% if user_is_mod or post|pybb_equal_to:last_post %}
817- <button onclick="window.location.href='{% url 'pybb_delete_post' post.id %}';">
818- <img src="{% static 'forum/img/delete.png' %}" alt ="" class="middle" />
819- <span class="middle">{% trans "Delete" %}</span>
820- </button>
821- {% endif %}
822- {% endif %}
823- </td>
824- </tr>
825- </tbody>
826- </table>
827- <br /><hr /><br />
828- {% endwith %}
829- {% endifnotequal %}
830- {% endif %}
831-
832- <table class="forum">
833- <tbody>
834- {% for post in object_list %}
835- {% comment %}
836- TODO (Franku): use
837- {% include 'pybb/inlines/post.html' %}
838- {% endcomment %}
839- <tr class="{% cycle 'odd' 'even' %}" {% if post.is_spam %} style="background-color: gray" {% endif %}>
840- <td class="author">
841- {{ post.user|user_link }}<br />
842- {% if post.user.wlprofile.avatar %}
843- <a href="{% url 'profile_view' post.user %}">
844- <img src="{{ post.user.wlprofile.avatar.url }}" alt="Avatar" />
845- </a>
846- {% endif %}
847- <div class="authorStats">
848- <strong>Joined:</strong> {{ post.user.date_joined|custom_date:user|title }}<br />
849- <strong>Posts:</strong> {{ post.user.wlprofile.post_count }}<br />
850- <img src="{% static 'img/'%}{{ post.user.wlprofile.user_status.image }}" alt="Ranking" /><br />
851- <strong>{{ post.user.wlprofile.user_status.text }}</strong><br />
852- {% if post.user.wlprofile.location %}
853- <strong>Location:</strong> {{ post.user.wlprofile.location }}<br />
854- {% endif %}
855- </div>
856- </td>
857- <td class="post">
858- <a id="post-{{ post.id }}" href="{{post.get_absolute_url}}" title="{% trans "Permalink" %}" class="posRight small permalink">&nbsp;</a>
859- <span class="small">Posted at: {{ post.created|custom_date:user}}</span>
860- <hr />
861- <div class="post">
862- {{ post.body_html|safe }}
863- </div>
864-
865- {% if post.attachment_cache %}
866- {% for attach in post.attachment_cache %}
867- {% trans "Attachment" %}: <a href="{{ attach.get_absolute_url }}">{{ attach.name }}</a> ({{ attach.size_display }})
868- {% endfor %}
869- {% endif %}
870-
871- {% if post.updated %}
872- <span class="small">{% trans "Edited" %}: {{ post.updated|custom_date:user|title}}</span>
873- {% endif %}
874- <hr />
875- {% if user.is_authenticated %}
876- {% ifequal user.wlprofile.show_signatures 1 %}
877- {% if post.user.wlprofile.signature %}
878- {{ post.user.wlprofile.signature|urlize|linebreaks }}
879- {% endif %}
880- {% endifequal %}
881- {% else %}
882- {% if post.user.wlprofile.signature %}
883- {{ post.user.wlprofile.signature|urlize|linebreaks }}
884- {% endif %}
885- {% endif %}
886-
887- <a class="button posRight" href="#top">
888- <img src="{% static 'forum/img/top.png' %}" alt ="" class="middle" />
889- <span class="middle">{% trans "Top" %}</span>
890- </a>
891-
892- <a class="button" href="{% url 'pybb_add_post' topic.id %}?quote_id={{ post.id }}">
893- <img src="{% static 'forum/img/quote.png' %}" alt ="" class="middle" />
894- <span class="middle">{% trans "Quote" %}</span>
895- </a>
896- {% if user_is_mod or post|pybb_posted_by:user %}
897- <a class="button" href="{% url 'pybb_edit_post' post.id %}">
898- <img src="{% static 'forum/img/edit.png' %}" alt ="" class="middle" />
899- <span class="middle">{% trans "Edit" %}</span>
900- </a>
901- {% if user_is_mod or post|pybb_equal_to:last_post %}
902- <a class="button" href="{% url 'pybb_delete_post' post.id %}">
903- <img src="{% static 'forum/img/delete.png' %}" alt ="" class="middle" />
904- <span class="middle">{% trans "Delete" %}</span>
905- </a>
906- {% endif %}
907- {% endif %}
908- </td>
909- </tr>
910- {% if not forloop.last %}
911- {# no spacer at end of table #}
912- <tr class="spacer">
913- <td></td>
914- <td></td>
915- </tr>
916- {% endif %}
917- {% endfor %}
918+
919+ <table class="forum">
920+ <tbody>
921+ {% for post in object_list %}
922+ <tr class="{% cycle 'odd' 'even' %}" {% if post.is_spam %} style="background-color: gray" {% endif %}>
923+ {% include 'pybb/inlines/post.html' %}
924+ </tr>
925+ {% if not forloop.last %}
926+ {# no spacer at end of table #}
927+ <tr class="spacer">
928+ <td></td>
929+ <td></td>
930+ </tr>
931+ {% endif %}
932+ {% endfor %}
933 </tbody>
934 </table>
935
936
937=== modified file 'pybb/templatetags/pybb_extras.py'
938--- pybb/templatetags/pybb_extras.py 2018-12-18 11:38:34 +0000
939+++ pybb/templatetags/pybb_extras.py 2019-03-02 13:44:23 +0000
940@@ -9,10 +9,8 @@
941 from django.template.defaultfilters import stringfilter
942 from django.utils.encoding import smart_unicode
943 from django.utils.html import escape
944-from django.utils.translation import ugettext as _
945-from django.utils import dateformat
946
947-from pybb.models import Post, Forum, Topic, Read, Category
948+from pybb.models import Post, Forum, Topic, Read
949 from pybb.unread import cache_unreads
950 from pybb import settings as pybb_settings
951 import pybb.views
952@@ -20,66 +18,6 @@
953 register = template.Library()
954
955
956-@register.tag
957-def pybb_time(parser, token):
958- try:
959- tag, time = token.split_contents()
960- except ValueError:
961- raise template.TemplateSyntaxError(
962- 'pybb_time requires single argument')
963- else:
964- return PybbTimeNode(time)
965-
966-
967-class PybbTimeNode(template.Node):
968-
969- def __init__(self, time):
970- self.time = template.Variable(time)
971-
972- def render(self, context):
973- time = self.time.resolve(context)
974-
975- delta = datetime.now() - time
976- today = datetime.now().replace(hour=0, minute=0, second=0)
977- yesterday = today - timedelta(days=1)
978-
979- if delta.days == 0:
980- if delta.seconds < 60:
981- if context['LANGUAGE_CODE'].startswith('ru'):
982- msg = _('seconds ago,seconds ago,seconds ago')
983- import pytils
984- msg = pytils.numeral.choose_plural(delta.seconds, msg)
985- else:
986- msg = _('seconds ago')
987- return u'%d %s' % (delta.seconds, msg)
988-
989- elif delta.seconds < 3600:
990- minutes = int(delta.seconds / 60)
991- if context['LANGUAGE_CODE'].startswith('ru'):
992- msg = _('minutes ago,minutes ago,minutes ago')
993- import pytils
994- msg = pytils.numeral.choose_plural(minutes, msg)
995- else:
996- msg = _('minutes ago')
997- return u'%d %s' % (minutes, msg)
998- if time > today:
999- return _('today, %s') % time.strftime('%H:%M')
1000- elif time > yesterday:
1001- return _('yesterday, %s') % time.strftime('%H:%M')
1002- else:
1003- return dateformat.format(time, 'd M, Y H:i')
1004-
1005-
1006-@register.inclusion_tag('pybb/pagination.html', takes_context=True)
1007-def pybb_pagination(context, label):
1008- page = context['page']
1009- paginator = context['paginator']
1010- return {'page': page,
1011- 'paginator': paginator,
1012- 'label': label,
1013- }
1014-
1015-
1016 @register.inclusion_tag('pybb/last_posts.html', takes_context=True)
1017 def pybb_last_posts(context, number=8):
1018 if pybb.views.allowed_for(context.request.user):
1019@@ -225,39 +163,6 @@
1020 return pprint(post)
1021
1022
1023-@register.simple_tag
1024-def pybb_render_post(post, mode='html'):
1025- """Process post contents and replace special tags with human readeable
1026- messages.
1027-
1028- Arguments:
1029- post - the ``Post`` instance
1030- mode - "html" or "text". Control which field to use ``body_html`` or ``body_text``
1031-
1032- Currently following tags are supported:
1033-
1034- @@@AUTOJOIN-(SECONDS)@@@ - autojoin message
1035-
1036- """
1037-
1038- def render_autojoin_message(match):
1039- time_diff = int(match.group(1)) / 60
1040-
1041- join_message = ungettext(u"Added after %s minute",
1042- u"Added after %s minutes",
1043- time_diff)
1044- join_message %= time_diff
1045-
1046- if mode == 'html':
1047- return u'<div class="autojoin-message">%s</div>' % join_message
1048- else:
1049- return join_message
1050-
1051- body = getattr(post, 'body_%s' % mode)
1052- re_tag = re.compile(r'@@@AUTOJOIN-(\d+)@@@')
1053- return re_tag.sub(render_autojoin_message, body)
1054-
1055-
1056 @register.inclusion_tag('mainpage/forum_navigation.html', takes_context=True)
1057 def forum_navigation(context):
1058 """Makes the forum list available to the navigation.
1059@@ -268,81 +173,12 @@
1060
1061 """
1062
1063- from pybb.models import Forum
1064-
1065 forums = Forum.objects.all()
1066-
1067- if context.request.user.is_superuser or pybb.views.allowed_for(context.request.user):
1068+
1069+ if pybb.views.allowed_for(context.request.user):
1070 pass
1071 else:
1072 # Don't show internal forums
1073 forums = forums.filter(category__internal=False)
1074
1075 return {'forums': forums.order_by('category', 'position')}
1076-
1077-
1078-"""
1079-Spielwiese, Playground, Cour de récréati ;)
1080-"""
1081-
1082-
1083-@register.filter
1084-@stringfilter
1085-def pybb_trim_string(value, arg):
1086- """
1087- Mit "arg" ist es moeglich 1 oder mehr Werte der Funtion zu Uebergeben. Wenn
1088- mehr als 1 Wert genutzt werden soll wird es durch "-" getrennt. Jeder Wert
1089- kann entweder die Beschraenkung fuer die Zeichen oder Woerter beinhalten.
1090- Um das eindeutig zu identifizieren Wort "w" und Zeichen "z".
1091- Beispiel:
1092- 1. w:10 -> Auf 10 Worte beschraenken
1093- 2. z:250 -> Auf 250 Zeichen beschraenken
1094- 3. w:10-z:250 -> Auf 10 Worte und 250 Zeichen beschraenken
1095-
1096- Beim spaeteren drueber nachdenken ist das mit den Worten eig. egal und
1097- koennte wieder entfernt werden, aber vllt findet ja einer noch einen nutzen
1098- dafuer ;)
1099- """
1100- _iWord = ''
1101- _iSign = ''
1102- _lArguments = arg.split('-')
1103- _sOption = _lArguments[0].split(':')[0]
1104- _iValue = _lArguments[0].split(':')[1]
1105- if len(_lArguments) == 1:
1106- if _sOption == 'w':
1107- _iWord = int(_iValue)
1108- elif _sOption == 'z':
1109- _iSign = int(_iValue)
1110- else:
1111- pass
1112- elif len(_lArguments) == 2:
1113- if _sOption == 'w':
1114- _iWord = int(_iValue)
1115- _iSign = int(_lArguments[1].split(':')[1])
1116- elif _sOption == 'z':
1117- _iSign = int(_iValue)
1118- _iWord = int(_lArguments[1].split(':')[1])
1119- else:
1120- pass
1121- else:
1122- pass
1123- if _iWord != '' or _iSign != '':
1124- _iWordCount = int(len(value.split(' ')))
1125- _iSignCount = int(len(value))
1126- """
1127- Hier waere noch die Ueberlegung wenn 2 Werte gesetzt das man dann
1128- wirklich nur ganze Woerter anzeigen laesst ohne sie zu beschneiden
1129- """
1130- if _iWord != '' and _iSign != '' and _iSignCount >= _iSign:
1131- return value[0:_iSign] + '...'
1132- elif _iWord != '' and _iSign == '' and _iWordCount >= _iWord:
1133- return ' '.join(value.split(' ')[0:_iWord]) + '...'
1134- elif _iWord == '' and _iSign != '' and _iSignCount >= _iSign:
1135- return value[0:_iSign] + '...'
1136- else:
1137- return value
1138- # return " " + str(len(value)) + " " + str(len(value.split(" "))) +
1139- # " " + str(arg) + " " + str(_iWord) + ":" + str(_iWordCount) + " "
1140- # + str(_iSign) + ":" + str(_iSignCount)
1141- else:
1142- return value
1143
1144=== modified file 'pybb/urls.py'
1145--- pybb/urls.py 2018-11-15 18:30:45 +0000
1146+++ pybb/urls.py 2019-03-02 13:44:23 +0000
1147@@ -40,7 +40,6 @@
1148 url('^post/(?P<post_id>\d+)/edit/$', views.edit_post, name='pybb_edit_post'),
1149 url('^post/(?P<post_id>\d+)/delete/$',
1150 views.delete_post, name='pybb_delete_post'),
1151- url('pybb_moderate_info/$', views.pybb_moderate_info),
1152
1153 # Attachment
1154 url('^attachment/(?P<hash>\w+)/$',
1155
1156=== modified file 'pybb/util.py'
1157--- pybb/util.py 2018-11-09 17:46:16 +0000
1158+++ pybb/util.py 2019-03-02 13:44:23 +0000
1159@@ -48,48 +48,6 @@
1160 return decorator
1161
1162
1163-def paged(paged_list_name, per_page): # , per_page_var='per_page'):
1164- """Parse page from GET data and pass it to view.
1165-
1166- Split the query set returned from view.
1167-
1168- """
1169-
1170- def decorator(func):
1171- def wrapper(request, *args, **kwargs):
1172- result = func(request, *args, **kwargs)
1173- if not isinstance(result, dict):
1174- return result
1175- try:
1176- page = int(request.GET.get('page', 1))
1177- except ValueError:
1178- page = 1
1179-
1180- real_per_page = per_page
1181-
1182- # if per_page_var:
1183- # try:
1184- #value = int(request.GET[per_page_var])
1185- # except (ValueError, KeyError):
1186- # pass
1187- # else:
1188- # if value > 0:
1189- #real_per_page = value
1190-
1191- from django.core.paginator import Paginator
1192- paginator = Paginator(result['paged_qs'], real_per_page)
1193- result[paged_list_name] = paginator.page(page).object_list
1194- result['page'] = page
1195- result['page_list'] = range(1, paginator.num_pages + 1)
1196- result['pages'] = paginator.num_pages
1197- result['per_page'] = real_per_page
1198- result['request'] = request
1199- return result
1200- return wrapper
1201-
1202- return decorator
1203-
1204-
1205 def ajax(func):
1206 """Checks request.method is POST. Return error in JSON in other case.
1207
1208@@ -206,27 +164,6 @@
1209 return text
1210
1211
1212-def absolute_url(path):
1213- return 'http://%s%s' % (pybb_settings.HOST, path)
1214-
1215-
1216-def memoize_method(func):
1217- """Cached result of function call."""
1218-
1219- def wrapper(self, *args, **kwargs):
1220- CACHE_NAME = '__memcache'
1221- try:
1222- cache = getattr(self, CACHE_NAME)
1223- except AttributeError:
1224- cache = {}
1225- setattr(self, CACHE_NAME, cache)
1226- key = (func, tuple(args), frozenset(kwargs.items()))
1227- if key not in cache:
1228- cache[key] = func(self, *args, **kwargs)
1229- return cache[key]
1230- return wrapper
1231-
1232-
1233 def unescape(text):
1234 """Do reverse escaping."""
1235
1236
1237=== modified file 'pybb/views.py'
1238--- pybb/views.py 2018-12-18 11:38:34 +0000
1239+++ pybb/views.py 2019-03-02 13:44:23 +0000
1240@@ -3,21 +3,18 @@
1241 from pybb.markups import mypostmarkup
1242
1243 from django.shortcuts import get_object_or_404
1244-from django.http import HttpResponseRedirect, HttpResponse, HttpResponseNotFound, Http404
1245+from django.http import HttpResponseRedirect, HttpResponse, Http404
1246 from django.contrib.auth.models import User
1247 from django.contrib.auth.decorators import login_required
1248-from django.conf import settings
1249 from django.urls import reverse
1250-from django.db import connection
1251-from django.utils import translation
1252-from django.shortcuts import render, redirect
1253+from django.shortcuts import redirect
1254 from django.db.models import Q
1255 from django.http import Http404
1256
1257-from pybb.util import render_to, paged, build_form, quote_text, ajax, urlize
1258-from pybb.models import Category, Forum, Topic, Post, PrivateMessage, Attachment,\
1259+from pybb.util import render_to, build_form, quote_text, ajax, urlize
1260+from pybb.models import Category, Forum, Topic, Post, Attachment,\
1261 MARKUP_CHOICES
1262-from pybb.forms import AddPostForm, EditPostForm, UserSearchForm
1263+from pybb.forms import AddPostForm, EditPostForm
1264 from pybb import settings as pybb_settings
1265 from pybb.orm import load_related
1266 from pybb.templatetags.pybb_extras import pybb_moderated_by
1267@@ -33,7 +30,7 @@
1268 def allowed_for(user):
1269 """Check if a user has the permission to enter internal Forums."""
1270
1271- return user.is_superuser or user.has_perm(settings.INTERNAL_PERM)
1272+ return user.is_superuser or user.has_perm(pybb_settings.INTERNAL_PERM)
1273
1274
1275 def index_ctx(request):
1276@@ -91,10 +88,6 @@
1277 if request.user.is_authenticated:
1278 topic.update_read(request.user)
1279
1280- if pybb_settings.FREEZE_FIRST_POST:
1281- first_post = topic.posts.order_by('created')[0]
1282- else:
1283- first_post = None
1284 last_post = topic.posts.order_by('-created')[0]
1285
1286 initial = {}
1287@@ -127,7 +120,6 @@
1288
1289 return {'topic': topic,
1290 'last_post': last_post,
1291- 'first_post': first_post,
1292 'form': form,
1293 'user_is_mod': user_is_mod,
1294 'subscribed': subscribed,
1295@@ -191,8 +183,8 @@
1296 # - enable 'forum_new_topic' in the notification settings, or
1297 # - subscribe to an existing topic
1298 subscribers = User.objects.filter(
1299- Q(groups__permissions__codename=settings.INTERNAL_PERM) |
1300- Q(user_permissions__codename=settings.INTERNAL_PERM)
1301+ Q(groups__permissions__codename=pybb_settings.INTERNAL_PERM) |
1302+ Q(user_permissions__codename=pybb_settings.INTERNAL_PERM)
1303 ).exclude(username=request.user.username)
1304 superusers = User.objects.filter(
1305 is_superuser=True).exclude(
1306@@ -233,15 +225,6 @@
1307 add_post = render_to('pybb/add_post.html')(add_post_ctx)
1308
1309
1310-def user_ctx(request, username):
1311- user = get_object_or_404(User, username=username)
1312- topic_count = Topic.objects.filter(user=user).count()
1313- return {'profile': user,
1314- 'topic_count': topic_count,
1315- }
1316-user = render_to('pybb/user.html')(user_ctx)
1317-
1318-
1319 def show_post(request, post_id):
1320 post = get_object_or_404(Post, pk=post_id)
1321 count = post.topic.posts.filter(created__lt=post.created).count() + 1
1322@@ -349,22 +332,6 @@
1323 return HttpResponseRedirect(topic.get_absolute_url())
1324
1325
1326-@render_to('pybb/users.html')
1327-def users_ctx(request):
1328- users = User.objects.order_by('username')
1329- form = UserSearchForm(request.GET)
1330- users = form.filter(users)
1331-
1332- page, paginator = paginate(users, request, pybb_settings.USERS_PAGE_SIZE)
1333-
1334- return {'users': page.object_list,
1335- 'page': page,
1336- 'paginator': paginator,
1337- 'form': form,
1338- }
1339-users = render_to('pybb/users.html')(users_ctx)
1340-
1341-
1342 @login_required
1343 def delete_subscription(request, topic_id):
1344 topic = get_object_or_404(Topic, pk=topic_id)
1345@@ -410,10 +377,6 @@
1346 return {'content': html}
1347
1348
1349-def pybb_moderate_info(request):
1350- return render(request, 'pybb/pybb_moderate_info.html')
1351-
1352-
1353 def toggle_hidden_topic(request, topic_id):
1354 topic = get_object_or_404(Topic, pk=topic_id)
1355 first_post = topic.posts.all()[0]
1356
1357=== modified file 'settings.py'
1358--- settings.py 2019-02-09 14:41:20 +0000
1359+++ settings.py 2019-03-02 13:44:23 +0000
1360@@ -190,9 +190,9 @@
1361 ######################
1362 # Pybb Configuration #
1363 ######################
1364+# See also pybb defaults in pybb.settings.py
1365 PYBB_ATTACHMENT_ENABLE = False # disable gzip middleware when enabling attachments
1366 PYBB_DEFAULT_MARKUP = 'markdown'
1367-PYBB_FREEZE_FIRST_POST = False
1368 INTERNAL_PERM='pybb.can_access_internal' # The permission string derived from pybb.models.category
1369
1370 ##############################################
1371
1372=== modified file 'wlprofile/models.py'
1373--- wlprofile/models.py 2018-09-13 20:19:07 +0000
1374+++ wlprofile/models.py 2019-03-02 13:44:23 +0000
1375@@ -54,9 +54,6 @@
1376 verbose_name = _('Profile')
1377 verbose_name_plural = _('Profiles')
1378
1379- def unread_pm_count(self):
1380- return PrivateMessage.objects.filter(dst_user=self, read=False).count()
1381-
1382 def post_count(self):
1383 """Return the nr of posts the user has.
1384

Subscribers

People subscribed via source and target branches