예제 #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')