当前位置: 首页>>代码示例>>Python>>正文


Python Image.artist方法代码示例

本文整理汇总了Python中models.Image.artist方法的典型用法代码示例。如果您正苦于以下问题:Python Image.artist方法的具体用法?Python Image.artist怎么用?Python Image.artist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Image的用法示例。


在下文中一共展示了Image.artist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handleImagePopAdd

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import artist [as 别名]
def handleImagePopAdd(request, addForm, field, template="form/popmediaadd.html"):
    if not request.method == "POST":
        f = UploadForm()
        ctx = {'form': f, 'field': field}
        return render(request, template, ctx)

    f = UploadForm(request.POST, request.FILES)

    if not f.is_valid() and not request.FILES['file'].name.endswith('.svg'):
        ctx = {'form': f, 'field': field}
        return render(request, template, ctx)
    file = request.FILES['file']
    store_in_s3(file.name, file.read())
    p = Image(url="http://%s.s3.amazonaws.com/%s" % (bucket, file.name))

    if isinstance(request.user, AnonymousUser):
        p.user = User.objects.get(username="Anonymous")
    else:
        p.user = User.objects.get(username=request.user)
    if request.POST['artist']:
        p.artist = User.objects.get(pk=request.POST['artist'])
    p.save()
    newObject = p

    # Self destruction:
    if newObject:
        return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' %\
            (escape(newObject._get_pk_val()), escape(newObject)))
开发者ID:McDoku,项目名称:denigma,代码行数:30,代码来源:views.py

示例2: index

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import artist [as 别名]
def index(request, template='./gallery/index.html'):
    entry = get("Gallery")

    if 'gallery' in request.POST and request.POST['gallery']:
        artist = User.objects.get(pk=request.POST['gallery'])
        photos = Image.objects.filter(artist=artist).order_by('-uploaded')
    else:
        photos = Image.objects.all().order_by('-uploaded')

    if not request.method == "POST" or ('gallery' in request.POST):
        f = UploadForm()
        af = ArtistForm(request.POST)
        ctx = {'entry': entry, 'form': f, 'photos': photos, 'artist': af}
        return render(request, template, ctx)

    f = UploadForm(request.POST, request.FILES)
    af = ArtistForm(request.POST)


    if not f.is_valid() and not request.FILES['file'].name.endswith('.svg'):
        ctx = {'entry': entry, 'form': f, 'photos': photos, 'artist': af}
        return render(request, template, ctx)

    file = request.FILES['file']
    #print type(file)
    #print dir(file)
    #for k,v in file.items(): print k, v
    #filename = file._get_name() #['filename']
    #content = file['content']
    store_in_s3(file.name, file.read())
    p = Image(url="http://%s.s3.amazonaws.com/%s" % (bucket, file.name))

    if isinstance(request.user, AnonymousUser):
         p.user = User.objects.get(username="Anonymous")
    else:
        p.user = User.objects.get(username=request.user)
    if request.POST['artist']:
        p.artist = User.objects.get(pk=request.POST['artist'])
    p.save()
    photos = Image.objects.all().order_by('-uploaded')
    ctx = {'entry': entry, 'form': f, 'photos': photos, 'artist': af}
    return render(request, template, ctx)
开发者ID:McDoku,项目名称:denigma,代码行数:44,代码来源:views.py


注:本文中的models.Image.artist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。