diff --git a/amadeus/static/css/themes/green.css b/amadeus/static/css/themes/green.css index 578b447..8ea9336 100644 --- a/amadeus/static/css/themes/green.css +++ b/amadeus/static/css/themes/green.css @@ -67,6 +67,11 @@ a, a:focus, a:hover { color: #000000 !important; } +.group-panel-body { + background: #FFFFFF !important; + border-top: 1px solid #CCCCCC; +} + .topic-panel > .panel-heading { background-color: #7BA5B9 !important; } diff --git a/amadeus/static/js/course.js b/amadeus/static/js/course.js index 5a2f95d..ba8ba19 100755 --- a/amadeus/static/js/course.js +++ b/amadeus/static/js/course.js @@ -193,4 +193,14 @@ $('.collapse').on('hide.bs.collapse', function (e) { }); } } -}); \ No newline at end of file +}); + +function delete_group(url) { + $('.modal').remove(); + + $.get(url, function (modal) { + $("#group-accordion").after(modal); + + $('.modal').modal('show'); + }); +} \ No newline at end of file diff --git a/students_group/models.py b/students_group/models.py index 9a650db..c066a91 100644 --- a/students_group/models.py +++ b/students_group/models.py @@ -17,6 +17,7 @@ class StudentsGroup(models.Model): class Meta: verbose_name = _('Students Group') verbose_name_plural = _('Students Groups') + ordering = ['name'] def __str__(self): return self.name \ No newline at end of file diff --git a/students_group/templates/groups/delete.html b/students_group/templates/groups/delete.html new file mode 100644 index 0000000..01de76a --- /dev/null +++ b/students_group/templates/groups/delete.html @@ -0,0 +1,23 @@ +{% load i18n %} + + \ No newline at end of file diff --git a/students_group/templates/groups/index.html b/students_group/templates/groups/index.html index 90d418c..ff08eb7 100644 --- a/students_group/templates/groups/index.html +++ b/students_group/templates/groups/index.html @@ -33,15 +33,15 @@
-
+ +
+ {% autoescape off %} + {{ group.description }} + {% endautoescape %} +

{% trans 'Participant(s)' %}:

+ +
    + {% for user in group.participants.all %} +
  • + +

    {{ user }}

    +
  • + {% endfor %} +
+
+
{% endfor %} {% pagination request paginator page_obj %}
+ {% endblock %} \ No newline at end of file diff --git a/students_group/urls.py b/students_group/urls.py index 59ea5a5..97d987a 100644 --- a/students_group/urls.py +++ b/students_group/urls.py @@ -6,4 +6,5 @@ urlpatterns = [ url(r'^create/(?P[\w_-]+)/$', views.CreateView.as_view(), name='create'), url(r'^update/(?P[\w_-]+)/(?P[\w_-]+)/$', views.UpdateView.as_view(), name='update'), url(r'^replicate/(?P[\w_-]+)/(?P[\w_-]+)/$', views.CreateView.as_view(), name='replicate'), + url(r'^delete/(?P[\w_-]+)/$', views.DeleteView.as_view(), name = 'delete'), ] \ No newline at end of file diff --git a/students_group/views.py b/students_group/views.py index 9fe3c3b..5dc8549 100644 --- a/students_group/views.py +++ b/students_group/views.py @@ -149,4 +149,26 @@ class UpdateView(LoginRequiredMixin, generic.UpdateView): def get_success_url(self): messages.success(self.request, _('The group "%s" was updated successfully!')%(self.object.name)) + return reverse_lazy('groups:index', kwargs = {'slug': self.object.subject.slug}) + +class DeleteView(LoginRequiredMixin, generic.DeleteView): + login_url = reverse_lazy("users:login") + redirect_field_name = 'next' + + template_name = 'groups/delete.html' + model = StudentsGroup + context_object_name = 'group' + + def dispatch(self, request, *args, **kwargs): + slug = self.kwargs.get('slug', '') + group = get_object_or_404(StudentsGroup, slug = slug) + + if not has_subject_permissions(request.user, group.subject): + return redirect(reverse_lazy('subjects:home')) + + return super(DeleteView, self).dispatch(request, *args, **kwargs) + + def get_success_url(self): + messages.success(self.request, _('The group "%s" was removed successfully!')%(self.object.name)) + return reverse_lazy('groups:index', kwargs = {'slug': self.object.subject.slug}) \ No newline at end of file diff --git a/users/templates/users/search.html b/users/templates/users/search.html index aa173f4..64e8943 100644 --- a/users/templates/users/search.html +++ b/users/templates/users/search.html @@ -29,7 +29,7 @@ @@ -53,7 +53,7 @@ diff --git a/users/views.py b/users/views.py index 8274c09..bc25fcc 100644 --- a/users/views.py +++ b/users/views.py @@ -72,7 +72,7 @@ class SearchView(braces_mixins.LoginRequiredMixin, braces_mixins.StaffuserRequir def get_queryset(self): 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)).order_by('social_name','username').exclude(email = self.request.user.email) + 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 = self.request.user.email) return users -- libgit2 0.21.2