def handle_noargs(self, **options): if askbot_settings.ENABLE_EMAIL_ALERTS: activate_language(django_settings.LANGUAGE_CODE) for user in User.objects.exclude(status='b').iterator(): try: if email_is_blacklisted(user.email): continue self.send_email_alerts(user) except Exception: self.report_exception(user) connection.close()
def handle_noargs(self, **options): if askbot_settings.ENABLE_EMAIL_ALERTS: activate_language(django_settings.LANGUAGE_CODE) for user in User.objects.exclude(askbot_profile__status="b").iterator(): try: if email_is_blacklisted(user.email) and askbot_settings.BLACKLISTED_EMAIL_PATTERNS_MODE == "strict": continue self.send_email_alerts(user) except Exception: self.report_exception(user) connection.close()
def handle_noargs(self, **options): if askbot_settings.ENABLE_EMAIL_ALERTS: activate_language(django_settings.LANGUAGE_CODE) for user in User.objects.exclude(status='b').iterator(): try: if email_is_blacklisted(user.email) \ and askbot_settings.BLACKLISTED_EMAIL_PATTERNS_MODE == 'strict': continue self.send_email_alerts(user) except Exception: self.report_exception(user) connection.close()
def moderated_email_validator(email): allowed_domains = askbot_settings.ALLOWED_EMAIL_DOMAINS.strip() allowed_emails = askbot_settings.ALLOWED_EMAILS.strip() error_msg = _('this email address is not authorized') if allowed_emails or allowed_domains: if not email_is_allowed(email, allowed_emails=allowed_emails, allowed_email_domains=allowed_domains): raise forms.ValidationError(error_msg) else: from askbot.deps.django_authopenid.util import email_is_blacklisted blacklisting_on = askbot_settings.BLACKLISTED_EMAIL_PATTERNS_MODE != 'disabled' if blacklisting_on and email_is_blacklisted(email): raise forms.ValidationError(error_msg)
def moderated_email_validator(email): allowed_domains = askbot_settings.ALLOWED_EMAIL_DOMAINS.strip() allowed_emails = askbot_settings.ALLOWED_EMAILS.strip() error_msg = _('this email address is not authorized') if allowed_emails or allowed_domains: if not email_is_allowed( email, allowed_emails=allowed_emails, allowed_email_domains=allowed_domains ): raise forms.ValidationError(error_msg) else: from askbot.deps.django_authopenid.util import email_is_blacklisted blacklisting_on = askbot_settings.BLACKLISTED_EMAIL_PATTERNS_MODE != 'disabled' if blacklisting_on and email_is_blacklisted(email): raise forms.ValidationError(error_msg)
def clean(self, email): """ validate if email exist in database from legacy register return: raise error if it exist """ email = (email or '').strip() if askbot_settings.BLANK_EMAIL_ALLOWED and email == '': return '' email = super(UserEmailField,self).clean(email) if self.skip_clean: return email allowed_domains = askbot_settings.ALLOWED_EMAIL_DOMAINS.strip() allowed_emails = askbot_settings.ALLOWED_EMAILS.strip() from askbot.deps.django_authopenid.util import email_is_blacklisted if email_is_blacklisted(email): raise forms.ValidationError(self.error_messages['unauthorized']) if allowed_emails or allowed_domains: if not email_is_allowed( email, allowed_emails=allowed_emails, allowed_email_domains=allowed_domains ): raise forms.ValidationError(self.error_messages['unauthorized']) try: user = User.objects.get(email__iexact=email) logging.debug('email taken') raise forms.ValidationError(self.error_messages['taken']) except User.DoesNotExist: logging.debug('email valid') return email except User.MultipleObjectsReturned: logging.critical('email taken many times over') raise forms.ValidationError(self.error_messages['taken'])