simplify code
This commit is contained in:
parent
f3ca4a8de9
commit
62c25ac737
|
|
@ -13,6 +13,7 @@ from django.utils.http import urlsafe_base64_encode
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
from rest_framework.authtoken.models import Token
|
||||
from collections import Counter
|
||||
from typing import List
|
||||
|
||||
from authorization.models import Application
|
||||
from establishment.models import Establishment, EstablishmentSubType
|
||||
|
|
@ -435,7 +436,7 @@ class User(AbstractUser):
|
|||
result.append(item.id)
|
||||
return set(result)
|
||||
|
||||
def set_roles(self, ids: set):
|
||||
def set_roles(self, ids: List(int)):
|
||||
"""
|
||||
Set user roles
|
||||
:param ids: list of role ids
|
||||
|
|
|
|||
|
|
@ -133,10 +133,7 @@ class BackDetailUserSerializer(BackUserSerializer):
|
|||
subscriptions_list = validated_data.pop('subscription_types')
|
||||
|
||||
if 'roles' in validated_data:
|
||||
roles_ids = filter(
|
||||
lambda filter_role: False if not filter_role else True,
|
||||
map(lambda role: role["id"] if "id" in role else None, validated_data.pop("roles"))
|
||||
)
|
||||
roles_ids = [role['id'] for role in validated_data.pop('roles') if 'id' in role]
|
||||
instance.set_roles(roles_ids)
|
||||
|
||||
instance = super().update(instance, validated_data)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user