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
1=== added file 'pybb/templates/pybb/all_user_posts.html'
2--- pybb/templates/pybb/all_user_posts.html 1970-01-01 00:00:00 +0000
3+++ pybb/templates/pybb/all_user_posts.html 2019-05-10 16:24:01 +0000
4@@ -0,0 +1,38 @@
5+{% extends 'pybb/base.html' %}
6+{% load custom_date %}
7+{% load pagination_tags %}
8+{% block title %}
9+ Posts by {{ this_user }} - {{ block.super }}
10+{% endblock title %}
11+
12+{% block content_header %}
13+ <h1>Posts by {{ this_user }}</h1>
14+{% endblock %}
15+
16+{% block content_main %}
17+<div class="blogEntry">
18+<p>{{ this_user }} has written {{ posts|length }} post{{ posts|length|pluralize }}.</p>
19+{% autopaginate posts 30 %}
20+{% paginate %}
21+<table class='forum'>
22+ <thead>
23+ <tr>
24+ <th style="text-align: left; width: 12em;">Date</th>
25+ <th style="text-align: left; width: 14em;">Forum</th>
26+ <th style="text-align: left; width: 24em;">Topic</th>
27+ <th style="text-align: left;">Post{{ posts|length|pluralize }}</th>
28+ </tr>
29+ </thead>
30+ <tbody>
31+ {% for post in posts %}
32+ <tr class="{% cycle 'odd' 'even' %}">
33+ <td class='post'>{{ post.created|custom_date:user }}</td>
34+ <td class='post'><a href="{% url 'pybb_topic' post.topic.id %}">{{ post.topic.forum }}</a></td>
35+ <td class='post'><a href="{% url 'pybb_forum' post.topic.forum.id %}">{{ post.topic }}</a></td>
36+ <td class='post'><a href="{{ post.get_absolute_url }}">"{{ post.body_text|truncatechars:80 }}"</a></td>
37+ </tr>
38+ {% endfor %}
39+ </tbody>
40+</table>
41+</div>
42+{% endblock %}
43
44=== modified file 'pybb/urls.py'
45--- pybb/urls.py 2019-03-16 20:10:31 +0000
46+++ pybb/urls.py 2019-05-10 16:24:01 +0000
47@@ -41,6 +41,7 @@
48 url('^post/(?P<post_id>\d+)/delete/$',
49 views.delete_post, name='pybb_delete_post'),
50 url(r'^latest_posts/$', views.all_latest, name='all_latest_posts'),
51+ url(r'^user_posts/(?P<this_user>\w+)/$', views.user_posts, name='all_user_posts'),
52
53 # Attachment
54 url('^attachment/(?P<hash>\w+)/$',
55
56=== modified file 'pybb/views.py'
57--- pybb/views.py 2019-03-23 09:00:44 +0000
58+++ pybb/views.py 2019-05-10 16:24:01 +0000
59@@ -474,5 +474,20 @@
60 'sort_by': sort_by
61 }
62
63-
64 all_latest = render_to('pybb/all_last_posts.html')(all_latest_posts)
65+
66+@login_required
67+def all_user_posts(request, this_user=None):
68+ """Get all posts of a user"""
69+
70+ if this_user:
71+ posts = Post.objects.public().filter(user__username=this_user)
72+ else:
73+ posts = Post.objects.public().filter(user__username=request.user)
74+
75+ return {
76+ 'this_user': this_user,
77+ 'posts': posts,
78+ }
79+
80+user_posts = render_to('pybb/all_user_posts.html')(all_user_posts)
81
82=== modified file 'wlprofile/models.py'
83--- wlprofile/models.py 2019-03-31 11:08:21 +0000
84+++ wlprofile/models.py 2019-05-10 16:24:01 +0000
85@@ -62,7 +62,7 @@
86 to not be always calculated.
87
88 """
89- return Post.objects.filter(user=self.user).count()
90+ return Post.objects.public().filter(user=self.user).count()
91
92 def user_status(self):
93 nump = self.post_count()
94
95=== modified file 'wlprofile/templates/wlprofile/view_profile.html'
96--- wlprofile/templates/wlprofile/view_profile.html 2018-10-09 19:52:50 +0000
97+++ wlprofile/templates/wlprofile/view_profile.html 2019-05-10 16:24:01 +0000
98@@ -45,7 +45,7 @@
99 </tr>
100 <tr>
101 <td class="grey">Forum Posts:</td>
102- <td>{{ profile.post_count }}</td>
103+ <td><a href="{% url 'all_user_posts' profile.user %}" title="Show all posts">{{ profile.post_count }}</a></td>
104 </tr>
105 <tr>
106 <td class="grey">Website:</td>

Subscribers

People subscribed via source and target branches