示例#1
0
def cadastrar_newsletter_ajax(request):
    try:
        email = strip_tags(request.POST['email'])
        nome = strip_tags(request.POST['nome'])
        try:
            cadastro = Email.objects.get(email = email)
            resposta = "email_existente"
        except Email.DoesNotExist:    
            novo_cadastro = Email()
            novo_cadastro.email = email
            novo_cadastro.nome = nome
            novo_cadastro.save()
            resposta = "sucesso" 
    except Exception:
        resposta = "falha" 
        pass
    return HttpResponse(resposta)
示例#2
0
def email_validate(statu, recieve_email=None):
    if recieve_email is None:
        if statu == 'activate':
            form = EmailValidateForm()
            if request.method == 'POST':
                if form.validate_on_submit():
                    return redirect('/validator/validation/%s' %
                                    form.email.data)
            return render_template('validate.html',
                                   title='Validate the email',
                                   form=form)
    else:
        e = Email()
        e.email = recieve_email
        if statu == 'validation':
            if not e.is_exist():
                e.generate_password()
                email_msg = Message(recipients=[recieve_email],
                                    subject='OPEN ACCESS PUBLISH validation ')
                email_msg.body = 'CLICK HERE TO VALIDATE'
                email_msg.html = "<h1>Activation</h1><p><a href='http://jinmingyi.xin:8080/captcha/%s'>Click to activate</a></p>" % e.password
                sendEmail(email_msg)
                e.validate_time = datetime.datetime.now()
                db.session.add(e)
                db.session.commit()
                return "We've already send you an validation email"
            elif not e.is_validated():
                return "<a href='/validator/resend/%s'>Didn't receive email?</a>" % recieve_email
            else:
                abort(404)
        elif statu == 'resend':
            if e.is_exist():
                if not e.is_validated():
                    email_msg = Message(
                        recipients=[recieve_email],
                        subject='OPEN ACCESS PUBLISH validation ')
                    email_msg.body = 'CLICK HERE TO VALIDATE'
                    email_msg.html = "<h1>Activation</h1><p><a href='http://jinmingyi.xin:8080/captcha/%s'>Click to activate</a></p>" % e.password
                    sendEmail(email_msg)
                    return "We've already send you an validation email"
            abort(404)
    abort(404)
示例#3
0
文件: views.py 项目: phan0041/conve2
def submit(request):
    string = request.GET.get("email", "")
    string_type = request.GET.get("type", "")

    # check token #
    token = request.GET.get("nonce", "")
    if "token" not in request.session:
        return HttpResponse("Invalid token")
    elif token != request.session['token']:
        return HttpResponse("Invalid token")
    else:   #valid token
        del request.session['token']

    if len(Email.objects.filter(email=string)) == 0 and general_util.validate_register_email(string):
        email = Email()
        gSheet_services.add_email(string, string_type)
        email.email = string
        email.save()
        return HttpResponse("Success")
    else:
        if not general_util.validate_register_email(string):
            return HttpResponse("Error")
        else:
            return HttpResponse("Dup")