示例#1
0
文件: views.py 项目: gmist/1businka
def admin_delete(request, key_id):
    if request.method == 'POST':
        gram = GramPhoto.get_by_id(key_id)
        if gram:
            gram.pre_delete()
        gram.key.delete()
    return redirect(url_for('gram/admin/index'))
示例#2
0
文件: views.py 项目: gmist/1businka
def admin_index(request):
    photos = GramPhoto.query().order(-GramPhoto.add_time)
    url = blobstore.create_upload_url(url_for('gram/admin/add'))
    return render_to_response(
        'gram/admin/index.html', {
            'photos': photos,
            'url': url
        })
示例#3
0
文件: views.py 项目: gmist/1businka
def admin_add(request):
    if request.method == 'POST':
        upload_files = get_uploads(request, 'file')
        if len(upload_files):
            blob_info = upload_files[0]
            if blob_info.size:
                image = GramPhoto.create(blob_info.key())
                image.put()
            else:
                blob_info.delete()
    return redirect(url_for('gram/admin/index'))
示例#4
0
文件: views.py 项目: gmist/1businka
def load(request, offset):
    offset = int(offset)
    if offset <= 0:
        return render_to_response('empty.html')
    grams = GramPhoto.query().order(-GramPhoto.add_time)
    length = grams.count()
    if offset >= length:
        return render_to_response('empty.html')
    limit = 8
    is_end = False
    if offset + limit >= length:
        limit = length - offset
        is_end = True
    grams = grams.fetch(limit, offset=offset-1)
    return render_to_response('gram/load.html', {'grams': grams, 'is_end': is_end})
示例#5
0
文件: views.py 项目: gmist/1businka
def index(request):
    grams = GramPhoto.query().order(-GramPhoto.add_time).fetch(4)
    return render_to_response('page/index.html', {'grams': grams})