Esempio n. 1
0
def post_reply(index):
    directory = "data/posts/posts.csv"
    reply = request.form["reply"]
    #post_dic = reader.make_postdic("data/posts/posts.csv")
    text = reader.read_file(directory)


    i = 1
    count = 0
    
    while ((count <= int(index)) and (i < len(text))):
        if reader.string_at(i,"\\<end>\n",text):
            count+=1
            
        i+=1
    #if count != 0:
    #    print "WAHT THAS IASJDSOJHAMNIK"
    #    i-=1



    i -= 1 #8 is the length of string "/<end>\n"
    text = text[:i] + reply + "{,}" + session["username"] + "{{,}}" + text[i:]
    reader.replace_file(directory,text)
    return redirect("/post")
Esempio n. 2
0
def post_by_user(usr):
    user_list = reader.make_dic(reader.read_file("data/users/user_auth.csv"))
    if not usr in user_list.keys():
        return render_template("error.html",error = "The username you have provided does not exist.",globe=globe)

    post_dic = reader.make_postdic("data/posts/posts.csv")
    post_dic_user = reader.get_post_by_user(post_dic,usr)

    return render_template("post.html",dic = post_dic_user,tags = reader.get_tags(post_dic_user),message = "Posts by " + usr,globe=globe)
Esempio n. 3
0
def messages():
    if not 'username' in session:
        main_user = ""
        return redirect("/login/")
    else:
        url = "data/users/messages.csv"
        text = reader.read_file(url)
        text = text.replace("<,>False<,>","<,>True<,>")
        
        message_list = reader.make_messagelist(url)
        messages = reader.get_message_by_user(session['username'],message_list)
        print "MESSAGES: " + str(messages)
        return render_template("messages.html",messages = messages,globe=globe)
Esempio n. 4
0
def account_change_profile_img():
    directory = "data/users/user_auth.csv"
    url = request.form["image"]
    text = reader.read_file(directory)
    index = text[( text.find(session['username']) ):].find("\n")
    print "TEXT AFTER USERNAME: "******"TEXT UNTIL NEWLINE: " + str(text[( text.find(session['username']) ):index]) #works
    i = 0
    while(text[index - i] != ","): #From the end of the user line, it goes down until it finds a comma.
        i+=1
    print "TEXT OF IMAGE: " + str(text[index-i:index])
    text = text[:(index-i)] + "," + url + text[(index):]
    reader.replace_file(directory,text)
    return redirect("/")
Esempio n. 5
0
def result():
    user_list = reader.make_dic(reader.read_file("data/users/user_auth.csv"))
    #print "BEFORE: " + str(user_list)
    #user_list = checker.reformat(user_list)
    #print "AFTER: " + str(user_list)
    rf = request.form
    user = rf["txt_user"]
    pw = rf["txt_password"]
    if user == "" or pw == "":
        return render_template("login.html",error = "Both elements must be filled!",globe=globe)
    elif user in user_list.keys() and user_list[user][0] == pw:
        session['username'] = user
        main_user = user
        return redirect("/")
    else:
        return render_template("login.html",error = "Incorrect username and/or password",globe = globe)
Esempio n. 6
0
def registered():
    user_list = reader.make_dic(reader.read_file("data/users/user_auth.csv"))
    rf = request.form
    user = rf["txt_user"]
    pw = rf["txt_password"]
    pw2 = rf["txt_password2"]
    if user == "" or pw == "" or pw2 == "":
        return render_template("register.html",error = "ALL elements must be filled!",globe = globe)
    elif pw != pw2:
        return render_template("register.html",error = "Passwords must match",globe = globe)
    elif not checker.pwformat(pw):
        return render_template("register.html",error = "Passwords must contain characters AND numbers.",globe = globe)
    elif user in user_list.keys():
        return render_template("register.html",error = "Username already exists.",globe = globe)
    else:
        reader.write_file("data/users/user_auth.csv",user + "," + pw +  "," + "..static/img/default.png" + "\n")
        return redirect("/")
    
    return render_template("register.html",error = "",globe = globe)
Esempio n. 7
0
def account(usr):
    user_list = reader.make_dic(reader.read_file("data/users/user_auth.csv"))
    if not usr in user_list.keys():
        return render_template("error.html",error = "The username you have provided does not exist.",globe=globe)
    return render_template("account.html",user = usr,user_list = user_list,globe=globe)