• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python jsonresult.get_result函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.jsonresult.get_result函数的典型用法代码示例。如果您正苦于以下问题:Python get_result函数的具体用法?Python get_result怎么用?Python get_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: send_sms_code

def send_sms_code(request, tel):
    """
    发送修改密码的验证码
    :param request:
    :param tel:
    :return:
    发送修改密码的验证码
    by:王健 at:2016-04-21
    """
    # todo:虚假发送验证码,待完善
    before_sms = request.session.get('smstime')
    if before_sms and time.time() - before_sms < 60:
        return get_result(False, u'每分钟只能发送一条验证码短信')
    num = request.session.get('smsnum', 0)
    if num > 10:
        return get_result(False, u'当天发送短信验证码太多')
    if get_user_model().objects.filter(username=tel).exists():
        request.session['smsusername'] = tel
        request.session['smstime'] = time.time()
        request.session['smscode'] = 1234
        request.session['smsnum'] = num + 1
    else:
        return get_result(False, u'手机号不存在')

    return get_result(True, u'发送验证码成功')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:25,代码来源:views.py


示例2: remove_manager_org

def remove_manager_org(request, org_id, user_id, person):
    """
    移除管理员
    :param user_id:
    :param person:
    :param request:
    :param org_id:
    :return:
    移除管理员
    by:王健 at:2016-04-27
    组织成员变动事件
    by:王健 at:2016-05-03
    """
    if person.manage_type == 2:
        return get_result(False, u'只有超级管理员才能移除管理员')
    try:

        member = Person.objects.get(user_id=user_id, org_id=org_id, is_active=True)
        member.copy_old()
        member.manage_type = 0
        create, diff = member.compare_old()
        if diff:
            member.save()
            org_commend("remove_manager_org", org_id, u"%s 取消您 %s 管理员身份" % (person.realname, person.org.name), [user_id])
            org_commend("org_member_change", org_id, None)
        return get_result(True, u'成功将用户设置成管理员', member)
    except Person.DoesNotExist:
        return get_result(False, u'用户不是该组织成员')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:28,代码来源:views_org.py


示例3: transfer_manager_org

def transfer_manager_org(request, org_id, user_id, person):
    """
    添加新的超级管理员
    :param user_id:
    :param person:
    :param request:
    :param org_id:
    :return:
    添加新的超级管理员
    by:王健 at:2016-04-27
    组织成员变动事件
    by:王健 at:2016-05-03
    """
    if person.manage_type == 2:
        return get_result(False, u'只有超级管理员才能添加新的超级管理员')
    try:

        member = Person.objects.get(user_id=user_id, org_id=org_id, is_active=True)
        member.copy_old()
        member.manage_type = 2
        create, diff = member.compare_old()
        if diff:
            member.save()
            org_commend("transfer_manager_org", org_id, u"%s 设置您为 %s 超级管理员身份" % (person.realname, person.org.name), [user_id])
            member_ids = get_org_member_ids_by_manage_type(org_id, [1, 2])
            member_ids.remove(user_id)
            org_commend("transfer_manager_org", org_id, u"%s 设置 %s 为 %s 超级管理员" % (person.realname, member.realname, person.org.name), member_ids)

            org_commend("org_member_change", org_id, None)
        return get_result(True, u'成功将用户设置成超级管理员', member)
    except Person.DoesNotExist:
        return get_result(False, u'用户不是该组织成员')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:32,代码来源:views_org.py


示例4: change_password_by_code

def change_password_by_code(request, username, newpassword, code):
    """
    通手机验证码修改密码
    :param username:
    :param request:
    :param newpassword:
    :param code:
    :return:
    通手机验证码修改密码
    by:王健 at:2016-04-21
    """
    if code != request.session.get('smscode', 1234):
        return get_result(False, u'短信验证码输入错误,请核实!')
    if username != request.session.get('smsusername'):
        return get_result(False, u'手机号和短信验证码发送的手机号不一致,请核实!', None)
    try:
        user = get_user_model().objects.get(username=username)
    except get_user_model().DoesNotExist:
        return get_result(False, u'用户不存在')
    if not user.is_active:
        return get_result(False, u'用户已经停止使用。')

    user.set_password(newpassword)
    user.save(update_fields=['password'])

    return get_result(True, u'重置密码成功,请重新登录')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:26,代码来源:views.py


示例5: make_appinfo_permission

def make_appinfo_permission(request, org_id, app_id, user_id, role_id, person):
    """
    从组织中删除应用
    :param request:
    :param org_id:
    :return:
    从组织中删除应用
    by:王健 at:2016-04-27
    """
    try:
        org = person.org
        app = AppInfo.objects.get(pk=app_id, orgapp__org_id=org_id, is_active=True, orgapp__is_active=True)
        person = Person.objects.get(org_id=org_id, user_id=user_id, is_active=True)
        permission, created = Permissions.objects.get_or_create(org=org, person=person, app=app)
        permission.copy_old()
        if role_id is None:
            permission.is_active = False
        else:
            permission.role = AppRole.objects.get(app_id=app_id, pk=role_id, is_active=True)
        create, diff = permission.compare_old()
        if diff:
            permission.save()
        return get_result(True, u'修改用户在应用中的角色成功')
    except OrgApp.DoesNotExist:
        return get_result(False, u'组织中没有这个应用')
    except AppInfo.DoesNotExist:
        return get_result(False, u'应用不存在')
    except Person.DoesNotExist:
        return get_result(False, u'用户不是组织的成员')
    except AppRole.DoesNotExist:
        return get_result(False, u'应用中不存在这个角色')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:31,代码来源:views_appinfo.py


示例6: remove_person_org

def remove_person_org(request, org_id, user_id, person):
    """
    把用户移出组织
    :param user_id:
    :param person:
    :param request:
    :param org_id:
    :return:
    把用户移出组织
    by:王健 at:2016-04-27
    组织成员变动事件
    by:王健 at:2016-05-03
    """
    try:

        member = Person.objects.get(user_id=user_id, org_id=org_id)
        member.copy_old()
        member.is_active = False
        create, diff = member.compare_old()
        if diff:
            member.save()
            org_commend("remove_person_org", org_id, u"%s 将您移出 %s " % (person.realname, person.org.name), [user_id])
            org_commend("org_member_change", org_id, None)
        return get_result(True, u'成功将用户移出组织', member)
    except Person.DoesNotExist:
        return get_result(False, u'用户不是该组织成员')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:26,代码来源:views_org.py


示例7: reject_organization

def reject_organization(request, org_id, orgapply_id, person):
    """
    拒绝加入组织
    :param orgapply_id:
    :param person:
    :param request:
    :param org_id:
    :return:
    拒绝加入组织
    by:王健 at:2016-04-27
    拒绝加入事件
    by:王健 at:2016-05-03
    """
    try:
        apporg = OrgApply.objects.get(id=orgapply_id, org_id=org_id)
        if apporg.status != 0:
            if apporg.status == 1:
                return get_result(False, u'该申请已经被 %s 通过' % apporg.checker)
            elif apporg.status == 2:
                return get_result(False, u'该申请已经被 %s 拒绝' % apporg.checker)
            else:
                return get_result(False, u'该申请已经被 %s 处理' % apporg.checker)

        apporg.copy_old()
        apporg.status = 2
        apporg.compare_old()
        apporg.save()
        org_commend("reject_organization", org_id, u"您被拒绝加入 %s" % apporg.org.name, [apporg.user_id])
        return get_result(True, u'已经绝用户的加入组织申请', apporg)
    except OrgApply.DoesNotExist:
        return get_result(False, u'这不是发给您的组织的申请,您不能处理')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:31,代码来源:views_org.py


示例8: remove_talkgroup

def remove_talkgroup(request, talkgroup_id, user_id, talkuser):
    """
    踢人出群
    :param talkuser:
    :param user_id:
    :param request:
    :param talkgroup_id:
    :return:
    踢出群
    by:王健 at:2016-04-25
    """
    if talkuser.talkgroup.owner_id != request.user.id and talkuser.role != 1:
        return get_result(False, u'只有群主和管理员才能踢人出群')
    member = TalkUser.objects.get(talkgroup_id=talkgroup_id, user_id=user_id)
    member.copy_old()
    member.is_active = False
    member.compare_old()
    member.save()
    member.push_im_event(request.user)
    talkgroup = talkuser.talkgroup
    talkgroup.copy_old()
    talkgroup.make_md5_flag()
    created, diff = talkgroup.compare_old()
    if diff:
        talkgroup.save()
        im_commend("im_group_change", talkgroup.id)
    return get_result(True, u'踢出群成功')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:27,代码来源:views_talkgroup.py


示例9: process_exception

    def process_exception(self, request, e):
        """
        程序遇到未捕获的异常,会在此处整理出错误信息,和代码行数
        by:王健 at:2015-1-3
        修改日志 配置
        by:王健 at:2015-3-10
        修改获取用户手机号
        by:王健 at:2015-3-15
        优化 日志输入
        by:王健 at:2015-3-17
        修改错误堆栈信息 获取方式
        by:王健 at:2015-4-7
        修改错误输出格式
        by: 范俊伟 at:2015-04-19
        修改log输出函数
        by: 范俊伟 at:2015-05-05
        :param request:
        :param e:
        :return:
        """
        import time

        errorid = time.time()
        # client.user_context({
        #     "errorid": errorid,
        #     "url": request.path,
        #     "method": request.method,
        #     "post": json.dumps(request.POST.items(), ensure_ascii=False),
        #     "get": json.dumps(request.GET.items(), ensure_ascii=False),
        #     "ENVIRONMENT": settings.ENVIRONMENT,
        #
        # })
        # client.captureException()
        log = logging.getLogger('django')
        s = [u'错误码:%s' % errorid, u'%s:%s' % (request.method, request.path)]
        user = getattr(request, 'user', None)
        if hasattr(user, "tel"):
            s.append(u'用户:%s' % user.tel)
        else:
            s.append(u'未登录用户')
        s.append(u'出现以下错误:')
        # s.append(traceback.format_exc())
        etype, value, tb = sys.exc_info()
        s.append(repr(value.message))
        s.append(u'错误代码位置如下:')
        while tb is not None:
            f = tb.tb_frame
            lineno = tb.tb_lineno
            co = f.f_code
            filename = co.co_filename
            name = co.co_name
            s.append(u'File "%s", line %d, in %s' % (filename, lineno, name))
            tb = tb.tb_next
        if not settings.DEBUG:
            log.exception('\n    '.join(s))
            return get_result(False, u'服务器端错误,请联系管理员,错误标记码:%s' % errorid, dialog=2)
        else:
            m = '\n    '.join(s)
            log.exception(m)
            return get_result(False, u'服务器端错误,错误如下:\n%s' % (m), dialog=2)
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:60,代码来源:error_middle.py


示例10: create_organization

def create_organization(request, name, icon_url):
    """
    创建组织
    :param icon_url:
    :param name:
    :param request:
    :return:
    创建组织
    by:王健 at:2016-04-26
    """
    try:
        obj = Organization()
        obj.name = name
        obj.icon_url = icon_url
        obj.save()
        person = Person()
        person.org = obj
        person.manage_type = 2
        person.user = request.user
        person.realname = request.user.realname
        person.email = request.user.email
        person.save()

        org_commend("org_change", obj.id, None)

        return get_result(True, None, obj)
    except Organization.DoesNotExist:
        return get_result(False, u'组织不存在')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:28,代码来源:views_org.py


示例11: add_talkgroup

def add_talkgroup(request, talkgroup_id, user_id, talkuser):
    """
    拉人入群
    :param talkuser:
    :param user_id:
    :param request:
    :param talkgroup_id:
    :return:
    拉人入群
    by:王健 at:2016-04-25
    """
    if not talkuser.talkgroup.is_add and talkuser.talkgroup.owner_id != request.user.id and talkuser.role != 1:
        return get_result(False, u'只有群主和管理员才能拉人入群')

    member, created = TalkUser.objects.get_or_create(talkgroup_id=talkgroup_id, user_id=user_id)
    member.copy_old()
    member.is_active = True
    member.read_timeline = int(time.time())
    member.is_muted = False
    member.compare_old()
    member.save()
    member.push_im_event(request.user)
    talkgroup = talkuser.talkgroup
    talkgroup.copy_old()
    talkgroup.make_md5_flag()
    created, diff = talkgroup.compare_old()
    if diff:
        talkgroup.save()
        im_commend("im_group_change", talkgroup.id)
    return get_result(True, u'踢出群成功')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:30,代码来源:views_talkgroup.py


示例12: update_person_group

def update_person_group(request, org_id, user_id, realname, title, email, is_gaoguan, is_show_tel, is_show_email,
                        person):
    """
    修改组织成员信息
    :param group:
    :param person:
    :param user_id:
    :param request:
    :param org_id:
    :return:
    部门加人
    by:王健 at:2016-04-27
    """
    if person.manage_type in [1, 2]:
        try:
            member = Person.objects.get(org_id=org_id, user_id=user_id, is_active=True)
            member.copy_old()
            member.realname = realname
            member.email = email
            member.title = title
            member.is_gaoguan = is_gaoguan
            member.is_show_tel = is_show_tel
            member.is_show_email = is_show_email
            created, diff = member.compare_old()
            if diff:
                member.save()
                org_commend("org_group_change", org_id, None)
            return get_result(True, u'成员信息修改成功', member)
        except Person.DoesNotExist:
            return get_result(False, u'成员不存在')

    else:
        return get_result(False, u'只有管理员可以设置成员信息')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:33,代码来源:views_group.py


示例13: remove_group

def remove_group(request, org_id, person, group):
    """
    删除部门
    :param group:
    :param person:
    :param request:
    :param org_id:
    :return:
    删除部门
    by:王健 at:2016-04-27
    部门变动事件
    by:王健 at:2016-05-03
    """
    if check_person_group_permiss(person, group, True):

        if group.members.all().exist():
            return get_result(False, u'部门内还有成员, 请先移除成员')
        group.copy_old()
        group.is_active = False
        created, diff = group.compare_old()
        if diff:
            group.save()
            org_commend("org_group_change", org_id, None)
        return get_result(True, u'删除部门成功', group)
    else:
        return get_result(False, u'只有管理员、部门主管、父级部门主管、父级部门主管助手可以删除部门')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:26,代码来源:views_group.py


示例14: add_person_group

def add_person_group(request, org_id, user_id, person, group):
    """
    部门加人
    :param group:
    :param person:
    :param user_id:
    :param request:
    :param org_id:
    :return:
    部门加人
    by:王健 at:2016-04-27
    部门变动事件
    by:王健 at:2016-05-03
    """
    if check_person_group_permiss(person, group):

        try:
            group.members.add(Person.objects.get(org_id=org_id, user_id=user_id, is_active=True))

        except Person.DoesNotExist:
            return get_result(False, u'用户不是当前组织的成员,不能加入部门')
        clean_organization_groups_cache(org_id)
        org_commend("org_group_change", org_id, None)
        if group.talkgroup_id:
            talkuser, created = TalkUser.objects.get_or_create(talkgroup_id=group.talkgroup_id, user_id=user_id)
            talkuser.copy_old()
            talkuser.is_active = True
            crea, diff = talkuser.compare_old()
            if created or diff:
                talkuser.save()
                talkuser.push_im_event(request.user)
                im_commend("im_group_change", group.talkgroup_id)
        return get_result(True, u'部门加人成功')
    else:
        return get_result(False, u'只有管理员、部门主管、部门主管助手、父级部门主管、父级部门主管助手可以添加部门成员')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:35,代码来源:views_group.py


示例15: add_charge_group

def add_charge_group(request, org_id, group_id, user_id, person, group):
    """
    添加部门主管
    :param request:
    :param org_id:
    :return:
    添加部门主管
    by:王健 at:2016-04-27
    部门变动事件
    by:王健 at:2016-05-03
    """
    if check_person_group_permiss(person, group, True):
        group.copy_old()
        try:
            group.charge = Person.objects.get(org_id=org_id, user_id=user_id, is_active=True)
        except Person.DoesNotExist:
            return get_result(False, u'用户不是当前组织的成员,不能设置成主管')
        created, diff = group.compare_old()
        if diff:
            group.save()
            org_commend("org_group_change", org_id, None)
            if group.talkgroup_id is not None:
                talkuser, created = TalkUser.objects.get_or_create(talkgroup_id=group.talkgroup_id, user_id=user_id)
                talkuser.copy_old()
                talkuser.is_active = True
                crea, diff = talkuser.compare_old()
                if created or diff:
                    talkuser.save()
                    talkuser.push_im_event(request.user)
                    im_commend("im_group_change", group.talkgroup_id)

        return get_result(True, u'设置部门主管成功', group)
    else:
        return get_result(False, u'只有管理员、部门主管、父级部门主管、父级部门主管助手可以添加部门主管')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:34,代码来源:views_group.py


示例16: update_group

def update_group(request, org_id, group_id, name, icon_url, parent_id, person, group):
    """
    修改部门的信息
    :param request:
    :param org_id:
    :return:
    修改部门的信息
    by:王健 at:2016-04-27
    部门变动事件
    by:王健 at:2016-05-03
    """
    if not check_person_group_permiss(person, group):
        return get_result(False, u'只有管理员、部门主管、部门主管助手、父级部门主管、父级部门主管助手可以修改部门信息')
    try:
        if parent_id is not None:
            parentgroup = Group.objects.get(org_id=org_id, pk=parent_id, is_active=True)
    except Group.DoesNotExist:
        return get_result(False, u'设置的父级部门不存在,无法修改')

    group.copy_old()
    if name:
        group.name = name
    if icon_url:
        group.icon_url = icon_url
    if parent_id:
        group.parent_id = parent_id
    created, diff = group.compare_old()

    if diff:
        group.save()
        org_commend("org_group_change", org_id, None)

    return get_result(True, u'修改部门信息成功', group)
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:33,代码来源:views_group.py


示例17: pass_friendapply

def pass_friendapply(request, friendapply_id):
    """
    修改好友申请
    :param request:
    :param friendapply_id:
    :return:
    修改好友申请
    by:王健 at:2016-04-24
    增加好友变动的事件
    by:王健 at:2016-05-03
    """
    try:
        friendapply = FriendApply.objects.get(id=friendapply_id, owner=request.user, is_active=True)
        friendapply.copy_old()
        friendapply.status = 1
        created, diff = friendapply.compare_old()
        if diff:
            friend, created = Friend.objects.get_or_create(friend=friendapply.friend, owner=request.user)
            if not created:
                friend.is_active = True
            friend.save()
            friend, created = Friend.objects.get_or_create(owner=friendapply.friend, friend=request.user)
            if not created:
                friend.is_active = True
            friend.save()
            im_friend_commend("pass_friendapply", friendapply.owner_id, friendapply.friend_id, friendapply.toJSON())
            return get_result(True, u'好友申请处理成功', friendapply)
        else:
            return get_result(False, u'已经处理过的申请,不能再次处理', friendapply)
    except FriendApply.DoesNotExist:
        return get_result(False, u'好友申请,不是发给您的,您无权处理')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:31,代码来源:views_friend.py


示例18: test

 def test(request, *args, **kwargs):
     if not request.user.is_anonymous():
         if request.user.is_active:
             return func(request, *args, **kwargs)
         else:
             return get_result(False, u'用户已被禁用。', None, 5)
     else:
         return get_result(False, u'请先登录', None, 1)
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:8,代码来源:loginrequired.py


示例19: get_userinfo

def get_userinfo(request, user_id):
    """
    获取用户信息
    :param request:
    :return:
    获取用户信息
    by:范俊伟 at:2016-04-30
    """
    try:
        user = LYUser.objects.get(id=user_id)
    except:
        return get_result(False, '', '不存在此用户')
    return get_result(True, u'', user.toJSON())
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:13,代码来源:views.py


示例20: get_appinfo

def get_appinfo(request, appinfo_id):
    """
    查询应用信息
    :param appinfo_id:
    :param request:
    :return:
    查询应用信息
    by:王健 at:2016-04-21
    """
    try:
        obj = AppInfo.objects.get_serializer(pk=appinfo_id)
        return get_result(True, None, obj)
    except AppInfo.DoesNotExist:
        return get_result(False, u'应用不存在')
开发者ID:BPC-LIYU,项目名称:LiYuOA,代码行数:14,代码来源:views_develop.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap