Пример #1
0
def commit(request):
    if request.method == "POST":
        ef = EmailForm(request.POST)
        if ef.is_valid():
            s = Signup(email=ef.cleaned_data["email"])
            s.save()
        cats = ["volunteer", "outdoors", "food", "drink", "entertain", "winter", "rents"]
        resp_dict = models.get_acts_from_cats(cats)
        return render_to_response("home.html", resp_dict, RequestContext(request))
    else:
        ef = EmailForm()
        return render_to_response("commit.html", {"form": ef}, RequestContext(request))
Пример #2
0
def pull_csv_signups_todb(f):
    ''' creates unsaved signup instances from a csv file '''
    # read data
    text = ''.join(f.chunks())
    lines = text.splitlines()[1:]

    # generate signups
    signups = []
    for l in lines:
        words = l.split(',')
        if len(words) == 4:
            signup = Signup(firstname=words[0],
                            lastname=words[1],
                            email=words[2],
                            username=words[3],
                            password=get_random_passwd(),
                            courses=[])
            signup.save()
            signups.append(signup)
        elif len(words) == 7:
            signup = Signup(firstname=words[0],
                            lastname=words[1],
                            email=words[2],
                            username=words[3],
                            password=get_random_passwd(),
                            institution_tpe = words[4],
                            country = words[5],
                            description = words[6],
                            courses=[])
            signup.save()
            signups.append(signup)
        else:
            raise Exception("bulk enroll csv must have 4 or 7 columns (of which all or some can be empty)")
    
    return signups
Пример #3
0
def signup(request):
    if request.method != "POST":
        return HttpResponseNotFound()

    signup = Signup()
    signup.email = request.POST['email'] 
    signup.business = (request.POST['business'] == "true")
    signup.save()

    if signup.business:
        return render_to_response('core/business_signup_success.html', 
            {'signup_id': signup.pk}, context_instance=RequestContext(request))
    else:
        return render_to_response('core/signup_success.html')
Пример #4
0
def signup_view(request):
    if request.method == "POST":
        form = SignUpForm(request.POST)
        if form.is_valid():
            print "yes"
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            confirm_password = form.cleaned_data['confirm_password']
            email = form.cleaned_data['email']
            phone = form.cleaned_data['phone']
            user = Signup(username=username,
                          password=make_password(password),
                          confirm_password=make_password(confirm_password),
                          email=email,
                          phone=phone)
            user.save()
            return render(request, 'tender.html')
        else:
            print 'Invalid'
    elif request.method == 'GET':
        form = SignUpForm()

    return render(request, 'signup.html', {'form': form})
Пример #5
0
def signup(request):
    if request.method == 'GET':
        signup = Signup()
        print signup.name
        return render(request, "signup.html", {})
    elif request.method == 'POST':
        signup = Signup()
        value = 0
        print "requesmethod", request.method
        name = request.POST.get("name" or None)
        if name is None or '' or len(name) == 0:
            print "name"
            value = 1
        print "len name", len(name)
        email = request.POST.get("email" or None)
        if email == None or '@' not in email:
            print "email"
            value = 2
        passwd = request.POST.get("passwd" or None)
        if passwd == None or len(passwd) < 8:
            print "passwd"
            value = 3
        exist = Signup.objects.filter(name=name)
        if len(exist) > 0 and value != 1:
            value = 4
        print value
        if value == 1:
            return render(request, "signup.html", {'noname': True})
        elif value == 2:
            return render(request, "signup.html", {'noemail': True})
        elif value == 3:
            return render(request, "signup.html", {'nopasswd': True})
        elif value == 4:
            return render(request, "signup.html", {'existing': True})
        p = Signup(name=name, email=email, passwd=passwd)
        p.save()
        return render(request, "signup.html", {})
Пример #6
0
def create_signup(firstname, lastname, email, username, courses_lst):
    ''' most simple way of creating a new signup instance '''
    signup = Signup(firstname=firstname, lastname=lastname, email=email, username=username, password=get_random_passwd())
    signup.courses = courses_lst
    signup.save()
    return signup
Пример #7
0
def sign_up(request):

    name = request.POST.get('txt_name')
    email = request.POST.get('txt_email')
    password = request.POST.get('txt_password')
    confirm_pwd = request.POST.get('txt_confirm_pwd')

    me = "*****@*****.**"
    you = email
    msg = MIMEMultipart('alternative')
    msg['Subject'] = "Confirmation Email"
    msg['From'] = me
    msg['To'] = you
    text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttps://www.python.org"
    html = """\
	<html>
	  <head>
	  </head>
	  <body>
	  	<p><font color="Blue"><h1>Hello !!!<h1></font><br>
        <h2><font color="Blue">This is the verification message....</font</h2><br>
        <h2><font color="Black">Click to verify :</font></h2>   
	    <button type="submit"><a href="http://127.0.0.1:8000/single_photon/email/">VERIFY</a></button></p>
	  </body>
	</html>
	"""
    part1 = MIMEText(text, 'plain')
    part2 = MIMEText(html, 'html')
    msg.attach(part1)
    msg.attach(part2)
    s = smtplib.SMTP('smtp.gmail.com', 587)
    s.starttls()
    s.login(me, 'dingu@123')
    s.sendmail(me, you, msg.as_string())
    s.quit()
    try:
        check_email_exist = Login.objects.filter(login_username=email).exists()
        if check_email_exist == False:

            a = Login(login_username=email, login_password=password)
            a.save()
            fk_id = a.id

            #----c is the object created here------
            c = Login.objects.get(id=fk_id)
            request.session['loginid'] = fk_id

            b = Signup(name=name, login=c)
            b.save()

            template = loader.get_template('login.html')
            context = {"Email": "PLEASE VERIFY YOUR EMAIL !!!"}

        else:
            template = loader.get_template('sign_up.html')
            context = {"email_err": "Email already Exists"}
    except Exception, e:
        template = loader.get_template('sign_up.html')
        context = {"error": "Invalid Login Credentials"}
        print("########## This is the error ############")
        print e