Exemple #1
0
def controlView(request):
    expert_review_forms = []
    expert_final_review_forms = []
    schedule_form = ScheduleBaseForm(request=request)
    specials = getSpecial(request)
    for special in specials:
        expert_review_form = ExpertReviewForm(instance=special)
        expert_review_forms.append(expert_review_form)

        expert_final_review_forms.append(
            ExpertFinalReviewForm(instance=special))

        control_types = []
        for t in CONTROL_TYPE_CHOICES:
            t = list(t)
            t.append(getattr(special, t[0] + "_status"))
            control_types.append(t)
        special.control_types = control_types

    # spec_list = zip(specials,expert_review_forms)
    spec_list = zip(specials, expert_review_forms, expert_final_review_forms)
    context = {
        'spec_list': spec_list,
        'alloc_excel': TYPE_ALLOC[0],
        'final_alloc_excel': TYPE_FINAL_ALLOC[0],
        'schedule_form': schedule_form,
    }
    return render(request, "school/control.html", context)
def get_project_list(request):
    identity = request.session.get('auth_role', "")
    if identity == ADMINSTAFF_USER:
        pro_list = ProjectSingle.objects.all()
    elif identity == SCHOOL_USER:
        specials = getSpecial(request)
        try:
            qset = reduce(
                lambda x, y: x | y,
                [Q(project_special=_special) for _special in specials])
            pro_list = ProjectSingle.objects.filter(qset).order_by(
                "project_code")
        except:
            pro_list = ProjectSingle.objects.none()
    elif identity == COLLEGE_USER:
        try:
            colleges = getCollege(request)
            qset = reduce(
                lambda x, y: x | y,
                [Q(teacher__college=_college) for _college in colleges])
            pro_list = ProjectSingle.objects.filter(qset)
        except:
            pro_list = ProjectSingle.objects.none()
    elif identity == TEACHER_USER:
        pro_list = ProjectSingle.objects.filter(teacher__userid=request.user)
    elif identity == EXPERT_USER:
        pro_list = ProjectSingle.objects.all()
    else:
        pro_list = ProjectSingle.objects.all()
    return pro_list
def get_project_list(request):
    identity = request.session.get('auth_role', "")
    if identity == ADMINSTAFF_USER:
        pro_list = ProjectSingle.objects.all()
    elif identity == SCHOOL_USER:
        specials = getSpecial(request)
        try:
            qset = reduce(lambda x,y:x|y,[Q(project_special = _special) for _special in specials])
            pro_list = ProjectSingle.objects.filter(qset).order_by("project_code")
        except:
            pro_list = ProjectSingle.objects.none()
    elif identity == COLLEGE_USER:
        try:
            colleges = getCollege(request)
            qset = reduce(lambda x,y:x|y,[Q(teacher__college = _college) for _college in colleges])
            pro_list = ProjectSingle.objects.filter(qset)
        except:
            pro_list = ProjectSingle.objects.none()
    elif identity == TEACHER_USER:
        pro_list = ProjectSingle.objects.filter(teacher__userid = request.user)
    elif identity == EXPERT_USER:
        pro_list = ProjectSingle.objects.all()
    else:
        pro_list = ProjectSingle.objects.all()
    return pro_list
def controlView(request):
    expert_review_forms=[]
    expert_final_review_forms = []
    schedule_form=ScheduleBaseForm(request=request)
    specials =  getSpecial(request)
    for special in specials:
        expert_review_form = ExpertReviewForm(instance=special)
        expert_review_forms.append(expert_review_form)

        expert_final_review_forms.append(  ExpertFinalReviewForm(instance = special))

        control_types = []
        for t in CONTROL_TYPE_CHOICES:
            t = list(t)
            t.append(getattr(special,t[0]+"_status"))
            control_types.append(t)
        special.control_types = control_types

    # spec_list = zip(specials,expert_review_forms)
    spec_list = zip(specials,expert_review_forms, expert_final_review_forms)
    context = {
        'spec_list' :spec_list,
        'alloc_excel':TYPE_ALLOC[0],
        'final_alloc_excel':TYPE_FINAL_ALLOC[0],
        'schedule_form':schedule_form,
    }
    return render(request, "school/control.html", context);
def getSpecialTypeGroup(request):
    special_list = getSpecial(request)
    special_choice_list=[]
    special_choice_list.append((-1,"专题类型"))
    for s in special_list:
        special_choice_list.append((s.id, s.name))
    special_choice_list = tuple(special_choice_list)
    return special_choice_list
def getSpecialTypeGroup(request):
    special_list = getSpecial(request)
    special_choice_list=[]
    special_choice_list.append((-1,"专题类型"))
    for s in special_list:
        special_choice_list.append((s.id, s.name))
    special_choice_list = tuple(special_choice_list)
    return special_choice_list
def ChangeControlStatus(request,special_id,type_id,type_name):
    special = getSpecial(request).get(id = special_id)
    if special:
        type=(type_id,type_name)
        loginfo(type_id)
        if type in CONTROL_TYPE_CHOICES or type_id=="review":
            bValue = not getattr(special,type_id+"_status")
            setattr(special,type_id+"_status",bValue)
            special.save()
        return simplejson.dumps({'status':'1','type_id':type_id,'type_name':type_name,'value':bValue})
    return simplejson.dumps({'status':'0'})
    def __init__(self, *args, **kwargs):
        request = kwargs.pop("request", None)
        super(NoticeForm, self).__init__(*args, **kwargs)
        special_list = getSpecial(request)
        special_choice_list = []
        special_choice_list.append((-1, "专题类型"))
        for s in special_list:
            special_choice_list.append((s.id, s.name))
        special_choice = tuple(special_choice_list)

        self.fields["expert_special_select"].choices = getSpecialTypeGroup(
            request)
        self.fields["teacher_special_select"].choices = getSpecialTypeGroup(
            request)
        self.fields["teacher_year_select"].choices = getTeacherYearGroup(
            request)
        if request == None: return
        if SchoolProfile.objects.filter(userid=request.user).count() > 0:
            college_list_choice = []
            college_list_all = CollegeProfile.objects.all()
            for item in college_list_all:
                collegename = [obj.name for obj in item.college_set.all()]
                cname = ""
                for name in collegename:
                    cname = cname + name + '  '
                collegename = item.userid.first_name + '(' + cname + ')'
                college_list_choice.append((
                    item.id,
                    collegename,
                ))
            college_list_choice = list(set(college_list_choice))
            project_group = ProjectSingle.objects.filter(
                project_special__school_user__userid=request.user)
            teacher_year_choice = []
            teacher_year_choice.extend(
                list(
                    set([(item.approval_year, item.approval_year)
                         for item in project_group])))
            teacher_year_choice = tuple(teacher_year_choice)
            teacher_special_choice = []
            teacher_special_choice.extend(
                list(
                    set([(item.project_special.id, item.project_special.name)
                         for item in project_group])))
            teacher_special_choice = tuple(teacher_special_choice)

            self.fields["college_list"].choices = college_list_choice
            self.fields["teacher_year"].choices = teacher_year_choice
            self.fields["expert_year"].choices = teacher_year_choice
            self.fields["teacher_special"].choices = teacher_special_choice
            self.fields["expert_special"].choices = teacher_special_choice
def ChangeExpertReview(request,form,special_id):
    special = getSpecial(request).get(id = special_id)
    if special:
        loginfo(special)
        expert_form = ExpertReviewForm(deserialize_form(form),instance=special)
        if expert_form.is_valid():
            qset1=Q(project_status__status__gte = PROJECT_STATUS_APPLICATION_EXPERT_SUBJECT,project_status__status__lte = PROJECT_STATUS_APPROVAL)
            qset2=Q(project_status__status__gte = PROJECT_STATUS_FINAL_EXPERT_SUBJECT,project_status__status__lt = PROJECT_STATUS_OVER)
            prolist = ProjectSingle.objects.filter(Q(project_special=special) & (qset1 | qset2))
            loginfo(prolist)
            if prolist.count()==0:
                expert_form.save()
                loginfo("success")
                return simplejson.dumps({'status':'1'})
            else:
                return simplejson.dumps({'status':'2'})
    return simplejson.dumps({'status':'0'})
def ExpertinfoExport(request,special_id,eid,form):
    special = getSpecial(request).get(id = special_id)
    if special:
        if eid==TYPE_ALLOC[0]:
            schedule_form = ScheduleBaseForm(deserialize_form(form))
            proj_set =get_search_data(request,schedule_form)
            # proj_set = ProjectSingle.objects.filter(Q(project_special=special) & Q(project_status__status = PROJECT_STATUS_APPLICATION_EXPERT_SUBJECT))
            loginfo(len(proj_set))
        elif eid == TYPE_FINAL_ALLOC[0]:
            proj_set = ProjectSingle.objects.filter(Q(project_special=special) & Q(project_status__status = PROJECT_STATUS_FINAL_EXPERT_SUBJECT))
        loginfo(proj_set.count())
        if eid==TYPE_ALLOC[0]:
            path = get_xls_path(request,special.expert_review.category,proj_set,special.name,eid)
        elif eid == TYPE_FINAL_ALLOC[0]:
            path = get_xls_path(request,special.expert_final_review.category,proj_set,special.name,eid)
        ret = {'path':path}
        return simplejson.dumps(ret)
    return simplejson.dumps({'status':'0'})
Exemple #11
0
    def __init__(self, *args, **kwargs):
        request = kwargs.pop("request",None)
        super(NoticeForm,self).__init__(*args,**kwargs)
        special_list = getSpecial(request)
        special_choice_list=[]
        special_choice_list.append((-1,"专题类型"))
        for s in special_list:
            special_choice_list.append((s.id, s.name))
        special_choice = tuple(special_choice_list)

        self.fields["expert_special_select"].choices = getSpecialTypeGroup(request)
        self.fields["teacher_special_select"].choices = getSpecialTypeGroup(request)
        self.fields["teacher_year_select"].choices = getTeacherYearGroup(request)
        if request == None:return
        if SchoolProfile.objects.filter(userid=request.user).count()>0:
            college_list_choice=[]
            college_list_all = CollegeProfile.objects.all()
            for item in college_list_all:
                collegename = [obj.name for obj in item.college_set.all()]
                cname = ""
                for name in collegename:
                    cname=cname+name+'  '
                collegename = item.userid.first_name+'('+cname+')'
                college_list_choice.append((item.id,collegename,))
            college_list_choice=list(set(college_list_choice))
            project_group=ProjectSingle.objects.filter(project_special__school_user__userid=request.user)
            teacher_year_choice=[]
            teacher_year_choice.extend(list(set([ (item.approval_year,item.approval_year) for item in project_group])))
            teacher_year_choice=tuple(teacher_year_choice)
            teacher_special_choice=[]
            teacher_special_choice.extend(list(set([(item.project_special.id,item.project_special.name) for item in project_group])))
            teacher_special_choice=tuple(teacher_special_choice)

            self.fields["college_list"].choices=college_list_choice
            self.fields["teacher_year"].choices=teacher_year_choice
            self.fields["expert_year"].choices=teacher_year_choice
            self.fields["teacher_special"].choices=teacher_special_choice
            self.fields["expert_special"].choices=teacher_special_choice