Exemple #1
0
def add():
    if request.method == "POST":

        username = ""
        password = ""
        current = ""
        name = ""
        if 'username' in request.form:
            username = request.form.get("username")
            password = request.form.get("password")
            name = mongo.getName2(username,password)
            session['user'] = name
            crushlist = ""
            if name == 0:
                return render_template("add.html",name=True,crush=False,crushlist="")
            crushl = mongo.getPeopleYouLike2(str(name))
            return render_template("add.html",name=False,crush=True,crushlist=crushl,person=name,current=current)

        elif 'usernamereg' in request.form:
            namereg = request.form.get("namereg")
            usernamereg = request.form.get("usernamereg")
            passwordreg1 = request.form.get("passwordreg1")
            passwordreg2 = request.form.get("passwordreg2")
            crushlist = ""
            current = ""
            if passwordreg1 != passwordreg2:
                return render_template("add.html",name=True,crush=False,crushlist="")
            mongo.addUser(namereg,usernamereg,passwordreg1)
            session['user'] = namereg
            crushlist = mongo.getPeopleYouLike2(str(namereg))
            return render_template("add.html",name=False,crush=True,crushlist=crushlist,person=namereg,current=current)


        elif 'remove' in request.form:
            name = session['user']
            mongo.removeUser(name)
            return render_template("add.html",name=True,crush=False,crushlist="")
        elif 'add' in request.form:
            meep = request.form.get("crushes")
            crushl = [x.strip() for x in meep.split('\n')]
            name = session['user']
            for item in crushl:
                item.strip()
                x = item.split(", ")
                print x
                print len(x)
                if len(x)>2:
                    mongo.addPerson2(str(name),x[0],x[1],x[2])
                elif len(x) == 1:
                    continue
                else:
                    mongo.addPerson2(str(name),x[0],x[1],"")
            crushl = mongo.getPeopleYouLike2(str(name))
            return render_template("add.html",name=False,crush=True,crushlist=crushl,person=name,current=meep)
        else:
            name = session['user']
            print request.form
            crush = request.form.keys()[0]
            print crush
            mongo.removeCrush(name,crush)
            crushl = mongo.getPeopleYouLike2(str(name))
            return render_template("add.html",name=False,crush=True,crushlist=crushl,person=name)

    return render_template("add.html",name=True,crush=False,crushlist="")
Exemple #2
0
def add():
    if request.method == "POST":        
        username = ""
        password = ""
        current = ""
        name = ""
        if 'username' in request.form:
            username = request.form.get("username")
            password = request.form.get("password")
            name = mongo.getName(username,password)
            session['user'] = name
            crushlist = ""
            print name
            if name == 0:
                return render_template("add.html",name=True,crush=False,crushlist="")
            crushlist = mongo.getPeopleYouLike(str(name))
            for item in crushlist:
                current += item + ", "
            enter = False
            return render_template("add.html",name=False,crush=True,crushlist=crushlist,person=name,current=current)
        
        elif 'usernamereg' in request.form:
            namereg = request.form.get("namereg")
            usernamereg = request.form.get("usernamereg")
            passwordreg1 = request.form.get("passwordreg1")
            passwordreg2 = request.form.get("passwordreg2")
            crushlist = ""
            current = ""
            if passwordreg1 != passwordreg2:
                return render_template("add.html",name=True,crush=False,crushlist="")
            if namereg in mongo.getAllPeople():
                test = mongo.addUserInfo(namereg,usernamereg,passwordreg1)
                if test:
                    session['user'] = namereg
                    crushlist = mongo.getPeopleYouLike(str(namereg))
                    crushlist = [x.strip() for x in crushlist.split(", ")]
                    for item in crushlist:
                        current += item + ", "
                        enter = False
                    return render_template("add.html",name=False,crush=True,crushlist=crushlist,person=name,current=current)
                else:
                    return render_template("add.html",name=True,crush=False,crushlist="")
            else:
                session['user'] = namereg
                mongo.addPerson(namereg,"",usernamereg,passwordreg1)
                return render_template("add.html",name=False,crush=True,crushlist=crushlist,person=namereg,current=current)

        elif 'remove' in request.form:
            print "REMOVING USER"
            name = session['user']
            print name
            mongo.removeUser(name)
            return render_template("add.html",name=True,crush=False,crushlist="")
        else:
            meep = request.form.get("crushes")
            crushl = [x.strip() for x in meep.split(", ")]
            name = session['user']
            mongo.addPerson(str(name),crushl)
            for item in crushl:
                current += item + ", "
            return render_template("add.html",name=False,crush=True,crushlist=crushl,person=name,current=meep)
    return render_template("add.html",name=True,crush=False,crushlist="")
Exemple #3
0
def add():
    if request.method == "POST":

        username = ""
        password = ""
        current = ""
        name = ""
        if 'username' in request.form:
            username = request.form.get("username")
            password = request.form.get("password")
            name = mongo.getName2(username, password)
            session['user'] = name
            crushlist = ""
            if name == 0:
                return render_template("add.html",
                                       name=True,
                                       crush=False,
                                       crushlist="")
            crushl = mongo.getPeopleYouLike2(str(name))
            return render_template("add.html",
                                   name=False,
                                   crush=True,
                                   crushlist=crushl,
                                   person=name,
                                   current=current)

        elif 'usernamereg' in request.form:
            namereg = request.form.get("namereg")
            usernamereg = request.form.get("usernamereg")
            passwordreg1 = request.form.get("passwordreg1")
            passwordreg2 = request.form.get("passwordreg2")
            crushlist = ""
            current = ""
            if passwordreg1 != passwordreg2:
                return render_template("add.html",
                                       name=True,
                                       crush=False,
                                       crushlist="")
            mongo.addUser(namereg, usernamereg, passwordreg1)
            session['user'] = namereg
            crushlist = mongo.getPeopleYouLike2(str(namereg))
            return render_template("add.html",
                                   name=False,
                                   crush=True,
                                   crushlist=crushlist,
                                   person=namereg,
                                   current=current)

        elif 'remove' in request.form:
            name = session['user']
            mongo.removeUser(name)
            return render_template("add.html",
                                   name=True,
                                   crush=False,
                                   crushlist="")
        elif 'add' in request.form:
            meep = request.form.get("crushes")
            crushl = [x.strip() for x in meep.split('\n')]
            name = session['user']
            for item in crushl:
                item.strip()
                x = item.split(", ")
                print x
                print len(x)
                if len(x) > 2:
                    mongo.addPerson2(str(name), x[0], x[1], x[2])
                elif len(x) == 1:
                    continue
                else:
                    mongo.addPerson2(str(name), x[0], x[1], "")
            crushl = mongo.getPeopleYouLike2(str(name))
            return render_template("add.html",
                                   name=False,
                                   crush=True,
                                   crushlist=crushl,
                                   person=name,
                                   current=meep)
        else:
            name = session['user']
            print request.form
            crush = request.form.keys()[0]
            print crush
            mongo.removeCrush(name, crush)
            crushl = mongo.getPeopleYouLike2(str(name))
            return render_template("add.html",
                                   name=False,
                                   crush=True,
                                   crushlist=crushl,
                                   person=name)

    return render_template("add.html", name=True, crush=False, crushlist="")