예제 #1
0
def index():
    if current_user.is_authenticated:
        images = Image.select(Image, User).join(User).where(
            Image.user_id != current_user.id).order_by(Image.created_at.desc())
        return render_template('users/index.html', images=images)
    else:
        images = Image.select().order_by(Image.created_at.desc())
        return render_template('users/index.html', images=images)
예제 #2
0
def show(username):
    user = User.get(User.username == username)
    image_list = Image.select().where(Image.user_id == user.id)
    return render_template("users/profile.html",
                           username=username,
                           user=user,
                           image_list=image_list)
예제 #3
0
def new(image_id):
    if not current_user.is_authenticated:
        flash(u'Need to be logged in to donate.', 'warning')
        return redirect(request.referrer)
    current_user_images = Image.select(
        Image.id).where(Image.user_id == current_user.id)
    for cui_id in current_user_images:
        if image_id == str(cui_id):
            flash(
                'Sorry you cannot donate to yourself. You already own that money :)',
                'danger')
            return redirect(url_for('users.index'))

    client_token = gateway.client_token.generate({})
    return render_template('donations/new.html',
                           image_id=image_id,
                           client_token=client_token)
예제 #4
0
def index():
    images = Image.select().order_by(Image.created_at.desc())
    return render_template('/users/index.html',images = images)