Exemplo n.º 1
0
def view_post():
    if session.get('logged_in') is None:
        return redirect(url_for('PetCare.login'))
    postDao = PostDao()
    post = postDao.get_post(request.args['postId'])
    postInfo = Entities.make_post_output(dict(post))
    return render_template('view_post.html', post=postInfo)
Exemplo n.º 2
0
def view_post():
	if session.get('logged_in') is None:
		return redirect(url_for('PetCare.login'))
	postDao = PostDao()
	post = postDao.get_post(request.args['id'])
	change_time_format(dict(post))
	return render_template('view_post.html', post=post)
Exemplo n.º 3
0
def review():
	if session.get('logged_in') is None:
		return redirect(url_for('PetCare.login'))
	accountDao = AccountDao()
	postId = accountDao.get_account_post(session['logged_in'].rstrip())
	if postId is not None:
		postDao = PostDao()
		post = postDao.get_post(postId)
		if post['match'] is not None:
			postDao.update_review(post['id'], int(request.form['review']))
			accountDao.update_account_reputation(post['match'], int(request.form['review']), post['review'])
			if time.time() > post['end_date']:
				accountDao.remove_account_post(session['logged_in'].rstrip(), post['id'])
			return redirect(url_for('PetCare.profile', userId=post['match']))
	return redirect(url_for('PetCare.list_posts'))
Exemplo n.º 4
0
def view_post():
	if session.get('logged_in') is None:
		return redirect(url_for('PetCare.login'))
	postDao = PostDao()
	post = postDao.get_post(request.args['postId'])
	status = 'PENDING'
	if post['match'] is not None and len(post['match']) > 0:
		status = 'MATCHED'
	if time.time() > post['end_date']:
		status = 'FINISHED'
	postInfo = Entities.make_post_output(dict(post))
	isOwner = (session.get('logged_in') == post['owner_id'])
	accountDao = AccountDao()
	ownername =  accountDao.get_name(post['owner_id'])
	return render_template('view_post.html', post=postInfo, status=status, isOwner=isOwner, owner=ownername)
Exemplo n.º 5
0
def edit_post():
    if session.get('logged_in') is None:
        return redirect(url_for('PetCare.login'))
    accountDao = AccountDao()
    postDao = PostDao()
    postId = accountDao.get_account_post(session['logged_in'])
    if postId is None:
        return redirect(url_for('PetCare.create_post'))
    prevPost = dict(postDao.get_post(postId))
    if request.method == 'GET':
        # TODO: return with post information shown
        return render_template('edit_post.html', error=None)
    postInfo = Entities.make_post_info(session['logged_in'], request, prevPost)
    if not postInfo:
        return render_template('edit_post.html',
                               error="Required Informaion Missing")
    postInfo['id'] = postId
    postDao.update_post(postInfo)
    return redirect(url_for('PetCare.list_posts'))