Commit 0ecf734288349454e721e6ffb7c04f29c5a7300a
1 parent
18f30f2f
Exists in
master
and in
2 other branches
Adding participants list and search in subject messages page
Showing
5 changed files
with
155 additions
and
13 deletions
Show diff stats
amadeus/static/js/chat.js
| ... | ... | @@ -369,11 +369,18 @@ function getParticipants(btn) { |
| 369 | 369 | }); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - var li = $(".breadcrumb").find('li:last-child'); | |
| 373 | - var li_text = $(li).html(); | |
| 372 | + var li = $(".breadcrumb").find('li:last-child'), | |
| 373 | + li_text = $(li).html(), | |
| 374 | + new_li_text = container.data('breadtext'); | |
| 375 | + | |
| 376 | + if (li_text == new_li_text) { | |
| 377 | + | |
| 378 | + $(".breadcrumb").find('li:last-child').remove(); | |
| 379 | + } | |
| 380 | + | |
| 374 | 381 | var new_li = $(li).clone(); |
| 375 | - | |
| 376 | - new_li.html(container.data('breadtext')); | |
| 382 | + | |
| 383 | + new_li.html(new_li_text); | |
| 377 | 384 | |
| 378 | 385 | $(li).html("<a href='" + container.data('breadurl') + "'>" + li_text + "</a>"); |
| 379 | 386 | $(li).append("<span class='divider'>/</span>"); |
| ... | ... | @@ -413,11 +420,17 @@ function setSearchSubmit() { |
| 413 | 420 | }); |
| 414 | 421 | } |
| 415 | 422 | |
| 416 | - var li = $(".breadcrumb").find('li:last-child'); | |
| 417 | - var li_text = $(li).html(); | |
| 423 | + var li = $(".breadcrumb").find('li:last-child'), | |
| 424 | + li_text = $(li).html(), | |
| 425 | + new_li_text = container.data('breadtext'); | |
| 426 | + | |
| 427 | + if (li_text == new_li_text) { | |
| 428 | + $(".breadcrumb").find('li:last-child').remove(); | |
| 429 | + } | |
| 430 | + | |
| 418 | 431 | var new_li = $(li).clone(); |
| 419 | - | |
| 420 | - new_li.html(container.data('breadtext')); | |
| 432 | + | |
| 433 | + new_li.html(new_li_text); | |
| 421 | 434 | |
| 422 | 435 | $(li).html("<a href='" + container.data('breadurl') + "'>" + li_text + "</a>"); |
| 423 | 436 | $(li).append("<span class='divider'>/</span>"); | ... | ... |
chat/templates/chat/list_subject.html
| ... | ... | @@ -68,7 +68,7 @@ |
| 68 | 68 | <div class="panel panel-default"> |
| 69 | 69 | <div class="panel-body"> |
| 70 | 70 | <div class="col-md-8"> |
| 71 | - <form id="search-participants" action="{% url 'chat:participants_subject' subject.id %}" method="GET" class="form-horizontal"> | |
| 71 | + <form id="search-participants" action="{% url 'chat:participants_subject' subject.id %}?type=modal" method="GET" class="form-horizontal"> | |
| 72 | 72 | <div class="form-group"> |
| 73 | 73 | <div class="col-md-11 col-sm-11 col-xs-11"> |
| 74 | 74 | <input type="text" class="form-control" name="search" value="{{ search }}" placeholder="{% trans 'Search...' %}" /> |
| ... | ... | @@ -82,7 +82,7 @@ |
| 82 | 82 | </form> |
| 83 | 83 | </div> |
| 84 | 84 | <div class="col-md-4"> |
| 85 | - <a href="{% url 'chat:participants_subject' subject.id %}" onclick="getParticipants($(this)); return false;" class="pull-right btn btn-default btn-raised btn-md">{% trans 'List all participants' %}</a> | |
| 85 | + <a href="{% url 'chat:participants_subject' subject.id %}?type=modal" onclick="getParticipants($(this)); return false;" class="pull-right btn btn-default btn-raised btn-md">{% trans 'List all participants' %}</a> | |
| 86 | 86 | </div> |
| 87 | 87 | </div> |
| 88 | 88 | </div> | ... | ... |
chat/templates/chat/subject_view.html
| ... | ... | @@ -50,7 +50,7 @@ |
| 50 | 50 | <div class="panel panel-default"> |
| 51 | 51 | <div class="panel-body"> |
| 52 | 52 | <div class="col-md-8"> |
| 53 | - <form action="" method="GET" class="form-horizontal"> | |
| 53 | + <form action="{% url 'chat:participants_subject' subject.id %}" method="GET" class="form-horizontal"> | |
| 54 | 54 | <div class="form-group"> |
| 55 | 55 | <div class="col-md-11 col-sm-11 col-xs-11"> |
| 56 | 56 | <input type="text" class="form-control" name="search" value="{{ search }}" placeholder="{% trans 'Search...' %}" /> |
| ... | ... | @@ -64,7 +64,7 @@ |
| 64 | 64 | </form> |
| 65 | 65 | </div> |
| 66 | 66 | <div class="col-md-4"> |
| 67 | - <a href="" class="pull-right btn btn-default btn-raised btn-md">{% trans 'List all participants' %}</a> | |
| 67 | + <a href="{% url 'chat:participants_subject' subject.id %}" class="pull-right btn btn-default btn-raised btn-md">{% trans 'List all participants' %}</a> | |
| 68 | 68 | </div> |
| 69 | 69 | </div> |
| 70 | 70 | </div> | ... | ... |
| ... | ... | @@ -0,0 +1,101 @@ |
| 1 | +{% extends 'subjects/view.html' %} | |
| 2 | + | |
| 3 | +{% load static i18n pagination permissions_tags subject_counter %} | |
| 4 | +{% load django_bootstrap_breadcrumbs %} | |
| 5 | + | |
| 6 | +{% block breadcrumbs %} | |
| 7 | + {{ block.super }} | |
| 8 | + | |
| 9 | + {% trans 'Messages' as bread %} | |
| 10 | + | |
| 11 | + {% breadcrumb bread 'chat:subject_view' subject.slug %} | |
| 12 | + | |
| 13 | + {% trans 'Participants' as breadp %} | |
| 14 | + | |
| 15 | + {% breadcrumb breadp 'chat:participants_subject' subject.id %} | |
| 16 | +{% endblock %} | |
| 17 | + | |
| 18 | +{% block content %} | |
| 19 | + {% subject_permissions request.user subject as has_subject_permissions %} | |
| 20 | + | |
| 21 | + {% if subject.visible %} | |
| 22 | + <div class="panel panel-info subject-panel chat-panel" id="subject_{{subject.slug}}"> | |
| 23 | + <div class="panel-heading"> | |
| 24 | + {% elif has_subject_permissions %} | |
| 25 | + <div class="panel panel-info subject-panel-invisible chat-panel" id="subject_{{subject.slug}}"> | |
| 26 | + <div class="panel-heading panel-invisible"> | |
| 27 | + {% endif %} | |
| 28 | + <div class="row"> | |
| 29 | + <div class="col-md-12 category-header"> | |
| 30 | + <h4 class="panel-title" style="margin-top: 10px; margin-bottom: 8px"> | |
| 31 | + <span>{{subject.name}}</span> | |
| 32 | + </h4> | |
| 33 | + | |
| 34 | + <div class="col-md-5 pull-right category-card-items"> | |
| 35 | + {% if request.user in subject.professor.all or request.user in subject.category.coordinators.all or request.user.is_staff %} | |
| 36 | + <a href="" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
| 37 | + <i class="fa fa-ellipsis-v" aria-hidden="true"></i> | |
| 38 | + </a> | |
| 39 | + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> | |
| 40 | + {% if request.user not in subject.professor.all %} | |
| 41 | + <li><a href="{% url 'subjects:replicate' subject.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li> | |
| 42 | + {% endif %} | |
| 43 | + <li><a href="{% url 'subjects:update' subject.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | |
| 44 | + <li><a href="{% url 'groups:index' subject.slug %}"><i class="fa fa-group fa-fw" aria-hidden="true"></i>{% trans 'Groups' %}</a></li> | |
| 45 | + <li><a href="javascript:delete_subject.get('{% url 'subjects:delete' subject.slug %}?view=index','#subject','#modal_subject')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> | |
| 46 | + </ul> | |
| 47 | + {% endif %} | |
| 48 | + | |
| 49 | + </div> | |
| 50 | + </div> | |
| 51 | + </div> | |
| 52 | + </div> | |
| 53 | + <div id="{{subject.slug}}" class="panel-collapse panel-body in collapse chat-collapse"> | |
| 54 | + <div class="panel panel-default"> | |
| 55 | + <div class="panel-body"> | |
| 56 | + <div class="col-md-8"> | |
| 57 | + <form action="" method="GET" class="form-horizontal"> | |
| 58 | + <div class="form-group"> | |
| 59 | + <div class="col-md-11 col-sm-11 col-xs-11"> | |
| 60 | + <input type="text" class="form-control" name="search" value="{{ search }}" placeholder="{% trans 'Search...' %}" /> | |
| 61 | + </div> | |
| 62 | + <div class="col-md-1 col-sm-1 col-xs-1"> | |
| 63 | + <button type="submit" class="btn btn-fab btn-fab-mini"> | |
| 64 | + <i class="fa fa-search"></i> | |
| 65 | + </button> | |
| 66 | + </div> | |
| 67 | + </div> | |
| 68 | + </form> | |
| 69 | + </div> | |
| 70 | + <div class="col-md-4"> | |
| 71 | + <a href="" class="pull-right btn btn-default btn-raised btn-md">{% trans 'List all participants' %}</a> | |
| 72 | + </div> | |
| 73 | + </div> | |
| 74 | + </div> | |
| 75 | + | |
| 76 | + {% if participants.count > 0 %} | |
| 77 | + <div class="panel category-panel-content panel-body"> | |
| 78 | + <h2 class="my-subjects-title"><b>{% trans 'Participants' %}</b></h2> | |
| 79 | + | |
| 80 | + <div class="talks-group"> | |
| 81 | + {% for participant in participants %} | |
| 82 | + {% include 'chat/_view_participant.html' with space=subject.id space_type='subject' %} | |
| 83 | + {% endfor %} | |
| 84 | + </div> | |
| 85 | + | |
| 86 | + {% pagination request paginator page_obj %} | |
| 87 | + </div> | |
| 88 | + {% else %} | |
| 89 | + <div class="text-center no-subjects"> | |
| 90 | + <i class="fa fa-envelope-o"></i> | |
| 91 | + <h4>{% trans 'There is no other participants in this space yet.' %}</h4> | |
| 92 | + </div> | |
| 93 | + {% endif %} | |
| 94 | + </div> | |
| 95 | + | |
| 96 | + <div class="modal fade" id="chat-modal-info" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"></div> | |
| 97 | + | |
| 98 | + <div class="modal fade" id="chat-modal-form" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"></div> | |
| 99 | + | |
| 100 | + <script type="text/javascript" src="{% static 'js/chat.js' %}"></script> | |
| 101 | +{% endblock %} | |
| 0 | 102 | \ No newline at end of file | ... | ... |
chat/views.py
| ... | ... | @@ -233,6 +233,18 @@ class SubjectParticipants(LoginRequiredMixin, generic.ListView): |
| 233 | 233 | |
| 234 | 234 | template_name = 'chat/_participants.html' |
| 235 | 235 | context_object_name = "participants" |
| 236 | + paginate_by = None | |
| 237 | + | |
| 238 | + def dispatch(self, request, *args,**kwargs): | |
| 239 | + typep = self.request.GET.get('type', '') | |
| 240 | + | |
| 241 | + if not typep == 'modal': | |
| 242 | + subject = get_object_or_404(Subject, id = kwargs.get('subject', 0)) | |
| 243 | + | |
| 244 | + if not has_subject_view_permissions(request.user, subject): | |
| 245 | + return redirect(reverse_lazy('subjects:home')) | |
| 246 | + | |
| 247 | + return super(SubjectParticipants, self).dispatch(request, *args, **kwargs) | |
| 236 | 248 | |
| 237 | 249 | def get_queryset(self): |
| 238 | 250 | user = self.request.user |
| ... | ... | @@ -240,12 +252,28 @@ class SubjectParticipants(LoginRequiredMixin, generic.ListView): |
| 240 | 252 | search = self.request.GET.get('search', '') |
| 241 | 253 | |
| 242 | 254 | 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__id = sub) | Q(professors__id = sub) | Q(coordinators__subject_category__id = sub))).distinct().order_by('social_name','username').exclude(email = user.email) |
| 243 | - | |
| 255 | + | |
| 256 | + typep = self.request.GET.get('type', '') | |
| 257 | + | |
| 258 | + if not typep == 'modal': | |
| 259 | + self.paginate_by = 10 | |
| 260 | + | |
| 244 | 261 | return users |
| 245 | 262 | |
| 246 | 263 | def get_context_data(self, **kwargs): |
| 247 | 264 | context = super(SubjectParticipants, self).get_context_data(**kwargs) |
| 248 | 265 | |
| 266 | + typep = self.request.GET.get('type', '') | |
| 267 | + | |
| 268 | + if not typep == 'modal': | |
| 269 | + sub = self.kwargs.get('subject', 0) | |
| 270 | + subject = get_object_or_404(Subject, id = sub) | |
| 271 | + | |
| 272 | + context['subject'] = subject | |
| 273 | + context['search'] = self.request.GET.get('search', '') | |
| 274 | + context['title'] = _('%s - Participants')%(str(subject)) | |
| 275 | + self.template_name = 'chat/subject_view_participants.html' | |
| 276 | + | |
| 249 | 277 | context['space'] = self.kwargs.get('subject', 0) |
| 250 | 278 | context['space_type'] = 'subject' |
| 251 | 279 | ... | ... |