mirror of https://github.com/jumpserver/jumpserver
[BugFix] update some user import bug
parent
eae580e51f
commit
c1a74aebc5
|
@ -40,10 +40,9 @@ class NoDeleteModelMixin(models.Model):
|
|||
|
||||
|
||||
class JSONResponseMixin(object):
|
||||
|
||||
"""JSON mixin"""
|
||||
|
||||
def render_json_response(self, context):
|
||||
@staticmethod
|
||||
def render_json_response(context):
|
||||
return JsonResponse(context)
|
||||
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ class UserViewSet(BulkModelViewSet):
|
|||
serializer_class = serializers.UserSerializer
|
||||
permission_classes = (IsSuperUser,)
|
||||
|
||||
def allow_bulk_destroy(self, qs, filtered):
|
||||
return qs is not filtered
|
||||
|
||||
|
||||
class UserUpdateGroupApi(generics.RetrieveUpdateAPIView):
|
||||
queryset = User.objects.all()
|
||||
|
|
|
@ -79,7 +79,7 @@ class User(AbstractUser):
|
|||
role = models.CharField(choices=ROLE_CHOICES, default='User', max_length=10, blank=True, verbose_name=_('Role'))
|
||||
avatar = models.ImageField(upload_to="avatar", verbose_name=_('Avatar'))
|
||||
wechat = models.CharField(max_length=30, blank=True, verbose_name=_('Wechat'))
|
||||
phone = models.CharField(max_length=20, blank=True, verbose_name=_('Phone'))
|
||||
phone = models.CharField(max_length=20, blank=True, null=True, verbose_name=_('Phone'))
|
||||
enable_otp = models.BooleanField(default=False, verbose_name=_('Enable OTP'))
|
||||
secret_key_otp = models.CharField(max_length=16, blank=True)
|
||||
_private_key = models.CharField(max_length=5000, blank=True, verbose_name=_('ssh private key'))
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-9 col-lg-9 col-sm-offset-2">
|
||||
<div class="checkbox checkbox-success">
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" name="enable_otp" checked id="id_enable_otp"><label for="id_enable_otp">{% trans 'Enable-OTP' %}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -117,11 +117,11 @@ $(document).ready(function(){
|
|||
$('<span />', {class: 'help-block text-danger'}).html(data.msg).insertAfter($('#id_users'));
|
||||
} else {
|
||||
$('#id_created').html(data.created_info);
|
||||
$('#id_created_detail').html(data.created.join(','));
|
||||
$('#id_created_detail').html(data.created.join(', '));
|
||||
$('#id_updated').html(data.updated_info);
|
||||
$('#id_updated_detail').html(data.updated.join(','));
|
||||
$('#id_updated_detail').html(data.updated.join(', '));
|
||||
$('#id_failed').html(data.failed_info);
|
||||
$('#id_failed_detail').html(data.failed.join(','));
|
||||
$('#id_failed_detail').html(data.failed.join(', '));
|
||||
var $data_table = $('#user_list_table').DataTable();
|
||||
$data_table.ajax.reload();
|
||||
}
|
||||
|
|
|
@ -530,8 +530,9 @@ class BulkImportUserView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
|
|||
groups = None
|
||||
try:
|
||||
user = User.objects.create(**user_dict)
|
||||
user_add_success_next(user)
|
||||
created.append(user_dict['username'])
|
||||
except IntegrityError:
|
||||
except IntegrityError as e:
|
||||
user = User.objects.filter(username=user_dict['username'])
|
||||
if not user:
|
||||
failed.append(user_dict['username'])
|
||||
|
@ -539,7 +540,8 @@ class BulkImportUserView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
|
|||
user.update(**user_dict)
|
||||
user = user[0]
|
||||
updated.append(user_dict['username'])
|
||||
except TypeError:
|
||||
except TypeError as e:
|
||||
print(e)
|
||||
failed.append(user_dict['username'])
|
||||
user = None
|
||||
|
||||
|
|
Loading…
Reference in New Issue