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

Python jsonresult.getResult函数代码示例

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

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



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

示例1: del_gysaddress_by_id

def del_gysaddress_by_id(request, project_id):
    """
    删除供应商地址
    by:尚宗凯 at:2015-3-26
    删除项目应用节点最新数据时间
    by:尚宗凯 at:2015-05-20
    修复一个bug
    by:尚宗凯 at:2015-05-20
    删除时间改为30日之内
    by:尚宗凯 at:2015-05-27
    """
    # flag = request.REQUEST.get('flag')
    id = request.REQUEST.get('id')
    if id:
        ghsform = GYSAddressForm(request.POST, instance=GYSAddress.objects.get(pk=id))
        if ghsform.instance.user.pk != request.user.pk or ghsform.instance.project_id != int(project_id):
            return getResult(False, u'不是您发布的数据,不能删除', status_code=2)
        if (ghsform.instance.create_time + datetime.timedelta(days=1)) < timezone.now():
            return getResult(False, u'超过30日的数据,不能删除', status_code=2)
        ghsform.instance.delete()
        #删除项目应用节点最新数据时间
        cache.delete(RED_DOT_PROJECT_FILE_GROUP_LAST_NEW_DATA_TIMELINE % (project_id, ghsform.instance.file_group_id))
        cache.delete(RED_DOT_PROJECT_LAST_NEW_DATA_TIMELINE % project_id)
        return getResult(True, u'删除供应商记录成功', id)
    else:
        return getResult(False, u'参数不正确')
开发者ID:appleface2050,项目名称:ESNS,代码行数:26,代码来源:views_wzgl.py


示例2: del_log_by_id

def del_log_by_id(request, project_id=None):
    """
    不超过24小时的日志,可以由发布者 删除
    by:王健 at:2015-2-10
    清除最新数据事件缓存
    by:尚宗凯 at:2015-05-20
    删除时间改为30日之内
    by:尚宗凯 at:2015-05-27
    """
    pk = request.REQUEST.get('id')
    if pk:
        sg_log = SGlog.objects.get(pk=pk)
        if sg_log.project_id != int(project_id) or sg_log.user_id != request.user.pk:
            return getResult(False, u'不是您发布的数据,不能删除', status_code=2)
        if (sg_log.create_time + datetime.timedelta(days=30)) < timezone.now():
            return getResult(False, u'超过30日的数据,不能删除')
        sg_log.sg_tq_log.num -= 1
        sg_log.sg_tq_log.save()
        sg_log.is_active = False
        sg_log.create_time = timezone.now()
        sg_log.save()
        #删除项目应用节点最新数据时间
        cache.delete(RED_DOT_PROJECT_FILE_GROUP_LAST_NEW_DATA_TIMELINE % (project_id, get_file_group_id_by_flag_from_cache(project_id=project_id, flag="gong_cheng_ri_zhi")))
        cache.delete(RED_DOT_PROJECT_LAST_NEW_DATA_TIMELINE % project_id)
        return getResult(True, u'删除日志成功', pk)
    else:
        return getResult(False, u'参数不正确')
开发者ID:appleface2050,项目名称:ESNS,代码行数:27,代码来源:views_sglog.py


示例3: ding_favorite_by_id

def ding_favorite_by_id(request, company_id=''):
    """
    赞系统新闻
    by:王健 at:2015-06-18
    修复一个bug
    by:尚宗凯 at:2015-06-22
    修复栏目id错误的bug
    by:王健 at:2015-06-22
    修复dict 栏目id的bug
    by:王健 at:2015-06-23
    修复column_id
    by:王健 at:2015-06-25
    适应性优化,公司id 从None改为''
    by:王健 at:2015-06-26
    """
    news_id = request.REQUEST.get('id')
    if news_id:
        if company_id:
            news = CompanyNews.objects.get(pk=news_id).toJSON()
        else:
            news = SysNews.objects.get(pk=news_id).toJSON()
        if news:
            if company_id:
                result = favorite_news_by_id(request.user.id, company_id, news_id, news['company_column'], int(time.time()), False, news['title'], news['news_url'], news['icon_url'])
            else:
                result = favorite_news_by_id(request.user.id, company_id, news_id, news['sys_column'], int(time.time()), True, news['title'], news['news_url'], news['icon_url'])
            if result is None or (isinstance(result, dict) and result.has_key("code")):
                return getResult(False, u'操作失败,请稍后再试')
            return getResult(True, u'成功收藏了新闻 %s 。' % news['title'], result)
        return getResult(False, u'数据不存在')
    else:
        return getResult(False, u'请提供正确的参数')
开发者ID:appleface2050,项目名称:ESNS,代码行数:32,代码来源:views_replay.py


示例4: del_wuzirecord_by_id

def del_wuzirecord_by_id(request, project_id=None):
    """
    不超过24小时的日志,可以由发布者 删除
    by:王健 at:2015-2-10
    修改权限校验 函数
    by:王健 at:2015-3-5
    删除项目应用节点最新数据时间
    by:尚宗凯 at:2015-05-20
    删除时间改为30日之内
    by:尚宗凯 at:2015-05-27
    """
    pk = request.REQUEST.get('id')
    if pk:
        wuzirecord = WuZiRecord.objects.get(pk=pk)
        if wuzirecord.project_id != int(project_id) or wuzirecord.user_id != request.user.pk:
            return getResult(False, u'不是您发布的数据,不能删除', status_code=2)
        if (wuzirecord.create_time + datetime.timedelta(days=30)) < timezone.now():
            return getResult(False, u'超过30日的数据,不能删除')
        wuzirecord.record_date.num -= 1
        wuzirecord.record_date.save()
        wuzirecord.is_active = False
        wuzirecord.save()
        #删除项目应用节点最新数据时间
        cache.delete(RED_DOT_PROJECT_FILE_GROUP_LAST_NEW_DATA_TIMELINE % (project_id, wuzirecord.file_group_id))
        cache.delete(RED_DOT_PROJECT_LAST_NEW_DATA_TIMELINE % project_id)
        return getResult(True, u'删除物资记录成功', pk)
    else:
        return getResult(False, u'参数不正确')
开发者ID:appleface2050,项目名称:ESNS,代码行数:28,代码来源:views_wzgl.py


示例5: count_replay_by_news_id

def count_replay_by_news_id(request, company_id=''):
    """
    获取评论数量
    适应性优化,公司id 从None改为''
    by:王健 at:2015-06-26
    :param request:
    :param company_id:
    :return:
    """
    news_id = request.REQUEST.get('id')
    if news_id:
        if company_id:
            news = CompanyNews.objects.get(pk=news_id)
        else:
            news = SysNews.objects.get(pk=news_id)
        if news:
            if company_id:
                result = query_replay_num_by_news_id(news_id, False)
            else:
                result = query_replay_num_by_news_id(news_id, True)

            if result is None or (isinstance(result, dict) and result.has_key("code")):
                return getResult(False, u'操作失败,请稍后再试')
            return getResult(True, u'获取评论数量成功。', result)
        return getResult(False, u'数据不存在')
    else:
        return getResult(False, u'请提供正确的参数')
开发者ID:appleface2050,项目名称:ESNS,代码行数:27,代码来源:views_replay.py


示例6: query_favorite_zan_count_news_by_id

def query_favorite_zan_count_news_by_id(request, company_id=''):
    """
    查询新闻关注、赞、评论数量
    by:王健 at:2015-06-18
    查询用户是否赞过、收藏过和评论数量
    by:王健 at:2015-06-22
    增加company_id默认参数
    by:尚宗凯 at:2015-06-22
    适应性优化,公司id 从None改为''
    by:王健 at:2015-06-26
    :param request:
    :param company_id:
    :return:
    """
    news_id = request.REQUEST.get('id')
    if news_id:
        if company_id:
            news = CompanyNews.objects.get(pk=news_id)
        else:
            news = SysNews.objects.get(pk=news_id)
        if news:
            if company_id:
                result = query_news_favorite_zan(request.user.id, news_id, False)
            else:
                result = query_news_favorite_zan(request.user.id, news_id, True)

            if result is None or (isinstance(result, dict) and result.has_key("code")):
                return getResult(False, u'操作失败,请稍后再试')
            return getResult(True, u'获取评论数量成功。', result)
        return getResult(False, u'数据不存在')
    else:
        return getResult(False, u'请提供正确的参数')
开发者ID:appleface2050,项目名称:ESNS,代码行数:32,代码来源:views_replay.py


示例7: update_user_icon_url

def update_user_icon_url(request):
    """
    获取上传项目图标的url
    by:王健 at:2015-1-28
    解决用户被删除的bug
    by:王健 at:2015-2-5
    解决用户被删除的bug
    by:范俊伟 at:2015-2-9
    :param request:
    :param project_id:
    :return:
    """
    fileid = request.REQUEST.get('fileid')
    if fileid:
        fileobj = get_object_or_404(BaseFile, pk=fileid)
        fileobj.file_status = True
        fileobj.save()
        old_icon = None
        if fileobj.user.icon_url:
            old_icon = fileobj.user.icon_url
        fileobj.user.icon_url = fileobj
        fileobj.user.save()
        if old_icon:
            old_icon.delete()
        return getResult(True, u'上传成功', None)
    else:
        return getResult(False, u'没有上传文件id', None)
开发者ID:appleface2050,项目名称:ESNS,代码行数:27,代码来源:views_user.py


示例8: updateTask

def updateTask(request):
    id = request.REQUEST.get('id', '')
    title = request.REQUEST.get('title', '')
    desc = request.REQUEST.get('desc', '')
    startdate = request.REQUEST.get('startdate', '')
    enddate = request.REQUEST.get('enddate', '')

    color = request.REQUEST.get('color', '')

    warning_email = request.REQUEST.get('warning_email', '')
    warning_sms = request.REQUEST.get('warning_sms', '')
    warning_rtx = request.REQUEST.get('warning_rtx', '')
    wl = []
    if warning_email.lower() == 'true':
        wl.append('email')
    if warning_rtx.lower() == 'true':
        wl.append('rtx')
    if warning_sms.lower() == 'true':
        wl.append('sms')
    warning_time1 = request.REQUEST.get('warning_time1', '')
    warning_time2 = request.REQUEST.get('warning_time2', '')
    wtl = [warning_time1, warning_time2]


    if not title or not startdate :
        return getResult(False, u'请完善信息', None)
    if id:
        task = Task.objects.get(pk=id)
        RiLiWarning.objects.filter(warning_type__in=wl).filter(type='Task', fatherid=task.pk).delete()
    else:
        task = Task()
    task.title = title
    task.desc = desc
    with c:
        task.startdate = datetime.datetime.strptime(startdate, "%Y%m%d")
        task.enddate = datetime.datetime.strptime(enddate, "%Y%m%d")


    task.color = int(color)
    task.author = request.user
    task.warning_type = ','.join(wl)
    task.warning_time = ','.join(wtl)
    task.save()



    #
    # for wt in wl:
    #     for w in wtl:
    #         if w:
    #             rw = RiLiWarning()
    #             rw.fatherid = task.pk
    #             rw.type = 'Task'
    #             rw.warning_type = wt
    #             rw.timenum = int(w)
    #             rw.is_repeat = True
    #             rw.is_ok = True
    #             rw.save()
    # task.save()
    return getResult(True, u'保存成功', task.pk)
开发者ID:wangjian2254,项目名称:CalendarOA,代码行数:60,代码来源:view_task.py


示例9: query_replay_filerecord_by_id

def query_replay_filerecord_by_id(request, project_id=None):
    """
    查询查询记录的评论信息
    by:王健 at:2015-2-25
    去除 mongodb 影响
    by:王健 at:2015-3-8
    获取某个节点数据下的所有评论
    by:王健 at:2015-05-28
    修改错误提示语
    by:王健 at:2015-05-28
    """
    filerecord_id = request.REQUEST.get('id')
    flag = request.REQUEST.get('flag')
    if flag and filerecord_id:
        if flag in FILE_GROUP_FLAGS:
            filerecord = get_object_or_404(FileRecord, pk=filerecord_id, project_id=project_id)
        elif flag in ('zhi_liang_jian_cha', 'an_quan_wen_ming_jian_cha'):
            filerecord = get_object_or_404(EngineCheck, pk=filerecord_id, project_id=project_id)
        else:
            filerecord = None
        if filerecord:
            result = query_replay_by_filerecord_id(flag, filerecord_id, project_id)
            if result is None or (isinstance(result, dict) and result.has_key("code")):
                return getResult(False, u'操作失败,请稍后再试')
            return getResult(True, u'获取评论成功。', {'pinglun': result, 'filerecord': filerecord.toJSON()})
    else:
        return getResult(False, u'请提供正确的参数')
开发者ID:appleface2050,项目名称:ESNS,代码行数:27,代码来源:views_replay.py


示例10: delete_ding_filerecord_by_id

def delete_ding_filerecord_by_id(request, project_id=None):
    """
    对一个记录发出顶的操作
    by:王健 at:2015-2-25
    删除点赞
    by:王健 at:2015-05-28
    修改错误提示语
    by:王健 at:2015-05-28
    解决enginecheck 没有title的bug
    by:王健 at:2015-06-01
    """
    filerecord_id = request.REQUEST.get('id')
    flag = request.REQUEST.get('flag')
    if filerecord_id and flag:
        if flag in FILE_GROUP_FLAGS:
            filerecord = get_object_or_404(FileRecord, pk=filerecord_id, project_id=project_id)
            title = filerecord.title
        elif flag in ('zhi_liang_jian_cha', 'an_quan_wen_ming_jian_cha'):
            filerecord = get_object_or_404(EngineCheck, pk=filerecord_id, project_id=project_id)
            title = filerecord.desc
        else:
            filerecord = None
            title = ''

        if filerecord:
            result = delete_zan_by_filerecord(project_id, flag, filerecord_id, request.user.pk)
            if result is None or (isinstance(result, dict) and result.has_key("code")):
                return getResult(False, u'操作失败,请稍后再试')
            return getResult(True, u'成功 %s 取消了赞。' % title, result)
        return getResult(False, u'数据不存在')
    else:
        return getResult(False, u'请提供正确的参数')
开发者ID:appleface2050,项目名称:ESNS,代码行数:32,代码来源:views_replay.py


示例11: process_exception

 def process_exception(self, request,e):
     import time
     errorid = time.time()
     log=logging.getLogger()
     s = [u'错误码:%s'%errorid]
     s.append(u'%s:%s'%(request.method,request.path))
     user = getattr(request, 'user', None)
     if user.username:
         s.append(u'用户:%s'%user.username)
     else:
         s.append(u'未登录用户')
     s.append(u'出现以下错误:')
     etype, value, tb = sys.exc_info()
     s.append(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.error('\n    '.join(s))
         return getResult(False,u'服务器端错误,请联系管理员,错误标记码:%s'%errorid)
     else:
         m = '\n    '.join(s)
         log.error(m)
         return getResult(False,u'服务器端错误,错误如下:\n%s'%(m))
开发者ID:wangjian2254,项目名称:CalendarOA,代码行数:30,代码来源:error_middle.py


示例12: updateSubject

def updateSubject(request):
    pk = request.REQUEST.get('id', '')
    if pk:
        kindForm = SubjectForm(request.POST, instance = Subject.objects.get(pk=pk))
    else:
        kindForm = SubjectForm(request.POST)

    if not kindForm.is_valid():
        msg = kindForm.json_error()
        return getResult(False,msg,None)
    if not kindForm.instance.accuracy:
        kindForm.instance.accuracy=0.0
    kind = kindForm.save()
    for i in range(20):
        id = request.REQUEST.get("option_id_%s"%i,None)
        content = request.REQUEST.get("option_content_%s"%i,None)
        is_right = request.REQUEST.get("option_is_right_%s"%i,None)
        if id or content or is_right:
            if is_right=='true':
                is_right=True
            else:
                is_right = False
            if id:
                option = Option.objects.get(pk=id)
            else:
                option = Option()
            option.content = content
            option.is_right = is_right
            option.subject = kind
            option.save()


    return getResult(True,u'保存试题信息成功', kind.pk)
开发者ID:wangjian2254,项目名称:CalendarOA,代码行数:33,代码来源:view_subject.py


示例13: getMessageByUser

def getMessageByUser(request):
    '''
    type 为信息查询条件 all 为按时间倒序,n条; read 为按时间倒序,已读的 n条;unread 为按时间倒序 未读的n条
    '''
    user = request.user
    type = request.REQUEST.get('type', 'all')
    limit = int(request.REQUEST.get('limit', '30'))
    start = int(request.REQUEST.get('start', '0'))

    messagequery = ReceiveMessage.objects.filter(user=user).order_by('-id')
    if type == 'unread':
        messagequery = messagequery.filter(is_read=False)
    elif type == 'read':
        messagequery = messagequery.filter(is_read=True)
    elif type == 'saved':
        messagequery = OAMessage.objects.filter(flag=True,f=request.user).order_by('-id')
        resultlist = []
        for m in messagequery:

            s = {'id': m.pk,'rid':m.pk, 'title': m.title, 'mfid': m.fatherMessage_id, 'authorname':m.f.first_name, 'author':m.f.username,
                  'datetime': m.createtime.strftime("%Y/%m/%d %H:%M"),'flag':m.flag,'desc':m.desc}
            s['to'] = [{'username': u.username, 'nickname': u.first_name} for u in m.t.all()]
            resultlist.append(s)
        return getResult(True, u'获取信息成功', {'limit': limit, 'start': start, 'total': 0, 'list': resultlist})

    totalnum = messagequery.count()
    resultlist = []
    messageids=[]
    msgread={}
    for m in messagequery[start:limit]:

        s = {'id': m.message_id,'rid':m.pk, 'title': m.message.title, 'mfid': m.message.fatherMessage_id, 'authorname':m.message.f.first_name, 'author':m.message.f.username,
             'is_read': m.is_read, 'datetime': m.message.createtime.strftime("%Y/%m/%d %H:%M")}
        resultlist.append(s)
    return getResult(True, u'获取信息成功', {'limit': limit, 'start': start, 'total': totalnum, 'list': resultlist})
开发者ID:wangjian2254,项目名称:CalendarOA,代码行数:35,代码来源:view_message.py


示例14: joinGroup

def joinGroup(request):
    id = request.REQUEST.get('id','')
    username = request.REQUEST.get('username','')
    do = request.REQUEST.get('do','')
    usertype = request.REQUEST.get('type','join')
    if id:
        group = Group.objects.get(pk=id)
        if do =='join':
            if usertype=='join' and  username!=group.author.username and 0==group.users.filter(username=username).count():
                group.users.add(User.objects.get(username=username))
                group.observers.remove(User.objects.get(username=username))
                group.save()
            if usertype=='observer' and  username!=group.author.username and 0==group.observers.filter(username=username).count():
                group.observers.add(User.objects.get(username=username))
                group.users.remove(User.objects.get(username=username))
                group.save()
        elif do == 'out':
            if username!=group.author.username and (1==group.users.filter(username=username).count() or 1==group.observers.filter(username=username).count()):
                group.users.remove(User.objects.get(username=username))
                group.observers.remove(User.objects.get(username=username))
                group.save()
        else:
            return getResult(False,u'操作不正确',id)
        return getResult(True,u'完成操作',id)
    else:
        return getResult(False,u'操作不正确',id)
开发者ID:wangjian2254,项目名称:CalendarOA,代码行数:26,代码来源:view_group.py


示例15: submit_user_tel

def submit_user_tel(request):
    """
    提交手机号
    by:王健 at:2015-1-15
    提交手机号,只需要登录过,不需要已经有手机号,排除登陆者自己的手机号
    by:王健 at:2015-1-16
    改下提示内容
    by:尚宗凯 at:2015-05-12
    短信验证码使用后从session中删除
    by: 范俊伟 at:2015-07-01
    """
    user = request.user
    code = request.REQUEST.get('code', '')
    tel = request.REQUEST.get('tel', '')
    smsdebug = request.REQUEST.get('smsdebug', '')
    if not smsdebug and code != request.session.get('smscode', '1234'):
        return getResult(False, u'手机验证码不对,请重新输入。', None)
    if not smsdebug and tel != request.session.get('smstel', ''):
        return getResult(False, u'发送验证码的手机号,和注册的手机号不符合。请重新输入', None)
    user.tel = tel
    if get_user_model().objects.filter(tel=user.tel).exclude(id=user.id).exists():
        return getResult(False, u'手机号已经存在。请更换手机号', None)
    name = request.REQUEST.get('name', u'游客')
    if name:
        user.name = name
    user.save()
    request.session['smscode'] = None
    return getResult(True, u'验证手机号成功', None)
开发者ID:appleface2050,项目名称:ESNS,代码行数:28,代码来源:views_user.py


示例16: query_app_list

def query_app_list(request, project_id=None):
    """
    根据缓存的json串,输出
    by:王健 at:2015-1-11
    组装成带有包含关系的json数据
    by:王健 at:2015-1-12
    组装成不带有包含关系的json数据,填充上project、timeline字段
    by:王健 at:2015-1-13
    修改Model名字,去除下划线
    by:王健 at:2015-1-13
    修改为网络图
    by:王健 at:2015-2-12
    优化URL参数 timeline 0 和空 一致
    by:王健 at:2015-2-26
    修改权限校验 函数
    by:王健 at:2015-3-5
    """
    timeline = int(request.REQUEST.get('timeline', '0'))
    if timeline:
        if FileGroupJSON.objects.filter(project_id=project_id, timeline=timeline).exists():
            return getResult(True, u'已经是最新的数据了')

    fgroupjson, create = FileGroupJSON.objects.get_or_create(project_id=project_id)
    if create:
        fgroupjson.timeline = int(time.time())
        filegroup = FileGroup.objects.filter(Q(project_id=project_id) | Q(project_id=None)).order_by('sorted')
        jsongroup = MyEncoder.default(filegroup)
        for g in jsongroup:
            if not g['project'] or not g['icon_url']:
                g['icon_url'] = 'http://needserver.duapp.com/static/icon/%s' % g['icon']
            g['project']=int(project_id)
            g['timeline'] = fgroupjson.timeline
        fgroupjson.jsontext = json.dumps(jsongroup)
        fgroupjson.save()
    return getResult(True, None, json.loads(fgroupjson.jsontext))
开发者ID:appleface2050,项目名称:ESNS,代码行数:35,代码来源:views_app.py


示例17: get_userinfo

def get_userinfo(request, project_id):
    """
    根据id获取用户基础信息
    by:王健 at:2015-1-16
    修改个人信息返回值
    by:王健 at:2015-1-20
    修复id值不对的bug
    by:王健 at:2015-2-17
    查询视图替代查询表
    by:尚宗凯 at:2015-3-6
    查询表替代视图
    by:尚宗凯 at:2015-3-8
    :param request:
    :return:
    """
    userid = request.REQUEST.get('user_id')
    if Person.objects.filter(user_id=userid, project_id=project_id).exists():
        person = Person.objects.get(user_id=userid, project_id=project_id)
        user = person.user
        p = user.get_user_map()
        if hasattr(user, 'userinfo') and user.userinfo:
            p.update(MyEncoder.default(user.userinfo))
        p['id'] = user.pk
        return getResult(True, '', p)
    else:
        return getResult(False, u'不是项目组内成员')
开发者ID:appleface2050,项目名称:ESNS,代码行数:26,代码来源:views_user.py


示例18: query_replay_news_by_id

def query_replay_news_by_id(request, company_id=''):
    """
    查询查询记录的评论信息
    by:王健 at:2015-2-25
    去除 mongodb 影响
    by:王健 at:2015-3-8
    获取某个节点数据下的所有评论
    by:王健 at:2015-05-28
    修改错误提示语
    by:王健 at:2015-05-28
    添加分页属性
    by:王健 at:2015-06-24
    适应性优化,公司id 从None改为''
    by:王健 at:2015-06-26
    """
    news_id = request.REQUEST.get('id')
    start = int(request.REQUEST.get('start', 0))
    if news_id:
        if company_id:
            news = CompanyNews.objects.get(pk=news_id)
        else:
            news = SysNews.objects.get(pk=news_id)
        if news:
            if company_id:
                result = query_replay_by_news_id(news_id, False, start)
            else:
                result = query_replay_by_news_id(news_id, True, start)

            if result is None or (isinstance(result, dict) and result.has_key("code")):
                return getResult(False, u'操作失败,请稍后再试')
            return getResult(True, u'获取评论成功。', result)
        return getResult(False, u'数据不存在')
    else:
        return getResult(False, u'请提供正确的参数')
开发者ID:appleface2050,项目名称:ESNS,代码行数:34,代码来源:views_replay.py


示例19: query_person

def query_person(request, project_id=None):
    """
    获取所有联系人
    by:王健 at:2015-1-16
    优化URL参数 timeline 0 和空 一致
    by:王健 at:2015-2-26
    使用缓存
    by:王健 at:2015-3-9
    针对示例项目优化,获取成员接口
    by:王健 at:2015-3-25
    优化缓存结果的非空判断
    by:王健 at:2015-05-21
    """
    timeline = int(request.REQUEST.get('timeline', '0'))
    if not timeline:
        l = cache.get(PROJECT_PERSON_LIST % project_id)
        if l is None:
            l = Person.objects.filter(project_id=project_id).order_by('-timeline')
        else:
            if int(project_id) == settings.SHOW_PROJECT_ID:
                l.append(person_show_project_2_dict(request.user))
            return getResult(True, None, l)
    else:
        l = Person.objects.filter(project_id=project_id, timeline__gt=int(timeline)).order_by('timeline')
    ul = []
    for person in l:
        ul.append(person_2_dict(person))

    if not timeline:
        cache.set(PROJECT_PERSON_LIST % project_id, ul, settings.CACHES_TIMEOUT)
        if int(project_id) == settings.SHOW_PROJECT_ID:
                ul.append(person_show_project_2_dict(request.user))
    return getResult(True, None, ul)
开发者ID:appleface2050,项目名称:ESNS,代码行数:33,代码来源:views_user.py


示例20: ding_news_by_id

def ding_news_by_id(request, company_id=''):
    """
    赞系统新闻
    by:王健 at:2015-06-18
    增加赞数量+1
    by:尚宗凯 at:2015-06-22
    修复栏目id错误的bug
    by:王健 at:2015-06-22
    适应性优化,公司id 从None改为''
    by:王健 at:2015-06-26
    """
    news_id = request.REQUEST.get('id')
    if news_id:
        if company_id:
            news = CompanyNews.objects.get(pk=news_id)
        else:
            news = SysNews.objects.get(pk=news_id)
        if news:
            if company_id:
                result = zan_news_by_id(request.user.id, company_id, news_id, news.company_column_id, int(time.time()), False)
            else:
                result = zan_news_by_id(request.user.id, company_id, news_id, news.sys_column_id, int(time.time()), True)
            news.add_zan_num()
            if result is None or (isinstance(result, dict) and result.has_key("code")):
                return getResult(False, u'操作失败,请稍后再试')
            return getResult(True, u'成功对 %s 点了个赞。' % news.title, result)
        return getResult(False, u'数据不存在')
    else:
        return getResult(False, u'请提供正确的参数')
开发者ID:appleface2050,项目名称:ESNS,代码行数:29,代码来源:views_replay.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python jsonresult.get_result函数代码示例发布时间:2022-05-26
下一篇:
Python json.loads函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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