コード例 #1
0
def match():
	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()
		if postDao.add_match(postId, request.form['userId']):
			careGiverEmail = accountDao.get_account_email(request.form['userId'])
			userEmail = accountDao.get_account_email(session['logged_in'].rstrip())
			EmailHandler.send_approval(careGiverEmail, postId, userEmail)
	return redirect(url_for('PetCare.profile', userId=request.form['userId']))
コード例 #2
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'))
コード例 #3
0
def profile():
	if 'login' in request.args and session.get('logged_in') is not None and session.get('logged_in') != request.args['login']:
		session.pop('logged_in', None)
	if session.get('logged_in') is None:
		if 'login' not in request.args:
			return redirect(url_for('PetCare.login')) 
		else:
			return redirect(url_for('PetCare.prompt_login', userId=request.args['login'], targetId=request.args['userId'].rstrip()))
	accountDao = AccountDao()
	postDao = PostDao()
	accountInfo = accountDao.get_account_info(request.args['userId'].rstrip())
	posts = postDao.get_user_posts(request.args['userId'].rstrip())
	postInfos = [Entities.make_post_output(dict(post)) for post in posts]
	myCurrentPostId = accountDao.get_account_post(session['logged_in'].rstrip())
	status = 'UNRELATED' if myCurrentPostId is None else postDao.check_relation(myCurrentPostId, request.args['userId'].rstrip())
	return render_template('profile.html', account=accountInfo, posts=postInfos, status=status)
コード例 #4
0
def create_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'].rstrip())
	if postId is not None:
		return redirect(url_for('PetCare.edit_post'))
	if request.method == 'GET':
		return render_template('create_post.html', error=None)
	postInfo = Entities.make_post_info(session['logged_in'].rstrip(), request)
	if not postInfo:
		return render_template('create_post.html', error="Required Informaion Missing")
	postId = postDao.add_post(postInfo)
	accountDao.update_account_post(session['logged_in'].rstrip(), postId)
	return redirect(url_for('PetCare.list_posts'))
コード例 #5
0
ファイル: PetCare.py プロジェクト: zhw278/tritonPetCare
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'))
コード例 #6
0
ファイル: PetCare.py プロジェクト: zhw278/tritonPetCare
def profile():
    if 'login' in request.args and session.get(
            'logged_in'
    ) is not None and session.get('logged_in') != request.args['login']:
        session.pop('logged_in', None)
    if session.get('logged_in') is None:
        if 'login' not in request.args:
            return redirect(url_for('PetCare.login'))
        else:
            return redirect(
                url_for('PetCare.prompt_login',
                        userId=request.args['login'],
                        targetId=request.args['userId']))
    accountDao = AccountDao()
    postDao = PostDao()
    accountInfo = accountDao.get_account_info(request.args['userId'])
    posts = postDao.get_user_posts(request.args['userId'])
    myCurrentPostId = accountDao.get_account_post(session['logged_in'])
    isInterested = False if myCurrentPostId is None else postDao.check_interested(
        myCurrentPostId, request.args['userId'])
    return render_template('profile.html',
                           account=accountInfo,
                           posts=posts,
                           isInterested=isInterested)