(domain, new_plan_version)
return True
Deactivates users if there are too many for a community plan
Deactivates users if there are too many for a community plan
Deactivates users if there are too many for a community plan
def response_mobile_worker_creation(domain, new_plan_version):
        """ Deactivates users if there are too many for a community plan """
        from corehq.apps.accounting.models import (
            DefaultProductPlan, FeatureType, UNLIMITED_FEATURE_USAGE)

        # checks for community plan
        if (new_plan_version != DefaultProductPlan.get_default_plan_version()):
            return True

        # checks if unlimited is on for this user
        user_rate = new_plan_version.feature_rates.filter(
            feature__feature_type=FeatureType.USER).latest('date_created')
        if user_rate.monthly_limit == UNLIMITED_FEATURE_USAGE:
            return True

        # checks for extra users
        num_users = CommCareUser.total_by_domain(
            domain.name, is_active=True)
        num_allowed = user_rate.monthly_limit
        if num_users > num_allowed:
            # offloads deactivation onto a separate thread
            # there should be a task that deactivates users here
            pass
        return True
def response_mobile_worker_creation ( domain , new_plan_version ) : from corehq . apps . accounting . models import ( DefaultProductPlan , FeatureType , UNLIMITED_FEATURE_USAGE ) # checks for community plan if ( new_plan_version != DefaultProductPlan . get_default_plan_version ( ) ) : return True # checks if unlimited is on for this user user_rate = new_plan_version . feature_rates . filter ( feature__feature_type = FeatureType . USER ) . latest ( 'date_created' ) if user_rate . monthly_limit == UNLIMITED_FEATURE_USAGE : return True # checks for extra users num_users = CommCareUser . total_by_domain ( domain . name , is_active = True ) num_allowed = user_rate . monthly_limit if num_users > num_allowed : # offloads deactivation onto a separate thread # there should be a task that deactivates users here pass return True