コード例 #1
0
ファイル: models.py プロジェクト: tbuffington7/firecares
    def is_department_whitelisted(cls, email):
        if not email:
            return False

        email = email.lower()

        domain_whitelists = map(
            lambda x: x.lower(),
            cls.objects.filter(department__isnull=False).exclude(
                email_or_domain__contains='@').values_list('email_or_domain',
                                                           flat=True))
        if cls._is_domain_only(email):
            return email in domain_whitelists

        domain = get_email_domain(email)
        email_whitelists = map(
            lambda x: x.lower(),
            cls.objects.filter(department__isnull=False,
                               email_or_domain__contains='@').values_list(
                                   'email_or_domain', flat=True))

        if email in email_whitelists or domain in domain_whitelists:
            return True
        else:
            return False
コード例 #2
0
ファイル: models.py プロジェクト: tbuffington7/firecares
 def get_for_email(cls, email):
     if cls.is_whitelisted(email):
         email = email.lower()
         email_whitelists = cls.objects.filter(
             email_or_domain__contains='@')
         domain_whitelists = cls.objects.exclude(
             email_or_domain__contains='@')
         domain = get_email_domain(email)
         if email_whitelists.filter(email_or_domain__iexact=email).exists():
             return email_whitelists.filter(
                 email_or_domain__iexact=email).first()
         else:
             return domain_whitelists.filter(
                 email_or_domain__iexact=domain).first()
コード例 #3
0
ファイル: models.py プロジェクト: tbuffington7/firecares
    def get_department_for_email(cls, email):
        if cls.is_department_whitelisted(email):
            if cls._is_domain_only(email):
                return cls.objects.filter(
                    department__isnull=False,
                    email_or_domain__iexact=email).first().department

            domain = get_email_domain(email)
            by_domain = cls.objects.filter(
                department__isnull=False,
                email_or_domain__iexact=domain).first()
            by_email = cls.objects.filter(
                department__isnull=False,
                email_or_domain__iexact=email).first()

            return by_email.department if by_email else by_domain.department
コード例 #4
0
ファイル: models.py プロジェクト: tbuffington7/firecares
    def is_whitelisted(cls, email):
        if not email:
            return False

        email = email.lower()

        whitelists = map(lambda x: x.lower(),
                         cls.objects.values_list('email_or_domain', flat=True))
        email_whitelists = filter(lambda x: '@' in x, whitelists)
        domain_whitelists = set(whitelists) ^ set(email_whitelists)
        if cls._is_domain_only(email):
            return email in domain_whitelists

        domain = get_email_domain(email)
        pre_users = map(
            lambda x: x.lower(),
            PredeterminedUser.objects.values_list('email', flat=True))
        if email in email_whitelists or domain in domain_whitelists or email in pre_users:
            return True
        else:
            return False