Source code for services.users.unauthorized

from typing import Dict, List

from django.db import transaction

from apps.users.models import Profile, User


[docs] class UnauthorizedUserService:
[docs] @staticmethod @transaction.atomic def create_user(data: Dict, profile: Dict, interests: List, password: str) -> User: """ Creates user :param data: data of user :param profile: data of user profile :param interests: list of interests :param password: raw password :return: User object """ user = User(**data) user.set_password(password) user.save() if interests: user.interests.set(interests) user.save() if profile: Profile.objects.create(user=user, **profile) return user