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

Proposed by kaputtnik
Status: Merged
Merged at revision: 516
Proposed branch: lp:~widelands-dev/widelands-website/deleted_user2
Merge into: lp:widelands-website
Diff against target: 209 lines (+43/-29)
12 files modified
mainpage/admin.py (+6/-1)
pybb/templates/pybb/feeds/posts_description.html (+2/-5)
pybb/templates/pybb/feeds/topics_description.html (+2/-5)
settings.py (+0/-1)
templates/search/includes/posts.html (+2/-1)
templates/search/includes/topics.html (+2/-1)
wiki/templates/wiki/feeds/history_description.html (+2/-5)
wlprofile/admin.py (+1/-1)
wlprofile/context_processors.py (+0/-6)
wlprofile/templates/wlprofile/delete_me.html (+3/-2)
wlprofile/templatetags/wlprofile_extras.py (+21/-0)
wlprofile/views.py (+2/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands-website/deleted_user2
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+361963@code.launchpad.net

Commit message

Fix showing username in search results if user has deleted himself

Description of the change

Just stumbled over this during cleaning of users who had registered but never activated their account. So there are some more small changes:

- in admin/auth/user show if a user has deleted himself. So one can distinguish between inactive users and users who deleted them self (which are also inactive)
- show the deleted status also in admin/wlprofile
- added a new template filter 'user_status', which is used to either show DELETED_USERNAME or the real username. This makes some templates easier to use.
- this filter makes the context_processor in wlprofile superfluous
- use the filter in search results and other places
- fixed displaying smiley in delete_me page

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

removed line for testing purposes

Revision history for this message
GunChleoc (gunchleoc) wrote :

LGTM :)

review: Approve
519. By kaputtnik

merged trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mainpage/admin.py'
2--- mainpage/admin.py 2018-12-11 10:22:21 +0000
3+++ mainpage/admin.py 2019-02-09 14:41:50 +0000
4@@ -36,6 +36,11 @@
5 persons.allow_tags = True
6
7
8+def deleted(self):
9+ return '' if self.wlprofile.deleted==False else 'Yes'
10+deleted.short_description = u'Deleted himself'
11+
12+
13 class GroupAdmin(GroupAdmin):
14 list_display = ['name', persons]
15 list_display_links = ['name']
16@@ -47,7 +52,7 @@
17
18 class UserAdmin(UserAdmin):
19 list_display = ('username', 'email', 'date_joined', 'last_login',
20- 'is_active', 'is_staff', roles)
21+ 'is_active', deleted, 'is_staff', roles)
22 ordering = ('-date_joined',)
23
24
25
26=== modified file 'pybb/templates/pybb/feeds/posts_description.html'
27--- pybb/templates/pybb/feeds/posts_description.html 2018-09-13 20:19:07 +0000
28+++ pybb/templates/pybb/feeds/posts_description.html 2019-02-09 14:41:50 +0000
29@@ -1,6 +1,3 @@
30-{% if obj.user.wlprofile.deleted %}
31- {{ DELETED_USERNAME }}
32-{% else %}
33- {{ obj.user }}
34-{% endif %}wrote:<br>
35+{% load wlprofile_extras %}
36+{{ obj.user|user_status }} wrote:<br>
37 {{ obj.body_html|safe }}
38
39=== modified file 'pybb/templates/pybb/feeds/topics_description.html'
40--- pybb/templates/pybb/feeds/topics_description.html 2018-09-13 20:19:07 +0000
41+++ pybb/templates/pybb/feeds/topics_description.html 2019-02-09 14:41:50 +0000
42@@ -1,6 +1,3 @@
43-{% if obj.head.user.wlprofile.deleted %}
44- {{ DELETED_USERNAME }}
45-{% else %}
46- {{ obj.head.user }}
47-{% endif %}wrote:<br>
48+{% load wlprofile_extras %}
49+{{ obj.head.user|user_status }} wrote:<br>
50 {{ obj.head.body_html|safe }}
51
52=== modified file 'settings.py'
53--- settings.py 2018-12-30 11:45:03 +0000
54+++ settings.py 2019-02-09 14:41:50 +0000
55@@ -151,7 +151,6 @@
56 'django.template.context_processors.static',
57 'django.template.context_processors.tz',
58 'django_messages.context_processors.inbox',
59- 'wlprofile.context_processors.deleted_user_data',
60 ],
61 },
62 },
63
64=== modified file 'templates/search/includes/posts.html'
65--- templates/search/includes/posts.html 2017-09-17 15:52:45 +0000
66+++ templates/search/includes/posts.html 2019-02-09 14:41:50 +0000
67@@ -1,7 +1,8 @@
68 {% load highlight %}
69 {% load custom_date %}
70+{% load wlprofile_extras %}
71
72-<a href=" {{ post.post_link }}">Post by {{ post.user }}</a><span class="small"> @ </span>
73+<a href=" {{ post.post_link }}">Post by {{ post.user|user_status }}</a><span class="small"> @ </span>
74 Topic <a href="{{ post.object.topic.get_absolute_url }}">{{ post.object.topic }}</a><span class="small"> @ </span>
75 Forum <a href="{{ post.object.topic.forum.get_absolute_url }}">{{ post.object.topic.forum }}</a>,
76 {{ post.date|custom_date:user }}<br>
77
78=== modified file 'templates/search/includes/topics.html'
79--- templates/search/includes/topics.html 2017-09-17 15:52:45 +0000
80+++ templates/search/includes/topics.html 2019-02-09 14:41:50 +0000
81@@ -1,6 +1,7 @@
82 {% load custom_date %}
83+{% load wlprofile_extras %}
84
85 <a href=" {{ topic.topic_link }}">{{ topic.name }}</a><span class="small"> @ </span>
86 Forum <a href="{{ topic.object.forum.get_absolute_url }}">{{ topic.object.forum }}</a>
87- by {{topic.user}},
88+ by {{topic.user|user_status}},
89 {{topic.date|custom_date:user}}
90
91=== modified file 'wiki/templates/wiki/feeds/history_description.html'
92--- wiki/templates/wiki/feeds/history_description.html 2018-09-13 20:19:07 +0000
93+++ wiki/templates/wiki/feeds/history_description.html 2019-02-09 14:41:50 +0000
94@@ -1,9 +1,6 @@
95 {% load i18n %}
96+{% load wlprofile_extras %}
97
98-{% trans "Edited by user" %} {% if obj.editor.wlprofile.deleted %}
99- {{ DELETED_USERNAME }}
100- {% else %}
101- {{ obj.editor.username }}
102- {% endif %}
103+{% trans "Edited by user" %} {{ obj.editor.username|user_status }}
104 {% trans "at"%} {{ obj.modified }}<br>
105 {{ obj.comment }}
106
107=== modified file 'wlprofile/admin.py'
108--- wlprofile/admin.py 2018-12-11 10:22:21 +0000
109+++ wlprofile/admin.py 2019-02-09 14:41:50 +0000
110@@ -17,7 +17,7 @@
111
112
113 class ProfileAdmin(admin.ModelAdmin):
114- list_display = ['user', 'time_zone', 'location']
115+ list_display = ['user', 'time_zone', 'location', 'deleted']
116 list_per_page = 20
117 ordering = ['-user']
118 search_fields = ['user__username', 'user__first_name', 'user__last_name']
119
120=== removed file 'wlprofile/context_processors.py'
121--- wlprofile/context_processors.py 2018-09-13 20:19:07 +0000
122+++ wlprofile/context_processors.py 1970-01-01 00:00:00 +0000
123@@ -1,6 +0,0 @@
124-from django.conf import settings
125-
126-
127-def deleted_user_data(request):
128- context = {'DELETED_USERNAME': settings.DELETED_USERNAME}
129- return context
130
131=== modified file 'wlprofile/templates/wlprofile/delete_me.html'
132--- wlprofile/templates/wlprofile/delete_me.html 2018-10-14 13:24:15 +0000
133+++ wlprofile/templates/wlprofile/delete_me.html 2019-02-09 14:41:50 +0000
134@@ -2,6 +2,7 @@
135
136 {% load i18n %}
137 {% load wlprofile_extras %}
138+{% load static %}
139
140 {% block title %}
141 {% trans "Delete me" %} - {{ block.super }}
142@@ -13,7 +14,7 @@
143 {% block content_main %}
144 <div class="blogEntry">
145 <h3>Hi {{ user }},</h3>
146- <p>we are sorry that you want to leave our community <img src="/wlmedia/img/smileys/face-sad.png" alt="Sad smiley"></p>
147+ <p>we are sorry that you want to leave our community <img src="{% static 'img/smileys/face-sad.png' %}" alt="Sad smiley"></p>
148 <h3>What deleting yourself means:</h3>
149 <ul>
150 <li>Your account will be deactivated. This means:
151@@ -30,7 +31,7 @@
152 <li>Your email address will be removed, so you will not receive any notification mails anymore.</li>
153 <li>
154 <b>Nothing</b> that you have posted (forum posts, comments and uploaded maps) will be deleted.
155- Instead of your user name, the string "{{ DELETED_USERNAME }}" will be shown.</li>
156+ Instead of your user name, the string "{{ deleted_name }}" will be shown.</li>
157 <li>Your online gaming password will be reset.</li>
158 <li>All dates given in the <a href="{% url 'scheduling_scheduling' %}">Playtime scheduler</a> will be deleted</li>
159 </ul>
160
161=== modified file 'wlprofile/templatetags/wlprofile_extras.py'
162--- wlprofile/templatetags/wlprofile_extras.py 2018-09-14 07:01:22 +0000
163+++ wlprofile/templatetags/wlprofile_extras.py 2019-02-09 14:41:50 +0000
164@@ -14,6 +14,8 @@
165 from django.utils.safestring import mark_safe
166 from django.contrib.auth.models import User
167 from django.conf import settings
168+from django.contrib.auth.models import User
169+from django.shortcuts import get_object_or_404
170
171 register = template.Library()
172
173@@ -28,3 +30,22 @@
174 data = u'<a href="%s">%s</a>' % (
175 reverse('profile_view', args=[user.username]), user.username)
176 return mark_safe(data)
177+
178+
179+@register.filter
180+def user_status(user):
181+ """Check if user has deleted himself.
182+
183+ When using the search, the user is just a string, so we need to get
184+ the userobject.
185+ """
186+
187+ if not isinstance(user, User):
188+ user_obj = get_object_or_404(User, username=user)
189+ else:
190+ user_obj = user
191+
192+ if user_obj.wlprofile.deleted:
193+ return settings.DELETED_USERNAME
194+
195+ return user
196
197=== modified file 'wlprofile/views.py'
198--- wlprofile/views.py 2018-09-14 06:42:53 +0000
199+++ wlprofile/views.py 2019-02-09 14:41:50 +0000
200@@ -17,7 +17,8 @@
201 """Show a page to inform the user what deleting means."""
202
203 context = {
204- 'user': request.user
205+ 'user': request.user,
206+ 'deleted_name': settings.DELETED_USERNAME,
207 }
208 return render(request, 'wlprofile/delete_me.html',
209 context)

Subscribers

People subscribed via source and target branches