Commit 9c17da03 by Szeberényi Imre

Merge branch 'group_remove_all_users' into 'master'

Group remove all users

See merge request !422
parents 479d230f af154f27
Pipeline #1395 passed with stage
in 0 seconds
......@@ -29,7 +29,7 @@ $(function () {
return false;
});
$('.group-create, .node-create, .tx-tpl-ownership, .group-delete, .node-delete, .disk-remove, .template-delete, .delete-from-group, .lease-delete').click(function(e) {
$('.group-create, .node-create, .tx-tpl-ownership, .group-delete, .node-delete, .disk-remove, .template-delete, .delete-from-group, .group-remove-all-btn, .lease-delete').click(function(e) {
$.ajax({
type: 'GET',
url: $(this).prop('href'),
......
......@@ -806,6 +806,10 @@ textarea[name="new_members"] {
margin-top: -6px;
}
.group-remove-all-btn {
margin-right: 5px;
}
.store-action-button {
margin-left: 5px;
}
......
......@@ -82,6 +82,9 @@
{% trans "Create user" %}
</a>
{% endif %}
<a data-group_pk="{{ group.pk }}" href="{% url "dashboard.views.remove-all-users" group_pk=group.pk %}" class="btn btn-danger group-remove-all-btn pull-right">
{% trans "Remove all users" %}
</a>
</h3>
<form action="" method="post">{% csrf_token %}
<table class="table table-striped table-with-form-fields table-bordered" id="group-detail-user-table">
......
......@@ -32,6 +32,7 @@ from .views import (
DiskRemoveView, get_disk_download_status,
GroupRemoveUserView,
GroupRemoveFutureUserView,
GroupRemoveAllUsersView,
GroupCreate, GroupProfileUpdate,
TemplateChoose,
UserCreationView,
......@@ -192,6 +193,9 @@ urlpatterns = [
url(r'^group/(?P<group_pk>\d+)/remove/futureuser/(?P<member_org_id>.+)/$',
GroupRemoveFutureUserView.as_view(),
name="dashboard.views.remove-future-user"),
url(r'^group/(?P<group_pk>\d+)/remove/user/all/$',
GroupRemoveAllUsersView.as_view(),
name="dashboard.views.remove-all-users"),
url(r'^group/create/$', GroupCreate.as_view(),
name='dashboard.views.group-create'),
url(r'^group/(?P<group_pk>\d+)/permissions/$',
......
......@@ -285,6 +285,33 @@ class GroupRemoveFutureUserView(GroupRemoveUserView):
group=self.get_object()).delete()
class GroupRemoveAllUsersView(DeleteViewBase):
model = Group
level = 'operator'
slug_field = 'pk'
slug_url_kwarg = 'group_pk'
success_message = _("All users successfully removed from group.")
def check_auth(self):
if not self.get_object().profile.has_level(
self.request.user, self.level):
raise PermissionDenied()
def get_context_data(self, **kwargs):
context = super(GroupRemoveAllUsersView, self).get_context_data(**kwargs)
context['member'] = _("all users")
return context
def get_success_url(self):
return reverse_lazy("dashboard.views.group-detail",
kwargs={'pk': self.get_object().pk})
def delete_obj(self, request, *args, **kwargs):
container = self.get_object()
container.user_set.clear()
FutureMember.objects.filter(group=container).delete()
class GroupDelete(DeleteViewBase):
model = Group
success_message = _("Group successfully deleted.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment