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

Proposed by kaputtnik
Status: Merged
Merged at revision: 535
Proposed branch: lp:~widelands-dev/widelands-website/show_user_posts
Merge into: lp:widelands-website
Diff against target: 106 lines (+57/-3)
5 files modified
pybb/templates/pybb/all_user_posts.html (+38/-0)
pybb/urls.py (+1/-0)
pybb/views.py (+16/-1)
wlprofile/models.py (+1/-1)
wlprofile/templates/wlprofile/view_profile.html (+1/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands-website/show_user_posts
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+367237@code.launchpad.net

Description of the change

Add link and view to show all posts of a particular user.

The link is made from the posts count in the user profile. The view contains all posts of the user, sorted by date.

Example image: https://bugs.launchpad.net/widelands-website/+bug/1825707/+attachment/5262041/+files/all_users_post.jpg

To post a comment you must log in.
537. By kaputtnik

use em; added spaces to templatetags

Revision history for this message
GunChleoc (gunchleoc) wrote :

A few string nits. Feel free to merge & deploy when you have addressed them.

review: Approve
538. By kaputtnik

stringfixes

Revision history for this message
kaputtnik (franku) wrote :

Many thanks :-)

Will deploy in the next days...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'pybb/templates/pybb/all_user_posts.html'
--- pybb/templates/pybb/all_user_posts.html 1970-01-01 00:00:00 +0000
+++ pybb/templates/pybb/all_user_posts.html 2019-05-10 16:24:01 +0000
@@ -0,0 +1,38 @@
1{% extends 'pybb/base.html' %}
2{% load custom_date %}
3{% load pagination_tags %}
4{% block title %}
5 Posts by {{ this_user }} - {{ block.super }}
6{% endblock title %}
7
8{% block content_header %}
9 <h1>Posts by {{ this_user }}</h1>
10{% endblock %}
11
12{% block content_main %}
13<div class="blogEntry">
14<p>{{ this_user }} has written {{ posts|length }} post{{ posts|length|pluralize }}.</p>
15{% autopaginate posts 30 %}
16{% paginate %}
17<table class='forum'>
18 <thead>
19 <tr>
20 <th style="text-align: left; width: 12em;">Date</th>
21 <th style="text-align: left; width: 14em;">Forum</th>
22 <th style="text-align: left; width: 24em;">Topic</th>
23 <th style="text-align: left;">Post{{ posts|length|pluralize }}</th>
24 </tr>
25 </thead>
26 <tbody>
27 {% for post in posts %}
28 <tr class="{% cycle 'odd' 'even' %}">
29 <td class='post'>{{ post.created|custom_date:user }}</td>
30 <td class='post'><a href="{% url 'pybb_topic' post.topic.id %}">{{ post.topic.forum }}</a></td>
31 <td class='post'><a href="{% url 'pybb_forum' post.topic.forum.id %}">{{ post.topic }}</a></td>
32 <td class='post'><a href="{{ post.get_absolute_url }}">"{{ post.body_text|truncatechars:80 }}"</a></td>
33 </tr>
34 {% endfor %}
35 </tbody>
36</table>
37</div>
38{% endblock %}
039
=== modified file 'pybb/urls.py'
--- pybb/urls.py 2019-03-16 20:10:31 +0000
+++ pybb/urls.py 2019-05-10 16:24:01 +0000
@@ -41,6 +41,7 @@
41 url('^post/(?P<post_id>\d+)/delete/$',41 url('^post/(?P<post_id>\d+)/delete/$',
42 views.delete_post, name='pybb_delete_post'),42 views.delete_post, name='pybb_delete_post'),
43 url(r'^latest_posts/$', views.all_latest, name='all_latest_posts'),43 url(r'^latest_posts/$', views.all_latest, name='all_latest_posts'),
44 url(r'^user_posts/(?P<this_user>\w+)/$', views.user_posts, name='all_user_posts'),
4445
45 # Attachment46 # Attachment
46 url('^attachment/(?P<hash>\w+)/$',47 url('^attachment/(?P<hash>\w+)/$',
4748
=== modified file 'pybb/views.py'
--- pybb/views.py 2019-03-23 09:00:44 +0000
+++ pybb/views.py 2019-05-10 16:24:01 +0000
@@ -474,5 +474,20 @@
474 'sort_by': sort_by474 'sort_by': sort_by
475 }475 }
476476
477
478all_latest = render_to('pybb/all_last_posts.html')(all_latest_posts)477all_latest = render_to('pybb/all_last_posts.html')(all_latest_posts)
478
479@login_required
480def all_user_posts(request, this_user=None):
481 """Get all posts of a user"""
482
483 if this_user:
484 posts = Post.objects.public().filter(user__username=this_user)
485 else:
486 posts = Post.objects.public().filter(user__username=request.user)
487
488 return {
489 'this_user': this_user,
490 'posts': posts,
491 }
492
493user_posts = render_to('pybb/all_user_posts.html')(all_user_posts)
479494
=== modified file 'wlprofile/models.py'
--- wlprofile/models.py 2019-03-31 11:08:21 +0000
+++ wlprofile/models.py 2019-05-10 16:24:01 +0000
@@ -62,7 +62,7 @@
62 to not be always calculated.62 to not be always calculated.
6363
64 """64 """
65 return Post.objects.filter(user=self.user).count()65 return Post.objects.public().filter(user=self.user).count()
6666
67 def user_status(self):67 def user_status(self):
68 nump = self.post_count()68 nump = self.post_count()
6969
=== modified file 'wlprofile/templates/wlprofile/view_profile.html'
--- wlprofile/templates/wlprofile/view_profile.html 2018-10-09 19:52:50 +0000
+++ wlprofile/templates/wlprofile/view_profile.html 2019-05-10 16:24:01 +0000
@@ -45,7 +45,7 @@
45 </tr>45 </tr>
46 <tr>46 <tr>
47 <td class="grey">Forum Posts:</td>47 <td class="grey">Forum Posts:</td>
48 <td>{{ profile.post_count }}</td>48 <td><a href="{% url 'all_user_posts' profile.user %}" title="Show all posts">{{ profile.post_count }}</a></td>
49 </tr>49 </tr>
50 <tr>50 <tr>
51 <td class="grey">Website:</td>51 <td class="grey">Website:</td>

Subscribers

People subscribed via source and target branches