コード例 #1
0
ファイル: views.py プロジェクト: gmist/1businka
def show(request, uid):
    news = News.get_by_id(uid)
    if not news:
        return redirect(url_for('news'))
    images = NewsImage.query(NewsImage.news_ref == news.key)
    return render_to_response('news/show.html', {
        'news': news,
        'images': images
    })
コード例 #2
0
ファイル: views.py プロジェクト: gmist/1businka
def admin_images(request, uid):
    news = News.get_by_id(uid)
    if not news:
        return render_to_response('empty.html')
    images = NewsImage.query(NewsImage.news_ref == news.key)
    url = blobstore.create_upload_url(url_for('news/admin/images/add', uid=news.key.id()))
    return render_to_response('news/admin/images.html',{
        'images': images,
        'news': news,
        'url': url
        })
コード例 #3
0
ファイル: views.py プロジェクト: gmist/1businka
def admin_add_image(request, uid):
    if request.method == 'POST':
        news = News.get_by_id(uid)
        if not news:
            return render_json_response({'api':{'success':False}})
        upload_files = get_uploads(request, 'file')
        if len(upload_files):
            blob_info = upload_files[0]
            if blob_info.size:
                image = NewsImage.create(blob_info.key())
                news = News.get_by_id(uid)
                images = NewsImage.query(NewsImage.news_ref == news.key)
                if not images.count:
                    image.is_master = True
                image.news_ref = news.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')