Commit 5afc27b5c7a04bc241cc9cbf036dc7acc78b62dc
1 parent
83d82188
Exists in
master
and in
3 other branches
Adding category participants search
Showing
4 changed files
with
45 additions
and
3 deletions
Show diff stats
amadeus/static/css/base/amadeus.css
@@ -1344,8 +1344,8 @@ div.dataTables_wrapper div.dataTables_paginate { | @@ -1344,8 +1344,8 @@ div.dataTables_wrapper div.dataTables_paginate { | ||
1344 | padding: 7px 15px; | 1344 | padding: 7px 15px; |
1345 | } | 1345 | } |
1346 | .participant .user-info .status, .modal_profile_sidebar .status { | 1346 | .participant .user-info .status, .modal_profile_sidebar .status { |
1347 | - width: 20px; | ||
1348 | - height: 20px; | 1347 | + width: 12px; |
1348 | + height: 12px; | ||
1349 | border-width: 1px; | 1349 | border-width: 1px; |
1350 | border-style: solid; | 1350 | border-style: solid; |
1351 | border-radius: 10px; | 1351 | border-radius: 10px; |
amadeus/static/js/chat.js
@@ -370,6 +370,44 @@ function getParticipants(btn) { | @@ -370,6 +370,44 @@ function getParticipants(btn) { | ||
370 | }); | 370 | }); |
371 | } | 371 | } |
372 | 372 | ||
373 | +function setSearchSubmit() { | ||
374 | + var frm = $("#search-participants"), | ||
375 | + content_section = frm.parent().parent().parent().parent().find('.content'); | ||
376 | + | ||
377 | + frm.submit(function (e) { | ||
378 | + e.preventDefault(); | ||
379 | + e.stopImmediatePropagation(); | ||
380 | + | ||
381 | + $.ajax({ | ||
382 | + type: frm.attr('method'), | ||
383 | + url: frm.attr('action'), | ||
384 | + data: {'search': frm.find("input[name='search']").val()}, | ||
385 | + success: function (response) { | ||
386 | + | ||
387 | + content_section.html(response); | ||
388 | + | ||
389 | + var items = $('#content-list').children(":visible").length; | ||
390 | + var holder = content_section.find('.holder'); | ||
391 | + | ||
392 | + if (items > 10) { | ||
393 | + holder.jPages({ | ||
394 | + containerID : "content-list", | ||
395 | + perPage: 10, | ||
396 | + previous: "«", | ||
397 | + next: "»", | ||
398 | + midRange: 5 | ||
399 | + }); | ||
400 | + } | ||
401 | + }, | ||
402 | + error: function(data) { | ||
403 | + setSearchSubmit(); | ||
404 | + }, | ||
405 | + }); | ||
406 | + | ||
407 | + return false; | ||
408 | + }); | ||
409 | +} | ||
410 | + | ||
373 | $('.chat-collapse').on('shown.bs.collapse', function(e) { | 411 | $('.chat-collapse').on('shown.bs.collapse', function(e) { |
374 | if($(this).is(e.target)){ | 412 | if($(this).is(e.target)){ |
375 | var li = $(".breadcrumb").find('li:last-child'); | 413 | var li = $(".breadcrumb").find('li:last-child'); |
@@ -388,6 +426,8 @@ $('.chat-collapse').on('shown.bs.collapse', function(e) { | @@ -388,6 +426,8 @@ $('.chat-collapse').on('shown.bs.collapse', function(e) { | ||
388 | 426 | ||
389 | var url = $(this).data('url'); | 427 | var url = $(this).data('url'); |
390 | 428 | ||
429 | + setSearchSubmit(); | ||
430 | + | ||
391 | $.ajax({ | 431 | $.ajax({ |
392 | url: url, | 432 | url: url, |
393 | success: function (response) { | 433 | success: function (response) { |
chat/templates/chat/list_category.html
@@ -68,7 +68,7 @@ | @@ -68,7 +68,7 @@ | ||
68 | <div class="panel panel-default"> | 68 | <div class="panel panel-default"> |
69 | <div class="panel-body"> | 69 | <div class="panel-body"> |
70 | <div class="col-md-8"> | 70 | <div class="col-md-8"> |
71 | - <form action="{% url 'chat:participants_general' %}" method="GET" class="form-horizontal"> | 71 | + <form id="search-participants" action="{% url 'chat:participants_category' category.id %}" method="GET" class="form-horizontal"> |
72 | <div class="form-group"> | 72 | <div class="form-group"> |
73 | <div class="col-md-11 col-sm-11 col-xs-11"> | 73 | <div class="col-md-11 col-sm-11 col-xs-11"> |
74 | <input type="text" class="form-control" name="search" value="{{ search }}" placeholder="{% trans 'Search...' %}" /> | 74 | <input type="text" class="form-control" name="search" value="{{ search }}" placeholder="{% trans 'Search...' %}" /> |
chat/views.py
@@ -159,6 +159,8 @@ class CategoryParticipants(LoginRequiredMixin, generic.ListView): | @@ -159,6 +159,8 @@ class CategoryParticipants(LoginRequiredMixin, generic.ListView): | ||
159 | cat = self.kwargs.get('category', 0) | 159 | cat = self.kwargs.get('category', 0) |
160 | search = self.request.GET.get('search', '') | 160 | search = self.request.GET.get('search', '') |
161 | 161 | ||
162 | + print(search) | ||
163 | + | ||
162 | users = User.objects.filter((Q(username__icontains = search) | Q(last_name__icontains = search) | Q(social_name__icontains = search) | Q(email__icontains = search)) & (Q(is_staff = True) | Q(subject_student__category__id = cat) | Q(professors__category__id = cat) | Q(coordinators__id = cat))).distinct().order_by('social_name','username').exclude(email = user.email) | 164 | users = User.objects.filter((Q(username__icontains = search) | Q(last_name__icontains = search) | Q(social_name__icontains = search) | Q(email__icontains = search)) & (Q(is_staff = True) | Q(subject_student__category__id = cat) | Q(professors__category__id = cat) | Q(coordinators__id = cat))).distinct().order_by('social_name','username').exclude(email = user.email) |
163 | 165 | ||
164 | return users | 166 | return users |