(cls,
               domain,
               username,
               password,
               created_by,
               created_via,
               email=None,
               uuid='',
               date='',
               phone_number=None,
               location=None,
               commit=True,
               is_account_confirmed=True,
               metadata=None,
               **kwargs)
return commcare_user
Main entry point into creating a CommCareUser (mobile worker).
Main entry point into creating a CommCareUser (mobile worker).
Main entry point into creating a CommCareUser ( mobile worker ) .
def create(cls,
               domain,
               username,
               password,
               created_by,
               created_via,
               email=None,
               uuid='',
               date='',
               phone_number=None,
               location=None,
               commit=True,
               is_account_confirmed=True,
               metadata=None,
               **kwargs):
        """
        Main entry point into creating a CommCareUser (mobile worker).
        """
        uuid = uuid or uuid4().hex
        # if the account is not confirmed, also set is_active false so they can't login
        if 'is_active' not in kwargs:
            kwargs['is_active'] = is_account_confirmed
        elif not is_account_confirmed:
            assert not kwargs['is_active'], \
                "it's illegal to create a user with is_active=True and is_account_confirmed=False"
        commcare_user = super(CommCareUser, cls).create(domain, username, password, created_by, created_via,
                                                        email, uuid, date, metadata=None, **kwargs)
        if phone_number is not None:
            commcare_user.add_phone_number(phone_number)

        device_id = kwargs.get('device_id', '')
        # populate the couch user
        commcare_user.domain = domain
        commcare_user.device_ids = [device_id]
        commcare_user.registering_device_id = device_id
        commcare_user.is_account_confirmed = is_account_confirmed
        commcare_user.domain_membership = DomainMembership(domain=domain, **kwargs)
        # metadata can't be set until domain is present
        if 'user_data' in kwargs:
            raise ValueError("Do not access user_data directly, pass metadata argument to create.")
        commcare_user.update_metadata(metadata or {})

        if location:
            commcare_user.set_location(location, commit=False)

        if commit:
            commcare_user.save(**get_safe_write_kwargs())
            commcare_user.log_user_create(domain, created_by, created_via)
        return commcare_user
def create ( cls , domain , username , password , created_by , created_via , email = None , uuid = '' , date = '' , phone_number = None , location = None , commit = True , is_account_confirmed = True , metadata = None , * * kwargs ) : uuid = uuid or uuid4 ( ) . hex # if the account is not confirmed, also set is_active false so they can't login if 'is_active' not in kwargs : kwargs [ 'is_active' ] = is_account_confirmed elif not is_account_confirmed : assert not kwargs [ 'is_active' ] , "it's illegal to create a user with is_active=True and is_account_confirmed=False" commcare_user = super ( CommCareUser , cls ) . create ( domain , username , password , created_by , created_via , email , uuid , date , metadata = None , * * kwargs ) if phone_number is not None : commcare_user . add_phone_number ( phone_number ) device_id = kwargs . get ( 'device_id' , '' ) # populate the couch user commcare_user . domain = domain commcare_user . device_ids = [ device_id ] commcare_user . registering_device_id = device_id commcare_user . is_account_confirmed = is_account_confirmed commcare_user . domain_membership = DomainMembership ( domain = domain , * * kwargs ) # metadata can't be set until domain is present if 'user_data' in kwargs : raise ValueError ( "Do not access user_data directly, pass metadata argument to create." ) commcare_user . update_metadata ( metadata or { } ) if location : commcare_user . set_location ( location , commit = False ) if commit : commcare_user . save ( * * get_safe_write_kwargs ( ) ) commcare_user . log_user_create ( domain , created_by , created_via ) return commcare_user