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


Python Result.isSuccess方法代码示例

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


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

示例1: manage

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def manage(request):
    if request.method == "GET":
        guids = request.GET.get("guids", "").split(",")
        guids = filter(None, guids)

        objects = getObjectsFromGuids(guids)
        ids = [o.id for o in objects]

        imgtags = list(Tag.objects.filter(image__id__in=ids).exclude(artist=True))
        vidtags = list(Tag.objects.filter(video__id__in=ids).exclude(artist=True))
        tags = list(set(imgtags + vidtags))

        if request.GET.get("json", False):
            res = Result()
            data = {"queries": connection.queries}

            res.value = data

            res.isSuccess = True

            return JsonResponse(res)

        return render(request, "frog/tag_manage.html", {"tags": tags})
    else:
        add = request.POST.get("add", "").split(",")
        rem = request.POST.get("rem", "").split(",")
        guids = request.POST.get("guids", "").split(",")

        add = filter(None, add)
        rem = filter(None, rem)
        addList = []

        for t in add:
            try:
                addList.append(int(t))
            except ValueError:
                tag, created = Tag.objects.get_or_create(name=t)
                tag.save()
                addList.append(tag.id)

        objects = getObjectsFromGuids(guids)
        addTags = Tag.objects.filter(id__in=addList)
        remTags = Tag.objects.filter(id__in=rem)

        for o in objects:
            for a in addTags:
                o.tags.add(a)
            for r in remTags:
                o.tags.remove(r)

        res = Result()
        res.isSuccess = True

        return JsonResponse(res)
开发者ID:nickryand,项目名称:Frog,代码行数:56,代码来源:tag.py

示例2: post

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def post(request):
    """Sets a key to a value on the currently logged in users preferences

    :param key: Key to set
    :type key: str
    :param val: Value to set
    :type val: primitive
    :returns: json
    """
    key = request.POST.get('key', None)
    val = request.POST.get('val', None)
    res = Result()
    if key and val:
        obj, created = UserPref.objects.get_or_create(user=request.user)
        if created:
            obj.data = json.dumps(DefaultPrefs.copy())
            obj.save()
        val = json.loads(val)
        obj.setKey(key, val)
        obj.save()
        res.append(obj.json())
        res.isSuccess = True
    else:
        res.isError = True
        res.message = 'No key and value provided'

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:29,代码来源:userpref.py

示例3: post

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def post(request):
    """Returns a serialized object
    :param obj_id: ID of comment object
    :type obj_id: int
    :returns: json
    """
    guid = request.POST.get('guid', None)
    res = Result()   

    if guid:
        obj = getObjectsFromGuids([guid,])[0]
        c = Comment()
        c.comment = request.POST.get('comment', 'No comment')
        c.user = request.user
        c.user_name = request.user.get_full_name()
        c.user_email = request.user.email
        c.content_object = obj
        c.site_id = 1
        c.save()
        obj.comment_count = obj.comment_count + 1
        obj.save()

        __email(c, obj)

        res.append({'id': c.id, 'comment': c.comment})
        res.isSuccess = True
    else:
        res.isError = True
        res.message = "No guid provided"

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:33,代码来源:comment.py

示例4: post

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def post(request):
    """Creates a tag object

    :param name: Name for tag
    :type name: str
    :returns: json
    """
    res = Result()
    name = request.POST.get("name", None)

    if not name:
        res.isError = True
        res.message = "No name given"

        return JsonResponse(res)

    tag, created = Tag.objects.get_or_create(name=name)

    res.isSuccess = True
    if created:
        res.message = "Created"

    res.append(tag.json())

    return JsonResponse(res)
开发者ID:nickryand,项目名称:Frog,代码行数:27,代码来源:tag.py

示例5: get

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def get(request, obj_id=None):
    if obj_id:
        obj = Gallery.objects.get(pk=obj_id)
        if obj.security != Gallery.PUBLIC and request.user.is_anonymous():
            return HttpResponseRedirect('frogaccess_denied')

        return render(request, 'frog/gallery.html', {'object': obj})
    else:
        res = Result()
        res.isSuccess = True
        flat = bool(request.GET.get('flat'))
        if request.user.is_anonymous():
            objects = Gallery.objects.filter(security=Gallery.PUBLIC)
        else:
            objects = Gallery.objects.filter(Q(security__lt=Gallery.PRIVATE) | Q(owner=request.user))

        objects = objects.filter(parent__isnull=True)

        for n in objects:
            if flat:
                res.append({'title': n.title, 'id': n.id});
                for child in n.gallery_set.all().order_by('title'):
                    res.append({'title': '-- %s' % child.title, 'id': child.id});
            else:
                res.append(n.json())

        return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:29,代码来源:gallery.py

示例6: isUnique

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def isUnique(request):
    path = request.GET.get('path', None)
    res = Result()
    if path:
        if request.user.is_anonymous():
            username = request.GET.get('user', 'noauthor')
            user = User.objects.get(username=username)
        else:
            user = request.user
        
        uniqueID = Piece.getUniqueID(path, user)

        img = Image.objects.filter(unique_id=uniqueID)
        vid = Video.objects.filter(unique_id=uniqueID)
        if img:
            res.append(img[0].json())
        elif vid:
            res.append(vid[0].json())
        else:
            res.append(True)

        res.isSuccess = True
    else:
        res.isError = True
        res.message = "No path provided"

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:29,代码来源:__init__.py

示例7: post

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def post(request):
    """ Create a Gallery """
    defaultname = 'New Gallery %i' % Gallery.objects.all().count()
    title = request.POST.get('title', defaultname)
    description = request.POST.get('description', '')
    security = int(request.POST.get('security', Gallery.PUBLIC))
    parentid = request.POST.get('parent')
    if parentid:
        parent = Gallery.objects.get(pk=int(parentid))
        g, created = parent.gallery_set.get_or_create(title=title)
        g.security = parent.security
    else:
        g, created = Gallery.objects.get_or_create(title=title)
        g.security = security

    g.description = description
    g.owner = request.user
    g.save()

    res = Result()
    res.isSuccess = True
    res.append(g.json())
    res.message = 'Gallery created' if created else ''

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:27,代码来源:gallery.py

示例8: put

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def put(request, obj_id=None):
    """ Adds Image and Video objects to Gallery based on GUIDs """
    guids = filter(None, request.PUT.get('guids', '').split(','))
    security = request.PUT.get('security')
    object_ = Gallery.objects.get(pk=obj_id)
    
    if guids:
        objects = getObjectsFromGuids(guids)

        images = filter(lambda x: isinstance(x, Image), objects)
        videos = filter(lambda x: isinstance(x, Video), objects)

        object_.images.add(*images)
        object_.videos.add(*videos)
    
    if security is not None:
        object_.security = json.loads(security)
        object_.save()
        for child in object_.gallery_set.all():
            child.security = object_.security
            child.save()

    res = Result()
    res.append(object_.json())
    res.isSuccess = True

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:29,代码来源:gallery.py

示例9: delete

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def delete(self, request, obj):
    obj.deleted = True
    obj.save()
    res = Result()
    res.isSuccess = True
    res.value = obj.json()

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:10,代码来源:piece.py

示例10: get

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def get(request, obj_id):
    """Returns a serialized object
    :param obj_id: ID of comment object
    :type obj_id: int
    :returns: json
    """
    res = Result()
    c = Comment.objects.get(pk=obj_id)
    res.append(commentToJson(c))
    res.isSuccess = True

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:14,代码来源:comment.py

示例11: getUser

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def getUser(request):
    res = Result()
    if request.user.is_anonymous():
        res.isError = True
        res.append(DefaultPrefs)
    else:
        galleryid = request.GET.get('gallery')
        if galleryid is not None:
            gallery = Gallery.objects.filter(pk=galleryid, owner=request.user)
            if gallery:
                res.append(gallery[0].json())
        res.isSuccess = True

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:16,代码来源:__init__.py

示例12: get

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def get(request):
    """Gets the currently logged in users preferences

    :returns: json
    """
    res = Result()
    obj, created = UserPref.objects.get_or_create(user=request.user)
    if created:
        obj.data = json.dumps(DefaultPrefs.copy())
        obj.save()
    res.append(obj.json())
    res.isSuccess = True

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:16,代码来源:userpref.py

示例13: post

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def post(self, request, obj):
    tags = request.POST.get('tags', '').split(',')
    res = Result()
    for tag in tags:
        try:
            t = Tag.objects.get(pk=int(tag))
        except ValueError:
            t, created = Tag.objects.get_or_create(name=tag)
            if created:
                res.append(t.json())
        obj.tags.add(t)

    res.isSuccess = True

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:17,代码来源:piece.py

示例14: get

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def get(request, obj_id=None):
    """Lists all tags

    :returns: json
    """
    if obj_id:
        obj = get_object_or_404(Tag, pk=obj_id)

        return render(request, "frog/tag.html", {"object": obj})
    else:
        res = Result()
        res.isSuccess = True
        for n in Tag.objects.all():
            res.append(n.json())

        return JsonResponse(res)
开发者ID:nickryand,项目名称:Frog,代码行数:18,代码来源:tag.py

示例15: delete

# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import isSuccess [as 别名]
def delete(request, obj_id=None):
    """ Removes ImageVideo objects from Gallery """
    guids = request.DELETE.get('guids', '').split(',')
    objects = getObjectsFromGuids(guids)
    object_ = Gallery.objects.get(pk=obj_id)

    for o in objects:
        if isinstance(o, Image):
            object_.images.remove(o)
        elif isinstance(o, Video):
            object_.videos.remove(o)

    res = Result()
    res.isSuccess = True

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:18,代码来源:gallery.py


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