Commit 61d1d9ec authored by xiaoyu's avatar xiaoyu

temp

parent 22089282
......@@ -4,9 +4,10 @@
import logging
from rest_framework import generics
from rest_framework_bulk import ListBulkCreateUpdateDestroyAPIView
from .serializers import UserSerializer, UserGroupSerializer, UserAttributeSerializer, UserGroupEditSerializer, \
GroupEditSerializer, UserPKUpdateSerializer
GroupEditSerializer, UserPKUpdateSerializer, UserBulkUpdateSerializer
from .models import User, UserGroup
......@@ -92,3 +93,8 @@ class UserUpdatePKApi(generics.UpdateAPIView):
class GroupDeleteApi(generics.DestroyAPIView):
queryset = UserGroup.objects.all()
serializer_class = GroupEditSerializer
class UserBulkUpdateApi(ListBulkCreateUpdateDestroyAPIView):
queryset = User.objects.all()
serializer_class = UserBulkUpdateSerializer
......@@ -3,6 +3,7 @@
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from rest_framework_bulk import BulkListSerializer, BulkSerializerMixin
from .models import User, UserGroup
......@@ -67,3 +68,10 @@ class UserPKUpdateSerializer(serializers.ModelSerializer):
print e
raise serializers.ValidationError(_('Not a valid ssh public key'))
return value
class UserBulkUpdateSerializer(BulkSerializerMixin, serializers.ModelSerializer):
class Meta(object):
model = User
list_serializer_class = BulkListSerializer
......@@ -22,7 +22,7 @@
{% for user in object_list %}
<tr class="gradeX">
<td class="text-center">
<input type="checkbox" name="checked" value="{{ user.id }}">
<input type="checkbox" name="checked" value="{{ user.id }}" class="ipt_bulk_update">
</td>
<td class="text-center">
<a href="{% url 'users:user-detail' pk=user.id %}">
......@@ -50,23 +50,38 @@
{% endblock %}
{% block content_bottom_left %}
<form id="" method="get" action="" class=" mail-search">
<div class="input-group">
<select class="form-control m-b" style="width: auto">
<option>{% trans 'Delete selected' %}</option>
<option>{% trans 'Update selected' %}</option>
<option>{% trans 'Deactive selected' %}</option>
<option>{% trans 'Export selected' %}</option>
<select class="form-control m-b" style="width: auto" id="slct_bulk_update">
<option value="delete">{% trans 'Delete selected' %}</option>
<option value="update">{% trans 'Update selected' %}</option>
<option value="deactive">{% trans 'Deactive selected' %}</option>
<option value="export">{% trans 'Export selected' %}</option>
</select>
<div class="input-group-btn pull-left" style="padding-left: 5px;">
<button id='search_btn' type="submit" style="height: 32px;" class="btn btn-sm btn-primary">
<button id='btn_bulk_update' style="height: 32px;" class="btn btn-sm btn-primary">
{% trans 'Submit' %}
</button>
</div>
</div>
</form>
{% endblock %}
{% block custom_foot_js %}
<script>
jumpserver.bulk_delete = function(){
}
$(document).on('click', '#btn_bulk_update', function(){
var action = $('#slct_bulk_update').val();
var id_list = $('.ipt_bulk_update:checked').map(function(){return {'id': $(this).val()}}).get();
console.log(id_list);
function doDeactive() {
var body = $.each(id_list, function(dict, index) {
})
};
switch(action) {
case 'deactive':
}
})
</script>
{% endblock %}
......@@ -36,6 +36,7 @@ urlpatterns = [
urlpatterns += [
url(r'^v1/users$', api.UserListAddApi.as_view(), name='user-list-api'),
url(r'^v1/users/update/$', api.UserBulkUpdateApi.as_view(), name='user-bulk-update-api'),
url(r'^v1/users/(?P<pk>[0-9]+)$',
api.UserDetailDeleteUpdateApi.as_view(), name='user-detail-api'),
url(r'^v1/users/(?P<pk>[0-9]+)/patch$',
......
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 to comment