diff --git a/amadeus/static/js/chat.js b/amadeus/static/js/chat.js index e7cd984..17410cb 100644 --- a/amadeus/static/js/chat.js +++ b/amadeus/static/js/chat.js @@ -369,11 +369,18 @@ function getParticipants(btn) { }); } - var li = $(".breadcrumb").find('li:last-child'); - var li_text = $(li).html(); + var li = $(".breadcrumb").find('li:last-child'), + li_text = $(li).html(), + new_li_text = container.data('breadtext'); + + if (li_text == new_li_text) { + + $(".breadcrumb").find('li:last-child').remove(); + } + var new_li = $(li).clone(); - - new_li.html(container.data('breadtext')); + + new_li.html(new_li_text); $(li).html("" + li_text + ""); $(li).append("/"); @@ -413,11 +420,17 @@ function setSearchSubmit() { }); } - var li = $(".breadcrumb").find('li:last-child'); - var li_text = $(li).html(); + var li = $(".breadcrumb").find('li:last-child'), + li_text = $(li).html(), + new_li_text = container.data('breadtext'); + + if (li_text == new_li_text) { + $(".breadcrumb").find('li:last-child').remove(); + } + var new_li = $(li).clone(); - - new_li.html(container.data('breadtext')); + + new_li.html(new_li_text); $(li).html("" + li_text + ""); $(li).append("/"); diff --git a/chat/templates/chat/list_subject.html b/chat/templates/chat/list_subject.html index 6726f7e..72813ac 100644 --- a/chat/templates/chat/list_subject.html +++ b/chat/templates/chat/list_subject.html @@ -68,7 +68,7 @@
diff --git a/chat/templates/chat/subject_view.html b/chat/templates/chat/subject_view.html index 30354ce..eee223a 100644 --- a/chat/templates/chat/subject_view.html +++ b/chat/templates/chat/subject_view.html @@ -50,7 +50,7 @@
diff --git a/chat/templates/chat/subject_view_participants.html b/chat/templates/chat/subject_view_participants.html new file mode 100644 index 0000000..3c5b478 --- /dev/null +++ b/chat/templates/chat/subject_view_participants.html @@ -0,0 +1,101 @@ +{% extends 'subjects/view.html' %} + +{% load static i18n pagination permissions_tags subject_counter %} +{% load django_bootstrap_breadcrumbs %} + +{% block breadcrumbs %} + {{ block.super }} + + {% trans 'Messages' as bread %} + + {% breadcrumb bread 'chat:subject_view' subject.slug %} + + {% trans 'Participants' as breadp %} + + {% breadcrumb breadp 'chat:participants_subject' subject.id %} +{% endblock %} + +{% block content %} + {% subject_permissions request.user subject as has_subject_permissions %} + + {% if subject.visible %} +
+
+ {% elif has_subject_permissions %} +
+
+ {% endif %} +
+
+

+ {{subject.name}} +

+ +
+ {% if request.user in subject.professor.all or request.user in subject.category.coordinators.all or request.user.is_staff %} + + + {% endif %} + +
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ + {% if participants.count > 0 %} +
+

{% trans 'Participants' %}

+ +
+ {% for participant in participants %} + {% include 'chat/_view_participant.html' with space=subject.id space_type='subject' %} + {% endfor %} +
+ + {% pagination request paginator page_obj %} +
+ {% else %} +
+ +

{% trans 'There is no other participants in this space yet.' %}

+
+ {% endif %} +
+ + + + + + +{% endblock %} \ No newline at end of file diff --git a/chat/views.py b/chat/views.py index f89ef10..c51ff2f 100644 --- a/chat/views.py +++ b/chat/views.py @@ -233,6 +233,18 @@ class SubjectParticipants(LoginRequiredMixin, generic.ListView): template_name = 'chat/_participants.html' context_object_name = "participants" + paginate_by = None + + def dispatch(self, request, *args,**kwargs): + typep = self.request.GET.get('type', '') + + if not typep == 'modal': + subject = get_object_or_404(Subject, id = kwargs.get('subject', 0)) + + if not has_subject_view_permissions(request.user, subject): + return redirect(reverse_lazy('subjects:home')) + + return super(SubjectParticipants, self).dispatch(request, *args, **kwargs) def get_queryset(self): user = self.request.user @@ -240,12 +252,28 @@ class SubjectParticipants(LoginRequiredMixin, generic.ListView): search = self.request.GET.get('search', '') 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) - + + typep = self.request.GET.get('type', '') + + if not typep == 'modal': + self.paginate_by = 10 + return users def get_context_data(self, **kwargs): context = super(SubjectParticipants, self).get_context_data(**kwargs) + typep = self.request.GET.get('type', '') + + if not typep == 'modal': + sub = self.kwargs.get('subject', 0) + subject = get_object_or_404(Subject, id = sub) + + context['subject'] = subject + context['search'] = self.request.GET.get('search', '') + context['title'] = _('%s - Participants')%(str(subject)) + self.template_name = 'chat/subject_view_participants.html' + context['space'] = self.kwargs.get('subject', 0) context['space_type'] = 'subject' -- libgit2 0.21.2