Esempio n. 1
0
File: index.py Progetto: 1025ryu/sns
def newspeed():
	if request.method == 'POST':
		cnt=request.form['cnt']
		cnt=int(cnt)
		user_id=session['user_id']
		user=user_manager.get_user(session['user_id'])
		followees=user.followees
		followee_list=[]
		followee_list.append(user_id)
		for followee in followees:
			followee_id=followee.followee.id
			followee_list.append(followee_id)
		posts=user_manager.get_newspeed_post(followee_list,cnt)
		return render_template('newspeed_show.html',posts=posts)
	else:
		user_id=session['user_id']
		user=user_manager.get_user(session['user_id'])
		followees=user.followees
		followee_list=[]
		followee_list.append(user_id)
		for followee in followees:
			followee_id=followee.followee.id
			followee_list.append(followee_id)
		posts=user_manager.get_newspeed_post(followee_list,0)
		return render_template('newspeed.html',posts=posts)
Esempio n. 2
0
def timeline(wall_id):
	user = user_manager.get_user(wall_id)
	posts = user.wall_posts
	session['wall_host_id'] = user.id
	session['wall_host_name'] = user.username
	session["scroll_count"] = 0

	return render_template("sns_wall.html", wall_host_name = session['wall_host_name'], posts = posts, wall_id = session['wall_host_id'])
Esempio n. 3
0
def load_comments(place_id, offset):
    place = Place.query.get(place_id)

    context = {'comments': place.load_comments(offset), 'offset': offset}

    if 'user_id' in session:
        context['user'] = user_manager.get_user(session['user_id'])

    return render_template('ajax/comment.html', context=context)
Esempio n. 4
0
def get_places(start):
    places = place_manager.get_places(start)

    context = {'places': places}

    if 'user_id' in session:
        context['user'] = user_manager.get_user(session['user_id'])

    return render_template('ajax/card.html', context=context)
Esempio n. 5
0
File: index.py Progetto: 1025ryu/sns
def read(pid,wall_id):
	if request.method=="POST":
		
		post=user_manager.get_post(pid)
		comments=request.form['comments']
		user_manager.comment(session['user_id'],comments,pid)
		return render_template('read.html',post=post,comments=post.comments)
	else:
		user=user_manager.get_user(wall_id)
		post=user_manager.get_post(pid)
		session['pid']=pid
		session['wall_id']=wall_id
		return render_template('read.html',post=post,comments=post.comments)
Esempio n. 6
0
def contents(wall_id):
	if wall_id == 0:
		session['username'] = session['email']
		session['wall_id'] = wall_id
		return render_template('contents.html')
	else:		
		
		wall_user = user_manager.get_user(wall_id)
		session['wall_id'] = wall_id
		session['username'] = wall_user.username
		# post_lists = wall_user.wall_posts
		post_lists = user_manager.get_wall_posts(session['wall_id'])
		return render_template('contents.html', post_lists = post_lists)
Esempio n. 7
0
def get_5_post_newsfeed():
	celebrities = []
	user = user_manager.get_user(session['user_id'])

	followees = user.followees
	for followee in followees:
		celebrities.append(followee.followee_id)

	if request.method == 'POST':
		all_posts = data_manager.newsfeed_get_all_posts(celebrities)		
		five_posts = all_posts.slice(int(request.form["offset"]) , int(request.form["offset"])+5)

	return render_template("sns_newsfeed_2.html", five_posts = five_posts)
Esempio n. 8
0
def get_place_detail(id):
    place = place_manager.get_place(id)

    context = {'place': place}

    comment_context = {'comments': place.get_top_comments(), 'offset': 0}

    if 'user_id' in session:
        context['user'] = user_manager.get_user(session['user_id'])
        comment_context['user'] = context['user']

    context['comment_html'] = render_template('ajax/comment.html',
                                              context=comment_context)

    return render_template('ajax/modal_content.html', context=context)
Esempio n. 9
0
def login():
    error= None
    if request.method == 'POST':
        email = request.form['email']
        password = request.form['password']
        if user_manager.login_check(email, password) == True:
            session['logged_in'] = True
            session['email'] = email
            users = user_manager.get_user(email)
            session['user_id'] = users[0].id  
            flash('You were logged_in')
            return redirect(url_for('posts'))
        else :
            error = "There is no information."
    else :
        pass
        # don't need
    return render_template('login.html', error = error)
Esempio n. 10
0
File: index.py Progetto: 1025ryu/sns
def timeline(wall_id):
	user=user_manager.get_user(wall_id)
	user_name = user.username
	session['wall_id']=wall_id
	session['user_name']=user_name
	# data={}
	# db_list=[]
	# posts=user_manager.get_post_list(session['wall_id'])
	# for post in posts:
	# 	data['created_time']=str(post.created_time)
	# 	data['id']=post.id
	# 	data['body']=post.body
	# 	data['edited_time']=str(post.edited_time)
	# 	data['is_edited']=post.is_edited
	# 	data['is_secret']=post.is_secret
	# 	data['user_id']=post.user_id	
	# 	data['wall_id']=post.wall_id
	# 	db_list.append(data)
	# result_list = json.dumps(db_list)
	return render_template('timeline.html',message=user_name)
Esempio n. 11
0
File: index.py Progetto: 1025ryu/sns
def follow():
	user=user_manager.get_user(session['user_id'])
	return render_template('follow.html',followers=user.followers,followees=user.followees)