Esempio n. 1
0
def news_feed():
    quote_day = random.choice(quotes)
    all_stories = get_all_stories()
    print(all_stories,"stories",request.method)
    if request.method=="POST":
        content= request.form['story']
        picture= request.form['picture']
        spouse1 = request.form['name1']
        spouse2 = request.form['name2']
        title= spouse1 + " & " + spouse2 
        add_story(content, picture, spouse1, spouse2, title)
        all_stories = get_all_stories()

    return render_template("newsfeed.html", stories = all_stories,quote = quote_day) 
def index():
    if request.method=='GET':
         return render_template("home.html",titles=database.get_stories())      
    if request.method=='POST':
        if(request.form["button"]=="Submit"):
            database.add_story(str(request.form['title']))
            return render_template("home.html",titles=database.get_stories())
        elif (request.form["button"]=="Go To Story"):
            title=str(request.form['select'])
            assert title!=""
            return render_template("story.html",title=title,comments=database.get_comments(title))     
        elif (request.form["button"]=="Delete Story"):
            title=str(request.form['select'])
            database.delete_story(title)
            return render_template("home.html",titles=database.get_stories())
Esempio n. 3
0
def newpost():
    if session["logged"]==0:
        return redirect(url_for("login"))
    elif request.method=="GET":
        username = database.get_user_by_id(session["user"])
        return render_template("newpost.html", uname=username)
    else:
        title = request.form["title"]
        body = request.form["body"]
        session["title"] = title
        session["body"] = body
        session["author"] = database.get_user_by_id(session["user"])
        return redirect(url_for("story", storyid=database.add_story(title, session["user"], body, 1)))
 def test_get_comments(self):
     database.add_story("new story")
     database.add_comment("new story","comment one")
     database.add_comment("new story","comment one")
     comments=database.get_comments("new story")
     self.assertEqual(["comment one","comment one"],comments) 
 def test_add_comment(self):
     database.add_story("new story")
     database.add_comment("new story","comment one")
     database.add_comment("new story","comment two")
     self.assertEqual(2,len(database.get_comments("new story")))
 def test_add_same_story(self):
     database.add_story("new story")
     database.add_story("new story")
     self.assertEqual(1,len(database.get_stories()))
 def test_delete_story(self):
     database.add_story("new story")
     database.delete_story("new story")
     self.assertEqual(0,len(database.get_stories()))
Esempio n. 8
0
def edit():
    if session["logged"]==0:
        return redirect(url_for("login"))
    elif request.method=="GET":
        username = database.get_user_by_id(session["user"])
        return render_template("edit.html", uname=username)
    else:
        title = "<NO TITLE YET>"
        database.update_story_link(database.get_lowest_child(request.args.get('storyid')), database.add_story(title, session["user"], request.form["body"], 0))
        return redirect(url_for('story', storyid=request.args.get('storyid')))