Exemplo n.º 1
0
def struct_work(work, pov):
    from utils.file_fun import get_file_url
    from utils.file_fun import get_image_url
    from applications.common.services import area_name
    result = collections.OrderedDict()
    result['id'] = str(work.id)
    result['name'] = work.name
    result['rar_url'] = get_file_url(
        work.rar_file.url) if work.rar_file else ''
    result['img_url'] = get_image_url(
        work.img_file.url) if work.img_file else ''
    result['no'] = work.no
    result['sub_activity'] = work.sub_activity
    result['phase'] = work.phase
    result['project'] = work.project
    result['subject'] = work.subject
    result['status'] = str(work.status)
    result['authors'] = work.authors
    result['star'] = str(work.like)
    result['pv'] = str(work.pv)
    result['final_rank'] = work.ranks.name if work.ranks else ''
    result['final_score'] = str(work.final_score)
    result['preview_status'] = str(work.preview_status)
    result['area_is_direct'] = str(work.area.manage_direct)
    result['area_id'] = str(work.area.id)
    result['area_name_full'] = area_name(work.area.id, pov=pov)
    result['area_name_simple'] = area_name(work.area.id, full=False, pov=pov)
    result['is_public'] = str(work.is_public) if work.is_public else '0'
    return result
Exemplo n.º 2
0
 def score_item(rule,
                team_expert=None,
                status=FALSE_INT,
                is_final=FALSE_INT,
                ranks=[],
                score_id='',
                score='',
                rank='',
                comment=''):
     return {
         'rule':
         str(REVIEW_RULE_1),
         'score_id':
         str(score_id) if score_id else '',
         'expert_id':
         str(team_expert.expert.id) if team_expert else '',
         'team_expert_id':
         str(team_expert.id) if team_expert else '',
         'expert_name':
         str(team_expert.expert.account.name) if team_expert else '',
         'expert_area_name_full':
         area_name(team_expert.expert.area.id) if team_expert else '',
         'expert_area_name_simple':
         area_name(team_expert.expert.area.id, full=False)
         if team_expert else '',
         'status':
         str(status),
         'is_final':
         str(is_final),
         'items': [
             {
                 'name': 'score',
                 'value': str(score),
                 'desc': u'得分',
                 'type': INPUT_NUM,
                 'range_min': '1',
                 'range_max': str(rule.max_score),
                 'enum': []
             },
             {
                 'name': 'rank',
                 'value': str(rank),
                 'desc': u'等级',
                 'type': INPUT_LIST,
                 'range_min': '',
                 'range_max': '',
                 'enum': ranks
             },
             {
                 'name': 'comment',
                 'value': str(comment),
                 'desc': u'评语',
                 'type': INPUT_TEXTAREA,
                 'range_min': '',
                 'range_max': '',
                 'enum': []
             },
         ]
     }
Exemplo n.º 3
0
def area_struct(area):
    from applications.common.services import area_name
    return {
        'area_id': str(area.id),
        'area_level': str(area.area_level),
        'area_is_direct': str(area.manage_direct),
        'area_direct_level': '',
        'area_direct_base': '',
        'area_code': area.area_code,
        'area_name_full': area_name(int(area.id)),
        'area_name_simple': area_name(int(area.id), full=False),
    }
Exemplo n.º 4
0
def expert(expert):
    return {
        "expert_id": str(expert.id),
        "account_id": str(expert.account.id),
        "username": expert.account.username,
        "name": expert.name,
        "sex": expert.sex,
        "area_name_full": area_name(str(expert.area.id)),
        "area_name_simple": area_name(str(expert.area.id), full=False),
        "area_id": str(expert.area_id),
        "position": expert.position,
        "is_data_confirm": str(expert.account.is_data_confirm),
    }
Exemplo n.º 5
0
def detail_team(team):
    rule = SubJudgeRule.objects.filter(subjudge=team.subjudge, ).first()
    if not rule:
        raise BusinessException(ERR_RULE_NOT_EXIST)
    max = rule.parse_rule().expert_count()
    result = dict(judger_list=list(),
                  subjudge_team_id=str(team.id),
                  subjudge_team_name=team.name,
                  subjudge_team_work_count=str(team.work_count, ))
    experts = SubJudgeTeamExpert.objects.filter(
        subjudge_team=team).order_by('sn')
    judger_list = list()
    for i in xrange(max):
        for each in experts:
            if each.sn == i + 1:
                judger_list.append({
                    'subjudge_id':
                    str(team.subjudge.id),
                    'expert_id':
                    str(each.expert.id),
                    'expert_name':
                    each.expert.name,
                    'sn':
                    str(each.sn),
                    'is_leader':
                    str(each.is_leader),
                    'expert_position':
                    each.expert.position,
                    'expert_area_id':
                    str(each.expert.area_id),
                    'expert_area_name_full':
                    area_name(each.expert.area_id),
                })
                break
        else:
            judger_list.append({
                'subjudge_id': '',
                'expert_id': '',
                'expert_name': '',
                'sn': str(i + 1),
                'is_leader': '',
                'expert_position': '',
                'expert_area_id': '',
                'expert_area_name_full': '',
            })
    result['judger_list'] = judger_list
    return result
Exemplo n.º 6
0
def detail_team(team, max):
    experts_in_team = TeamExpert.objects.filter(
        team=team, expert__del_flag=FALSE_INT).order_by('sn')
    count = Work.objects.filter(team=team).count()
    result = {
        'team_id': str(team.id),
        'team_name': team.name,
        'team_work_count': str(count),
        'judger_max': max,
        'judger_list': list(),
    }
    expert_max = Rule.objects.filter(
        activity=team.activity).first().parse_rule().expert_count()
    for i in xrange(expert_max):
        sn = i + 1
        for et in experts_in_team:
            if et.sn == sn:
                result['judger_list'].append({
                    'expert_id':
                    str(et.expert.id),
                    'expert_name':
                    et.expert.account.name,
                    'sn':
                    str(et.sn),
                    'is_leader':
                    str(et.is_leader),
                    'expert_position':
                    et.expert.position,
                    'expert_area_id':
                    str(et.expert.area_id),
                    'expert_area_name_full':
                    area_name(et.expert.area_id),
                })
                break
        else:
            # 某位置没有专家,补一个空
            result['judger_list'].append({
                'expert_id': '',
                'expert_name': '',
                'sn': str(sn),
                'is_leader': '',
                'expert_position': '',
                'expert_area_id': '',
                'expert_area_name_full': '',
            })

    return result
Exemplo n.º 7
0
def available_add_team_expert(subjg_team, expert_in_same_team, keyword, page,
                              rows):
    expert_in_subjg = SubJudgeExpert.objects.filter(
        subjudge=subjg_team.subjudge, expert__del_flag=FALSE_INT)
    if keyword:
        expert_in_subjg = expert_in_subjg.filter(
            Q(expert__account__username__contains=keyword)
            | Q(expert__account__name__contains=keyword))
    expert_in_subjg = expert_in_subjg.values_list('expert__id', flat=True)
    expert_exist_in_other_team = SubJudgeTeamExpert.objects.filter(subjudge=subjg_team.subjudge)\
                        .exclude(subjudge_team=subjg_team).values_list('expert__id', flat=True)
    in_team_page = [int(each) for each in seq2list(expert_in_same_team)
                    ] if expert_in_same_team else list()

    result_id_list = set(expert_in_subjg) - set(
        expert_exist_in_other_team) - set(in_team_page)
    qs = Expert.objects.filter(id__in=result_id_list, del_flag=FALSE_INT)
    paged_data, result = paging_by_page(qs, rows, page)
    for each in qs:
        result['items'].append({
            'subjudge_id':
            str(subjg_team.subjudge.id),
            'expert_id':
            str(each.id),
            'expert_name':
            each.account.name,
            'expert_mobile':
            each.account.username,
            'expert_position':
            each.position,
            'expert_area_id':
            str(each.area.id) if each.area else '',
            'expert_area_name_full':
            area_name(each.area.id) if each.area else '',
        })
    return result
Exemplo n.º 8
0
def available_add_expert_in_team(account, team, expert_in_same_team, keyword,
                                 page, rows):
    # # load expert from expert_lib
    # from applications.expert.services import list_expert_user
    # expert_in_lib = [each['id'] for each in list_expert_user(account, user.id, None, None, None)]

    expert_in_acti = ExpertActivity.objects.filter(activity=team.activity,
                                                   expert__del_flag=FALSE_INT)
    if keyword:
        expert_in_acti = expert_in_acti.filter(
            Q(expert__account__username__contains=keyword)
            | Q(expert__account__name__contains=keyword))
    expert_in_acti = expert_in_acti.values_list('expert__id', flat=True)
    expert_exist_in_team = TeamExpert.objects.filter(
        team__activity=team.activity).exclude(team=team).values_list(
            'expert__id', flat=True)
    result_id_list = set(expert_in_acti) - set(expert_exist_in_team) - set(
        expert_in_same_team)
    qs = Expert.objects.filter(id__in=result_id_list, del_flag=FALSE_INT)
    paged_data, result = paging_by_page(qs, rows, page)
    for each in qs:
        result['items'].append({
            'expert_id':
            str(each.id),
            'expert_name':
            each.account.name,
            'expert_mobile':
            each.account.username,
            'expert_position':
            each.position,
            'expert_area_id':
            str(each.area.id) if each.area else '',
            'expert_area_name_full':
            area_name(each.area.id) if each.area else '',
        })
    return result
Exemplo n.º 9
0
 def score_item(rule,
                subjudge_team_expert,
                status=FALSE_INT,
                is_final=FALSE_INT,
                ranks=[],
                score_id='',
                score='',
                rank='',
                comment=''):
     result = {
         'rule':
         str(REVIEW_RULE_2),
         'score_id':
         str(score_id),
         'expert_id':
         str(subjudge_team_expert.expert.id) if subjudge_team_expert
         and subjudge_team_expert.expert else '',
         'subjudge_team_expert_id':
         str(subjudge_team_expert.id) if subjudge_team_expert else '',
         'expert_name':
         subjudge_team_expert.expert.account.name if
         subjudge_team_expert and subjudge_team_expert.expert else '',
         'expert_area_name_full':
         area_name(subjudge_team_expert.expert.area.id) if
         subjudge_team_expert and subjudge_team_expert.expert else '',
         'expert_area_name_simple':
         area_name(subjudge_team_expert.expert.area.id, full=False) if
         subjudge_team_expert and subjudge_team_expert.expert else '',
         'status':
         str(status),
         'is_final':
         str(is_final),
         'items': [
             {
                 'name': 'score',
                 'value': str(score),
                 'desc': u'得分',
                 'type': INPUT_NUM,
                 'range_min': '1',
                 'range_max': str(rule.max_score),
                 'enum': []
             },
             {
                 'name': 'comment',
                 'value': str(comment),
                 'desc': u'评语',
                 'type': INPUT_TEXTAREA,
                 'range_min': '',
                 'range_max': '',
                 'enum': []
             },
         ]
     }
     if is_final == TRUE_INT:
         result['items'].insert(
             1, {
                 'name': 'rank',
                 'value': str(rank),
                 'desc': u'等级',
                 'type': INPUT_LIST,
                 'range_min': '',
                 'range_max': '',
                 'enum': ranks
             })
     return result