예제 #1
0
파일: views.py 프로젝트: kharissa/instagood
def approve(user_id):
    follower = User.get_by_id(user_id)
    r = Relationship.get(Relationship.follower_id == user_id,
                         Relationship.following_id == current_user.id)
    r.is_approved = True

    if r.save():
        flash(f"You have approved {follower.name}'s follow request.")
        return redirect(url_for('users.show', username=follower.username))
    else:
        return render_template(
            'users/show.html',
            user=current_user,
            photos=Image.select().where(Image.user_id == current_user.id),
            errors=r.errors)
예제 #2
0
파일: views.py 프로젝트: kharissa/instagood
def reject(user_id):
    follower = User.get_by_id(user_id)
    r = Relationship.get(Relationship.follower_id == user_id,
                         Relationship.following_id == current_user.id)

    try:
        if Task.get(Task.relationship_id == r.id):
            t = Task.get(Task.relationship_id == r.id)
            t.delete_instance()
    except:
        pass

    r.delete_instance()
    flash(f"You have rejected {follower.name}'s follow request.")
    return redirect(url_for('users.show', username=current_user.username))
예제 #3
0
파일: views.py 프로젝트: kharissa/instagood
def destroy(following_id):
    following = User.get_by_id(following_id)
    r = Relationship.get(Relationship.follower_id == current_user.id,
                         Relationship.following_id == following_id)

    try:
        if Task.get(Task.relationship_id == r.id):
            t = Task.get(Task.relationship_id == r.id)
            t.delete_instance()
    except:
        pass

    r.delete_instance()
    flash(f"You have unfollowed {following.name}.")

    return render_template(
        'users/show.html',
        user=following,
        photos=Image.select().where(Image.user_id == following.id))