コード例 #1
0
ファイル: admin.py プロジェクト: pombredanne/Lady-Penh
 def save_model(self, request, obj, form, change):
     if 'pic' in request.FILES:
         pic = request.FILES['pic']
         picname = format_filename(pic.name, obj.date)
         picpath = "edito/%s" % picname
         imgobj = ImageFile(name=picpath, blob=pic.read())
         imgobj.put()
         obj.picname = picpath
     obj.save()
     if not obj.numid:
         obj.numid = obj.key().id()
         obj.save()
コード例 #2
0
ファイル: admin.py プロジェクト: pombredanne/Lady-Penh
 def save_model(self, request, obj, form, change):
     if 'pic' in request.FILES:
         pic = request.FILES['pic']
         blob = pic.read()
         obj.picname = format_filename(pic.name, obj.date)
         if obj.haslargepic:
             largepath = "event/large/%s" % obj.picname
             largeobj = ImageFile(name=largepath, blob=blob)
             largeobj.put()
         thumb = images.Image(blob)
         if thumb.width > 200:
             thumb.resize(width=200)
             blob = thumb.execute_transforms()
         thumbpath = "event/thumb/%s" % obj.picname
         thumbobj = ImageFile(name=thumbpath, blob=blob)
         thumbobj.put()
     obj.save()
     if not obj.numid:
         obj.numid = obj.key().id()
         obj.save()
     if obj.date <= datetime.now().date():
         msg = Message(
             user=request.user, 
             message="WARNING: date for %s is today or older! Please make sure the date is ok." % obj.title)
         msg.save()
コード例 #3
0
ファイル: views.py プロジェクト: pombredanne/Lady-Penh
def image(request, name):
    mime = mimetypes.guess_type(name)[0]
    bfiles = ImageFile.gql("WHERE name = :1", name).fetch(1)
    response = HttpResponse(bfiles[0].blob, mimetype=mime)
    response['Last-Modified'] = defaultdate.strftime("%a, %d %b %Y %H:%M:%S GMT")
    return response