Commit 2c6305908f911cfc1885e6130d61ebe000c07b03
1 parent
15681d51
Exists in
master
and in
3 other branches
Adding general participants search
Showing
3 changed files
with
7 additions
and
5 deletions
Show diff stats
chat/templates/chat/list.html
... | ... | @@ -26,10 +26,10 @@ |
26 | 26 | <div class="panel panel-default"> |
27 | 27 | <div class="panel-body"> |
28 | 28 | <div class="col-md-8"> |
29 | - <form action="" method="GET" class="form-horizontal"> | |
29 | + <form action="{% url 'chat:participants_general' %}" method="GET" class="form-horizontal"> | |
30 | 30 | <div class="form-group"> |
31 | 31 | <div class="col-md-11 col-sm-11 col-xs-11"> |
32 | - <input type="text" class="form-control" name="search" placeholder="{% trans 'Search...' %}" /> | |
32 | + <input type="text" class="form-control" name="search" value="{{ search }}" placeholder="{% trans 'Search...' %}" /> | |
33 | 33 | </div> |
34 | 34 | <div class="col-md-1 col-sm-1 col-xs-1"> |
35 | 35 | <button type="submit" class="btn btn-fab btn-fab-mini"> | ... | ... |
chat/templates/chat/list_participants.html
... | ... | @@ -28,10 +28,10 @@ |
28 | 28 | <div class="panel panel-default"> |
29 | 29 | <div class="panel-body"> |
30 | 30 | <div class="col-md-8"> |
31 | - <form action="" method="GET" class="form-horizontal"> | |
31 | + <form action="{% url 'chat:participants_general' %}" method="GET" class="form-horizontal"> | |
32 | 32 | <div class="form-group"> |
33 | 33 | <div class="col-md-11 col-sm-11 col-xs-11"> |
34 | - <input type="text" class="form-control" name="search" placeholder="{% trans 'Search...' %}" /> | |
34 | + <input type="text" class="form-control" name="search" value="{{ search }}" placeholder="{% trans 'Search...' %}" /> | |
35 | 35 | </div> |
36 | 36 | <div class="col-md-1 col-sm-1 col-xs-1"> |
37 | 37 | <button type="submit" class="btn btn-fab btn-fab-mini"> | ... | ... |
chat/views.py
... | ... | @@ -60,8 +60,9 @@ class GeneralParticipants(LoginRequiredMixin, generic.ListView): |
60 | 60 | |
61 | 61 | def get_queryset(self): |
62 | 62 | user = self.request.user |
63 | + search = self.request.GET.get('search', '') | |
63 | 64 | |
64 | - users = User.objects.all().exclude(id = user.id).order_by('social_name','username') | |
65 | + users = User.objects.filter(Q(username__icontains = search) | Q(last_name__icontains = search) | Q(social_name__icontains = search) | Q(email__icontains = search)).distinct().order_by('social_name','username').exclude(email = user.email) | |
65 | 66 | |
66 | 67 | self.totals['general'] = ChatVisualizations.objects.filter(user = user, viewed = False, message__talk__generaltalk__isnull = False).count() |
67 | 68 | self.totals['category'] = ChatVisualizations.objects.filter(user = user, viewed = False, message__talk__categorytalk__isnull = False).count() |
... | ... | @@ -74,6 +75,7 @@ class GeneralParticipants(LoginRequiredMixin, generic.ListView): |
74 | 75 | |
75 | 76 | context['title'] = _('Messages - Participants') |
76 | 77 | context['totals'] = self.totals |
78 | + context['search'] = self.request.GET.get('search') | |
77 | 79 | context['chat_menu_active'] = 'subjects_menu_active' |
78 | 80 | |
79 | 81 | return context | ... | ... |