Exemplo n.º 1
0
def get_prev_next_images(profile, img, limit=2):
    # query for "all" images though we need just the `limit`
    # bcoz we don't know how many are there in deleteQ.
    imgs = profile.stored_files.order_by('created_at desc').all()
    imgs = not_in_deleteQ(imgs)
    pos = imgs.index(img)
    return imgs[pos+1 : pos+1+limit], imgs[:pos][-limit:]
Exemplo n.º 2
0
def pop_up_gallery(profile):
    label = request.args.get('label')
    files = profile.stored_files
    if label:
        files = files.join(StoredFile.labels).filter(Label.name==label)
    files = files.order_by('stored_file.created_at desc').all()
    files = not_in_deleteQ(files)
    form = forms.UploadImageForm()
    cp_form = forms.ChangeProfileForm()
    cp_form.profiles.choices = [(p.id, p.name) for p in g.user.profiles]
    return render_template('pop_up_gallery.html', files=files, label=label,
                profile=profile, uploadform=form, cp_form=cp_form)
Exemplo n.º 3
0
def unlabelled_images(profile):
    """Get all unlabelled images owned by profile"""
    files = profile.stored_files.filter(not_(StoredFile.labels.any())).order_by('created_at desc').all()
    files = not_in_deleteQ(files)
    title_form = forms.EditTitleForm()
    return render_template('profile.html', profile=profile, files=files, title_form=title_form, unlabelled=True)
Exemplo n.º 4
0
def profile_view(profile):
    files = profile.stored_files.order_by('created_at desc').all()
    files = not_in_deleteQ(files)
    title_form = forms.EditTitleForm()
    upload_form = forms.UploadImageForm()
    return render_template('profile.html', profile=profile, files=files, uploadform=upload_form, title_form=title_form, mimetypes=ALLOWED_MIMETYPES.keys())