<commit_before>"""
Shortcuts for working with domains and users.
"""


from __future__ import absolute_import
from __future__ import unicode_literals
def create_domain(name, active=True):
    """Create domain without secure submissions for tests"""
    return Domain.get_or_create_with_name(name=name, is_active=active,
                                          secure_submissions=False)


def create_user(username, password, is_staff=False, is_superuser=False, is_active=True, password_hashed=False, **kwargs):
    user = User()
    user.username = username.lower()
    for key, val in kwargs.items():
        if key and val:
            setattr(user, key, val)
    user.is_staff = is_staff
    user.is_active = is_active
    user.is_superuser = is_superuser
    if not password_hashed:
        user.set_password(password)
    else:
        user.password = password

    user.save()
    return user

from corehq.apps.domain.models import Domain
from django.contrib.auth.models import User<commit_msg>don't save couch user when createing new user<commit_after>"""
Shortcuts for working with domains and users.
"""


from __future__ import absolute_import
from __future__ import unicode_literals
def create_domain(name, active=True):
    """Create domain without secure submissions for tests"""
    return Domain.get_or_create_with_name(name=name, is_active=active,
                                          secure_submissions=False)


def create_user(username, password, is_staff=False, is_superuser=False, is_active=True, password_hashed=False, **kwargs):
    user = User()
    user.username = username.lower()
    for key, val in kwargs.items():
        if key and val:
            setattr(user, key, val)
    user.is_staff = is_staff
    user.is_active = is_active
    user.is_superuser = is_superuser
    if not password_hashed:
        user.set_password(password)
    else:
        user.password = password

    user.DO_NOT_SAVE_COUCH_USER = True
    user.save()
    return user

from corehq.apps.domain.models import Domain
from django.contrib.auth.models import User
{'fraction_non_alphanumeric': 0.0824891461649783, 'fraction_numerical': 0.0, 'mean_word_length': 3.3029045643153525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2245491', 'n_tokens_mistral': 611, 'n_tokens_neox': 593, 'n_words': 164}