예제 #1
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'))
예제 #2
0
def delete_post():
	if session.get('logged_in') is not None:
		accountDao = AccountDao()
		ownerMatched = accountDao.remove_account_post(session['logged_in'], request.form['id'])
		if not ownerMatched:
			return redirect(url_for('PetCare.list_posts'))
		postDao = PostDao()
		postDao.remove_post(request.form['id'])
	return redirect(url_for('PetCare.list_posts'))
예제 #3
0
def delete_post():
    if session.get('logged_in') is not None:
        accountDao = AccountDao()
        ownerMatched = accountDao.remove_account_post(session['logged_in'],
                                                      request.form['postId'])
        if not ownerMatched:
            return redirect(url_for('PetCare.list_posts'))
        postDao = PostDao()
        prevImages = postDao.remove_post(request.form['postId'])
        for img in prevImages:
            ImageHandler.delete_image(img)
    return redirect(url_for('PetCare.list_posts'))