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

Proposed by kaputtnik
Status: Merged
Merged at revision: 472
Proposed branch: lp:~widelands-dev/widelands-website/custom_user_admin_page
Merge into: lp:widelands-website
Diff against target: 31 lines (+17/-0)
1 file modified
wlprofile/admin.py (+17/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands-website/custom_user_admin_page
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+331613@code.launchpad.net

Description of the change

Since i deleted two users today i got bored with the admin page showing all users in a list, sorted by username. Everytime one has to search for the user he wants to delete, while the most time a spammer has registered within the last few days. So i thought to order the list by 'date_joined' and made some other changes to make the work a bit easier:

Removed columns: 'last_name' and 'first_name'
Added columns: 'date_joined', 'last_login' and 'is_active'
Ordering is changed from 'username' to 'date_joined' showing the recent joined users first

All columns are sortable.

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

merged with trunk

Revision history for this message
GunChleoc (gunchleoc) wrote :

I think this is a great idea :D

LGTM, not tested.

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

Thanks, merged and deployed :-)

Revision history for this message
kaputtnik (franku) wrote :

Quite interesting how many users had registered but never activated the account ;)

https://wl.widelands.org/admin/auth/user/?o=5

Revision history for this message
GunChleoc (gunchleoc) wrote :

I'm in favour of deleting those accounts. It will make the list of usernames to trawl through shorter when posting news etc.

Revision history for this message
kaputtnik (franku) wrote :

I have deleted the non active accounts where the activation date expired. In total ~140 users.

> It will make the list of usernames to trawl through shorter when posting news etc.

Normally the one who will write a news post is the one who opens the appropriate admin page. So i think in the list of usernames the current user should be marked/chosen automatically.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Should, but isn't, at least not the last time I posted to the news page. Maybe I'm overlooking something?

Revision history for this message
kaputtnik (franku) wrote :

Sorry this was meant to be a 'will have': bug 1723640

Revision history for this message
GunChleoc (gunchleoc) wrote :

So I wasn't being blind then :)

Revision history for this message
GunChleoc (gunchleoc) wrote :

I waned to give this a quick spin while the Alpha site is up, but I don't have admin privileges.

Revision history for this message
kaputtnik (franku) wrote :

Sorry i don't understand what you mean. This branch is already merged so you could watch it on wl.widelands.org?

Revision history for this message
GunChleoc (gunchleoc) wrote :

Sorry, I didn't see that it was already merged.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'wlprofile/admin.py'
2--- wlprofile/admin.py 2016-12-13 18:28:51 +0000
3+++ wlprofile/admin.py 2017-10-01 08:12:20 +0000
4@@ -12,6 +12,8 @@
5 from django.utils.translation import ugettext_lazy as _
6 from django.contrib import admin
7 from models import Profile
8+from django.contrib.auth.models import User
9+from django.contrib.auth.admin import UserAdmin
10
11
12 class ProfileAdmin(admin.ModelAdmin):
13@@ -37,3 +39,18 @@
14 )
15
16 admin.site.register(Profile, ProfileAdmin)
17+
18+
19+class CustomUserAdmin(UserAdmin):
20+ """Partly overwritten admin page for django auth.user.
21+
22+ Replaces in users list: 'first_name' with 'date_joined' and
23+ 'last_name' with 'is_active'. Added column: 'last_login'.
24+
25+ """
26+ list_display = ('username', 'email', 'date_joined', 'last_login',
27+ 'is_active', 'is_staff')
28+ ordering = ('-date_joined',)
29+
30+admin.site.unregister(User)
31+admin.site.register(User, CustomUserAdmin)

Subscribers

People subscribed via source and target branches