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
=== modified file 'mainpage/admin.py'
--- mainpage/admin.py 2018-12-11 10:22:21 +0000
+++ mainpage/admin.py 2019-02-09 14:41:50 +0000
@@ -36,6 +36,11 @@
36persons.allow_tags = True36persons.allow_tags = True
3737
3838
39def deleted(self):
40 return '' if self.wlprofile.deleted==False else 'Yes'
41deleted.short_description = u'Deleted himself'
42
43
39class GroupAdmin(GroupAdmin):44class GroupAdmin(GroupAdmin):
40 list_display = ['name', persons]45 list_display = ['name', persons]
41 list_display_links = ['name']46 list_display_links = ['name']
@@ -47,7 +52,7 @@
4752
48class UserAdmin(UserAdmin):53class UserAdmin(UserAdmin):
49 list_display = ('username', 'email', 'date_joined', 'last_login',54 list_display = ('username', 'email', 'date_joined', 'last_login',
50 'is_active', 'is_staff', roles)55 'is_active', deleted, 'is_staff', roles)
51 ordering = ('-date_joined',)56 ordering = ('-date_joined',)
5257
5358
5459
=== modified file 'pybb/templates/pybb/feeds/posts_description.html'
--- pybb/templates/pybb/feeds/posts_description.html 2018-09-13 20:19:07 +0000
+++ pybb/templates/pybb/feeds/posts_description.html 2019-02-09 14:41:50 +0000
@@ -1,6 +1,3 @@
1{% if obj.user.wlprofile.deleted %}1{% load wlprofile_extras %}
2 {{ DELETED_USERNAME }}2{{ obj.user|user_status }} wrote:<br>
3{% else %}
4 {{ obj.user }}
5{% endif %}wrote:<br>
6{{ obj.body_html|safe }}3{{ obj.body_html|safe }}
74
=== modified file 'pybb/templates/pybb/feeds/topics_description.html'
--- pybb/templates/pybb/feeds/topics_description.html 2018-09-13 20:19:07 +0000
+++ pybb/templates/pybb/feeds/topics_description.html 2019-02-09 14:41:50 +0000
@@ -1,6 +1,3 @@
1{% if obj.head.user.wlprofile.deleted %}1{% load wlprofile_extras %}
2 {{ DELETED_USERNAME }}2{{ obj.head.user|user_status }} wrote:<br>
3{% else %}
4 {{ obj.head.user }}
5{% endif %}wrote:<br>
6{{ obj.head.body_html|safe }}3{{ obj.head.body_html|safe }}
74
=== modified file 'settings.py'
--- settings.py 2018-12-30 11:45:03 +0000
+++ settings.py 2019-02-09 14:41:50 +0000
@@ -151,7 +151,6 @@
151 'django.template.context_processors.static',151 'django.template.context_processors.static',
152 'django.template.context_processors.tz',152 'django.template.context_processors.tz',
153 'django_messages.context_processors.inbox',153 'django_messages.context_processors.inbox',
154 'wlprofile.context_processors.deleted_user_data',
155 ],154 ],
156 },155 },
157 },156 },
158157
=== modified file 'templates/search/includes/posts.html'
--- templates/search/includes/posts.html 2017-09-17 15:52:45 +0000
+++ templates/search/includes/posts.html 2019-02-09 14:41:50 +0000
@@ -1,7 +1,8 @@
1{% load highlight %}1{% load highlight %}
2{% load custom_date %}2{% load custom_date %}
3{% load wlprofile_extras %}
34
4<a href=" {{ post.post_link }}">Post by {{ post.user }}</a><span class="small"> @ </span>5<a href=" {{ post.post_link }}">Post by {{ post.user|user_status }}</a><span class="small"> @ </span>
5 Topic <a href="{{ post.object.topic.get_absolute_url }}">{{ post.object.topic }}</a><span class="small"> @ </span>6 Topic <a href="{{ post.object.topic.get_absolute_url }}">{{ post.object.topic }}</a><span class="small"> @ </span>
6 Forum <a href="{{ post.object.topic.forum.get_absolute_url }}">{{ post.object.topic.forum }}</a>,7 Forum <a href="{{ post.object.topic.forum.get_absolute_url }}">{{ post.object.topic.forum }}</a>,
7 {{ post.date|custom_date:user }}<br>8 {{ post.date|custom_date:user }}<br>
89
=== modified file 'templates/search/includes/topics.html'
--- templates/search/includes/topics.html 2017-09-17 15:52:45 +0000
+++ templates/search/includes/topics.html 2019-02-09 14:41:50 +0000
@@ -1,6 +1,7 @@
1{% load custom_date %}1{% load custom_date %}
2{% load wlprofile_extras %}
23
3 <a href=" {{ topic.topic_link }}">{{ topic.name }}</a><span class="small"> @ </span> 4 <a href=" {{ topic.topic_link }}">{{ topic.name }}</a><span class="small"> @ </span>
4 Forum <a href="{{ topic.object.forum.get_absolute_url }}">{{ topic.object.forum }}</a>5 Forum <a href="{{ topic.object.forum.get_absolute_url }}">{{ topic.object.forum }}</a>
5 by {{topic.user}},6 by {{topic.user|user_status}},
6 {{topic.date|custom_date:user}}7 {{topic.date|custom_date:user}}
78
=== modified file 'wiki/templates/wiki/feeds/history_description.html'
--- wiki/templates/wiki/feeds/history_description.html 2018-09-13 20:19:07 +0000
+++ wiki/templates/wiki/feeds/history_description.html 2019-02-09 14:41:50 +0000
@@ -1,9 +1,6 @@
1{% load i18n %}1{% load i18n %}
2{% load wlprofile_extras %}
23
3{% trans "Edited by user" %} {% if obj.editor.wlprofile.deleted %}4{% trans "Edited by user" %} {{ obj.editor.username|user_status }}
4 {{ DELETED_USERNAME }}
5 {% else %}
6 {{ obj.editor.username }}
7 {% endif %}
8 {% trans "at"%} {{ obj.modified }}<br>5 {% trans "at"%} {{ obj.modified }}<br>
9{{ obj.comment }}6{{ obj.comment }}
107
=== modified file 'wlprofile/admin.py'
--- wlprofile/admin.py 2018-12-11 10:22:21 +0000
+++ wlprofile/admin.py 2019-02-09 14:41:50 +0000
@@ -17,7 +17,7 @@
1717
1818
19class ProfileAdmin(admin.ModelAdmin):19class ProfileAdmin(admin.ModelAdmin):
20 list_display = ['user', 'time_zone', 'location']20 list_display = ['user', 'time_zone', 'location', 'deleted']
21 list_per_page = 2021 list_per_page = 20
22 ordering = ['-user']22 ordering = ['-user']
23 search_fields = ['user__username', 'user__first_name', 'user__last_name']23 search_fields = ['user__username', 'user__first_name', 'user__last_name']
2424
=== removed file 'wlprofile/context_processors.py'
--- wlprofile/context_processors.py 2018-09-13 20:19:07 +0000
+++ wlprofile/context_processors.py 1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
1from django.conf import settings
2
3
4def deleted_user_data(request):
5 context = {'DELETED_USERNAME': settings.DELETED_USERNAME}
6 return context
70
=== modified file 'wlprofile/templates/wlprofile/delete_me.html'
--- wlprofile/templates/wlprofile/delete_me.html 2018-10-14 13:24:15 +0000
+++ wlprofile/templates/wlprofile/delete_me.html 2019-02-09 14:41:50 +0000
@@ -2,6 +2,7 @@
22
3{% load i18n %}3{% load i18n %}
4{% load wlprofile_extras %}4{% load wlprofile_extras %}
5{% load static %}
56
6{% block title %}7{% block title %}
7{% trans "Delete me" %} - {{ block.super }}8{% trans "Delete me" %} - {{ block.super }}
@@ -13,7 +14,7 @@
13{% block content_main %}14{% block content_main %}
14<div class="blogEntry">15<div class="blogEntry">
15 <h3>Hi {{ user }},</h3>16 <h3>Hi {{ user }},</h3>
16 <p>we are sorry that you want to leave our community <img src="/wlmedia/img/smileys/face-sad.png" alt="Sad smiley"></p>17 <p>we are sorry that you want to leave our community <img src="{% static 'img/smileys/face-sad.png' %}" alt="Sad smiley"></p>
17 <h3>What deleting yourself means:</h3>18 <h3>What deleting yourself means:</h3>
18 <ul>19 <ul>
19 <li>Your account will be deactivated. This means:20 <li>Your account will be deactivated. This means:
@@ -30,7 +31,7 @@
30 <li>Your email address will be removed, so you will not receive any notification mails anymore.</li>31 <li>Your email address will be removed, so you will not receive any notification mails anymore.</li>
31 <li>32 <li>
32 <b>Nothing</b> that you have posted (forum posts, comments and uploaded maps) will be deleted.33 <b>Nothing</b> that you have posted (forum posts, comments and uploaded maps) will be deleted.
33 Instead of your user name, the string "{{ DELETED_USERNAME }}" will be shown.</li>34 Instead of your user name, the string "{{ deleted_name }}" will be shown.</li>
34 <li>Your online gaming password will be reset.</li>35 <li>Your online gaming password will be reset.</li>
35 <li>All dates given in the <a href="{% url 'scheduling_scheduling' %}">Playtime scheduler</a> will be deleted</li>36 <li>All dates given in the <a href="{% url 'scheduling_scheduling' %}">Playtime scheduler</a> will be deleted</li>
36 </ul>37 </ul>
3738
=== modified file 'wlprofile/templatetags/wlprofile_extras.py'
--- wlprofile/templatetags/wlprofile_extras.py 2018-09-14 07:01:22 +0000
+++ wlprofile/templatetags/wlprofile_extras.py 2019-02-09 14:41:50 +0000
@@ -14,6 +14,8 @@
14from django.utils.safestring import mark_safe14from django.utils.safestring import mark_safe
15from django.contrib.auth.models import User15from django.contrib.auth.models import User
16from django.conf import settings16from django.conf import settings
17from django.contrib.auth.models import User
18from django.shortcuts import get_object_or_404
1719
18register = template.Library()20register = template.Library()
1921
@@ -28,3 +30,22 @@
28 data = u'<a href="%s">%s</a>' % (30 data = u'<a href="%s">%s</a>' % (
29 reverse('profile_view', args=[user.username]), user.username)31 reverse('profile_view', args=[user.username]), user.username)
30 return mark_safe(data)32 return mark_safe(data)
33
34
35@register.filter
36def user_status(user):
37 """Check if user has deleted himself.
38
39 When using the search, the user is just a string, so we need to get
40 the userobject.
41 """
42
43 if not isinstance(user, User):
44 user_obj = get_object_or_404(User, username=user)
45 else:
46 user_obj = user
47
48 if user_obj.wlprofile.deleted:
49 return settings.DELETED_USERNAME
50
51 return user
3152
=== modified file 'wlprofile/views.py'
--- wlprofile/views.py 2018-09-14 06:42:53 +0000
+++ wlprofile/views.py 2019-02-09 14:41:50 +0000
@@ -17,7 +17,8 @@
17 """Show a page to inform the user what deleting means."""17 """Show a page to inform the user what deleting means."""
1818
19 context = {19 context = {
20 'user': request.user20 'user': request.user,
21 'deleted_name': settings.DELETED_USERNAME,
21 }22 }
22 return render(request, 'wlprofile/delete_me.html',23 return render(request, 'wlprofile/delete_me.html',
23 context)24 context)

Subscribers

People subscribed via source and target branches