0002-manager-search-deleted-users-by-email-51808.patch
src/authentic2/manager/journal_views.py | ||
---|---|---|
19 | 19 | |
20 | 20 |
from django import forms |
21 | 21 |
from django.contrib.auth import get_user_model |
22 |
from django.contrib.contenttypes.models import ContentType |
|
22 | 23 |
from django.core.exceptions import PermissionDenied, ValidationError |
23 | 24 |
from django.core.validators import EmailValidator |
24 | 25 |
from django.db.models import Q |
25 | 26 |
from django.utils.translation import ugettext_lazy as _ |
26 | 27 | |
28 |
from authentic2.custom_user.models import DeletedUser |
|
29 |
from authentic2.apps.journal.models import n_2_pairing |
|
27 | 30 |
from authentic2.apps.journal.forms import JournalForm |
28 | 31 |
from authentic2.apps.journal.models import EventType |
29 | 32 |
from authentic2.apps.journal.search_engine import JournalSearchEngine |
... | ... | |
71 | 74 |
users = User.objects.find_duplicates(fullname=fullname) |
72 | 75 |
return self.query_for_users(users) |
73 | 76 | |
77 |
def search_by_email(self, email): |
|
78 |
yield from super().search_by_email(email) |
|
79 |
pks = list(DeletedUser.objects.filter(old_email=email).values_list('old_user_id', flat=True)) |
|
80 |
yield Q(user_id__in=pks) |
|
81 |
user_ct = ContentType.objects.get_for_model(User) |
|
82 |
yield Q(reference_ids__contains=[n_2_pairing(user_ct.id, pk) for pk in pks]) |
|
83 | ||
74 | 84 | |
75 | 85 |
EVENT_TYPE_CHOICES = ( |
76 | 86 |
('', _('All')), |
tests/test_manager_journal.py | ||
---|---|---|
987 | 987 |
response.form.set('search', 'email:jane@example.com') |
988 | 988 |
response = response.form.submit() |
989 | 989 |
assert ( |
990 |
text_content(response.pyquery('tbody tr td.journal-list--message-column')[0]).strip()
|
|
990 |
text_content(response.pyquery('tbody tr td.journal-list--message-column')[12]).strip()
|
|
991 | 991 |
== 'email change of user "Johnny doe" for email address "jane@example.com"' |
992 | 992 |
) |
993 | 993 | |
994 | 994 |
response.form.set('search', 'jane@example.com') |
995 | 995 |
response = response.form.submit() |
996 | 996 |
assert ( |
997 |
text_content(response.pyquery('tbody tr td.journal-list--message-column')[0]).strip()
|
|
997 |
text_content(response.pyquery('tbody tr td.journal-list--message-column')[12]).strip()
|
|
998 | 998 |
== 'email change of user "Johnny doe" for email address "jane@example.com"' |
999 | 999 |
) |
1000 | 1000 | |
1001 |
- |