Exemple #1
0
def generate_secret_address(user, length=10):
    allowed_chars = 'abcdefghkmnprstuvwxyz2345689'
    username = user.username.replace('_', '.')
    secret = get_random_string(length=length, allowed_chars=allowed_chars)
    template = getattr(settings, 'FOI_EMAIL_TEMPLATE', None)

    FOI_EMAIL_DOMAIN = get_foi_mail_domains()[0]

    if template is not None and callable(template):
        return settings.FOI_EMAIL_TEMPLATE(username=username, secret=secret)
    elif template is not None:
        return settings.FOI_EMAIL_TEMPLATE.format(username=username,
                                                  secret=secret,
                                                  domain=FOI_EMAIL_DOMAIN)
    return "%s.%s@%s" % (username, secret, FOI_EMAIL_DOMAIN)
Exemple #2
0
def generate_secret_address(user, length=10):
    possible_chars = 'abcdefghkmnprstuvwxyz2345689'
    username = user.username.replace('_', '.')
    secret = "".join([random.choice(possible_chars) for i in range(length)])
    template = getattr(settings, 'FOI_EMAIL_TEMPLATE', None)

    domains = settings.FOI_EMAIL_DOMAIN
    if isinstance(domains, string_types):
        domains = [domains]
    FOI_EMAIL_DOMAIN = domains[0]

    if template is not None and callable(template):
        return settings.FOI_EMAIL_TEMPLATE(username=username, secret=secret)
    elif template is not None:
        return settings.FOI_EMAIL_TEMPLATE.format(username=username,
                                                  secret=secret,
                                                  domain=FOI_EMAIL_DOMAIN)
    return "%s.%s@%s" % (username, secret, FOI_EMAIL_DOMAIN)