File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,23 @@ def users_index(request):
42
42
if user is None :
43
43
user = models .User .get_by_email (request .db , username , authority )
44
44
45
+ if (user is not None ) and user .deleted :
46
+ # Don't show users that're marked as deleted on admin pages.
47
+ #
48
+ # Users that're marked as deleted can't login or authenticate requests
49
+ # in any way. They're in the process of being purged by a background
50
+ # task and will soon be really deleted from the DB.
51
+ #
52
+ # Showing these users on admin pages is confusing because admins may
53
+ # have already deleted a user (so the user has been marked as deleted
54
+ # and is now going to be purged) and then think that the user has not
55
+ # been deleted successfully because they still show up on the admin
56
+ # pages.
57
+ #
58
+ # Also we don't want admins to be able to do things like rename users
59
+ # who're marked as deleted and in the process of being purged.
60
+ user = None
61
+
45
62
if user is not None :
46
63
svc = request .find_service (name = "annotation_stats" )
47
64
user_meta ["annotations_count" ] = svc .total_user_annotation_count (user .userid )
Original file line number Diff line number Diff line change @@ -94,6 +94,24 @@ def test_users_index_no_user_found(models, pyramid_request):
94
94
}
95
95
96
96
97
+ @users_index_fixtures
98
+ def test_users_index_user_marked_as_deleted (models , pyramid_request , factories ):
99
+ pyramid_request .params = {"username" : "bob" , "authority" : "foo.org" }
100
+ user = factories .User .build (username = "bob" , authority = "foo.org" , deleted = True )
101
+ models .User .get_by_username .return_value = user
102
+
103
+ result = users_index (pyramid_request )
104
+
105
+ assert result == {
106
+ "default_authority" : "example.com" ,
107
+ "username" : "bob" ,
108
+ "authority" : "foo.org" ,
109
+ "user" : None ,
110
+ "user_meta" : {},
111
+ "format_date" : format_date ,
112
+ }
113
+
114
+
97
115
@users_index_fixtures
98
116
def test_users_index_user_found (
99
117
models , pyramid_request , factories , annotation_stats_service
You can’t perform that action at this time.
0 commit comments