(self, instance, user_id, with_valid=True)
| 361 | |
| 362 | @transaction.atomic |
| 363 | def save(self, instance, user_id, with_valid=True): |
| 364 | if with_valid: |
| 365 | if instance.get('encrypted'): |
| 366 | instance['password'] = decrypt(instance.get('password')) |
| 367 | self.UserInstance(data=instance).is_valid(raise_exception=True) |
| 368 | |
| 369 | user = User( |
| 370 | id=uuid.uuid7(), |
| 371 | email=instance.get('email'), |
| 372 | phone=instance.get('phone', ''), |
| 373 | nick_name=instance.get('nick_name', ''), |
| 374 | username=instance.get('username'), |
| 375 | password=password_encrypt(instance.get('password')), |
| 376 | role=RoleConstants.USER.name, |
| 377 | source=instance.get('source', 'LOCAL'), |
| 378 | is_active=True |
| 379 | ) |
| 380 | update_user_role(instance, user, user_id) |
| 381 | set_default_permission(user.id, instance) |
| 382 | user.save() |
| 383 | return UserInstanceSerializer(user).data |
| 384 | |
| 385 | class UserEditInstance(serializers.Serializer): |
| 386 | email = serializers.EmailField( |
no test coverage detected