Ejemplo n.º 1
0
def register_user(P, req):
    users = M.User.objects.filter(email=P["email"].strip().lower())
    if users.count() != 0:
        return UR.prepare_response(
            {}, 1,
            "A user with this email already exists - please choose another email."
        )
    user = auth.getGuest(P["ckey"])
    P["ckey"] = annotations.register_user(user.id, P)  #returns a new confkey.
    p2 = {
        "tutorial_url":
        settings.GUEST_TUTORIAL_URL,
        "conf_url":
        "%s?ckey=%s" % (req.META.get(
            "HTTP_REFERER", "http://%s" % settings.NB_SERVERNAME), P["ckey"])
    }
    from django.core.mail import EmailMessage
    p2.update(P)
    msg = render_to_string("email/confirm_guest_registration", p2)
    email = EmailMessage("Welcome to NB, %s !" % (p2["firstname"], ), msg,
                         settings.EMAIL_FROM, (P["email"], ),
                         (settings.EMAIL_BCC, ))
    email.send()
    #__send_email([P["email"], settings.SMTP_CC_USER], tpl.render(c))
    return UR.prepare_response({"uid": user.id})
Ejemplo n.º 2
0
def register_user(P, req):
    users = M.User.objects.filter(email=P["email"].strip().lower())
    if users.count() != 0:            
        return UR.prepare_response({}, 1,"A user with this email already exists - please choose another email.")
    user= auth.getGuest(P["ckey"])
    P["ckey"] = annotations.register_user(user.id, P) #returns a new confkey.       
    p2 = {"tutorial_url": settings.GUEST_TUTORIAL_URL, "conf_url": "%s?ckey=%s" %(req.META.get("HTTP_REFERER","http://%s" % settings.NB_SERVERNAME), P["ckey"])}
    from django.core.mail import EmailMessage
    p2.update(P)
    msg = render_to_string("email/confirm_guest_registration",p2)
    email = EmailMessage(
                "Welcome to NB, %s !" % (p2["firstname"], ),
                msg,  
                "NB Notifications <*****@*****.**>", 
                (P["email"], ), 
                (settings.EMAIL_BCC, ))
    email.send()
    #__send_email([P["email"], settings.SMTP_CC_USER], tpl.render(c))
    return UR.prepare_response({"uid": user.id})