Esempio n. 1
0
def show(request, uid):
    showcase = Showcase.get_by_id(uid)
    if not showcase:
        return redirect(url_for('showcase'))
    images = showcase.images
    return render_to_response('showcase/show.html', {
        'showcase': showcase,
        'images': images
    })
Esempio n. 2
0
def admin_images(request, uid):
    showcase = Showcase.get_by_id(uid)
    if not showcase:
        return render_to_response('empty.html')
    images = showcase.images
    url = blobstore.create_upload_url(url_for('showcase/admin/images/add', uid=showcase.key().id()))
    return render_to_response('showcase/admin/images.html',{
        'images': images,
        'showcase': showcase,
        'url': url
        })
Esempio n. 3
0
def index(request):
    showcases = Showcase.all().filter('is_display =', True).order("-add_time")
    paginator = Paginator(showcases, 5)
    try:
        page = int(request.args.get('page', 1))
    except ValueError:
        page = 1
    try:
        showcases = paginator.page(page)
    except (EmptyPage, InvalidPage):
        showcases = paginator.page(paginator.num_pages())

    return render_to_response('showcase/index.html', {
        'showcases': showcases
    })
Esempio n. 4
0
def admin_add_image(request, uid):
    if request.method == 'POST':
        showcase = Showcase.get_by_id(uid)
        if not showcase:
            return render_to_response('empty.html')
        upload_files = get_uploads(request, 'file')
        if len(upload_files):
            blob_info = upload_files[0]
            if blob_info.size:
                image = ShowcaseImage(showcase_key=showcase.key(),
                    image_key=str(blob_info.key()))
                image.cached_url = image.get_cached_url()
                image.put()
            else:
                 blob_info.delete()
        return admin_images(request, uid)
    return render_to_response('empty.html')
Esempio n. 5
0
def admin_edit(request, uid):
    showcase = Showcase.get_by_id(uid)
    if not showcase:
        return redirect(url_for('showcase/admin/list'))
    form = ShowcaseForm(instance=showcase)
    if request.method == 'POST':
        if form.validate(request.form):
            form.save()
            return redirect(url_for('showcase/admin/list'))
        else:
            return render_to_response(
                    'showcase/admin/edit.html', {
                        'form': form.as_widget(),
                        'showcase': showcase
                    })
    return render_to_response(
        'showcase/admin/edit.html', {
            'form': form.as_widget(),
            'showcase': showcase
        })
Esempio n. 6
0
def admin_delete(request, uid):
    showcase = Showcase.get_by_id(uid)
    if showcase:
        showcase.delete()
    return redirect(url_for('showcase/admin/list'))
Esempio n. 7
0
def admin_add(request):
    showcase = Showcase()
    showcase.put()
    form = ShowcaseForm(instance=showcase, action=url_for('showcase/admin/edit', uid=showcase.key().id()))
    return render_to_response('showcase/admin/edit.html', {'form': form.as_widget(), 'showcase': showcase})
Esempio n. 8
0
def admin_list(request):
    showcases = Showcase.all().order('-add_time')
    return render_to_response('showcase/admin/list.html', {'showcases':showcases})
Esempio n. 9
0
def showcases(request):
  showcases_objs = Showcase.all()
  return render_json_response([to_dict(o) for o in showcases_objs])