<commit_before>from __future__ import absolute_import

from django import forms
from django.core.exceptions import ValidationError
from django.utils.safestring import mark_safe
from django.contrib.auth.forms import SetPasswordForm
from django.conf import settings

from zerver.models import Realm, get_user_profile_by_email, UserProfile, \
    completely_open, email_to_domain, get_realm
from zerver.lib.actions import do_change_password, alias_for_realm
from zproject.backends import password_auth_enabled
import DNS

def is_inactive(value):
    try:
        if get_user_profile_by_email(value).is_active:
            raise ValidationError(u'%s is already active' % value)
    except UserProfile.DoesNotExist:
        pass

SIGNUP_STRING = '<a href="https://zulip.com/signup">Sign up</a> to find out when Zulip is ready for you.'

def has_valid_realm(value):
    return Realm.objects.filter(domain=email_to_domain(value)).exists()
<commit_msg>Disable signups for realms that exist as part of enterprise deployments.<commit_after>from __future__ import absolute_import

from django import forms
from django.core.exceptions import ValidationError
from django.utils.safestring import mark_safe
from django.contrib.auth.forms import SetPasswordForm
from django.conf import settings

from zerver.models import Realm, get_user_profile_by_email, UserProfile, \
    completely_open, email_to_domain, get_realm
from zerver.lib.actions import do_change_password, alias_for_realm
from zproject.backends import password_auth_enabled
import DNS

def is_inactive(value):
    try:
        if get_user_profile_by_email(value).is_active:
            raise ValidationError(u'%s is already active' % value)
    except UserProfile.DoesNotExist:
        pass

SIGNUP_STRING = '<a href="https://zulip.com/signup">Sign up</a> to find out when Zulip is ready for you.'

def has_valid_realm(value):
    try:
        realm = Realm.objects.get(domain=email_to_domain(value))
    except Realm.DoesNotExist:
        return False
    if settings.ENTERPRISE:
        return True
    return realm.deployment.name in ["mit.edu", "zulip.com"]

{'fraction_non_alphanumeric': 0.07156398104265403, 'fraction_numerical': 0.0, 'mean_word_length': 4.705405405405405, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2306606', 'n_tokens_mistral': 643, 'n_tokens_neox': 635, 'n_words': 174}