Example #1
0
def index(request):
    '''
    for index_new
    '''
    news_announcement = News.objects.filter(
        news_category__category=NEWS_CATEGORY_ANNOUNCEMENT).order_by(
            '-news_date')
    # news_policy = News.objects.filter(news_category__category=NEWS_CATEGORY_POLICY).order_by('-news_date')
    news_dynamic = News.objects.filter(
        news_category__category=NEWS_CATEGORY_DYNAMIC).order_by('-news_date')
    news_outstanding = News.objects.filter(
        news_category__category=NEWS_CATEGORY_OUTSTANDING).order_by(
            '-news_date')
    news_others = News.objects.filter(
        news_category__category=NEWS_CATEGORY_OTHERS).order_by('-news_date')
    context = getContext(news_announcement,
                         1,
                         "news_announcement",
                         page_elems=8)
    # context.update(getContext(news_policy, 1, "news_policy", page_elems=8))
    context.update(getContext(news_dynamic, 1, "news_dynamic", page_elems=8))
    context.update(
        getContext(news_outstanding, 1, "news_outstanding", page_elems=8))
    context.update(getContext(news_others, 1, "news_others", page_elems=8))
    return context
Example #2
0
def getUserListPagination(request, page, user):
    page = int(page)
    html = ""
    if user == "college":
        user_list = getCollegeListForHtml()
        context = getContext(user_list, page, "item2", 0)
        html = render_to_string(
            "widgets/notice_message_setting_select_college_table.html",
            context)
    elif user == "teacher":
        user_list = cnt_teacher_list
        context = getContext(user_list, page, "item3", 0)
        html = render_to_string(
            "widgets/notice_message_setting_select_teacher_table.html",
            context)
    else:
        user_list = cnt_expert_list
        context = getContext(user_list, page, "item4", 0)
        html = render_to_string(
            "widgets/notice_message_setting_select_expert_table.html", context)

    return simplejson.dumps({
        "status": 1,
        "html": html,
    })
def getParam(pro_list, userauth, flag, page, page2):
    (pending_q, default_q, search_q) = get_qset(userauth)
    not_pass_apply_project_group = pro_list.filter(pending_q)
    if flag:
        pass_apply_project_group = pro_list.filter(default_q)
    else:
        pass_apply_project_group = pro_list.filter(search_q)
    if userauth['role'] == FINANCE_USER:
        if userauth['status'] == "budget":
            pass_apply_project_group = pass_apply_project_group.order_by(
                'projectfundbudget__serial_number')
        else:
            pass_apply_project_group = pass_apply_project_group.order_by(
                'projectfundsummary__serial_number')
    pass_apply_project_group = addURL(pass_apply_project_group)
    not_pass_apply_project_group = addURL(not_pass_apply_project_group)
    param = {}
    param.update(
        getContext(pass_apply_project_group, page2, "item2", 0, page_elems=10))
    param.update(
        getContext(not_pass_apply_project_group,
                   page,
                   "item",
                   0,
                   page_elems=10))
    param.update({"pro_count": len(pass_apply_project_group)})
    return param
Example #4
0
def refresh_user_table(request,identity,search_form="",page=1):
    try:
        form = SearchForm(deserialize_form(search_form))
        if form.is_valid():
            name = form.cleaned_data['name']
    except:
        name = ""

    if identity == SCHOOL_USER:
        school_users = SchoolProfile.objects.filter(Q(userid__first_name__contains = name))
        context=getContext(school_users, page, "item")
        return render_to_string("widgets/dispatch/school_user_table.html",
                                context)
    elif identity == COLLEGE_USER:
        college_users = CollegeProfile.objects.filter(Q(userid__first_name__contains = name))
        context=getContext(college_users, page, "item2")
        return render_to_string("widgets/dispatch/college_user_table.html",
                                context)
    elif identity == TEACHER_USER:
         colleges = getCollege(request)
         qset = reduce(lambda x,y:x|y,[Q(college = _college) for _college in colleges])
         users = TeacherProfile.objects.filter(qset).filter(Q(userid__first_name__contains = name)).order_by('college')
         context=getContext(users, page, "item")
         return render_to_string("widgets/dispatch/teacher_user_table.html",
                                context)
    elif identity == EXPERT_USER:
        users = ExpertProfile.objects.filter(Q(userid__first_name__contains = name)).order_by('college')
        context=getContext(users, page, "item3")
        return render_to_string("widgets/dispatch/expert_user_table.html",
                                context)
def getPagination(request, special, college, page, is_first_round):
    message = ""
    expert = ExpertProfile.objects.get(userid = request.user)
    page = int(page)
    re_list = Re_Project_Expert.objects.filter(Q(expert = expert) & Q(is_first_round = is_first_round))
    if special != "-1": 
        re_list = re_list.filter(project__project_special = special)
    if college != "-1":
        re_list = re_list.filter(project__teacher__college = college)

    re_list = list(re_list)
    for re_obj in re_list:
        if is_first_round:
            re_obj.score = getScoreTable(re_obj.project).objects.get_or_create(re_obj = re_obj)[0].get_total_score()
        else:
            re_obj.score = getFinalScoreTable(re_obj.project).objects.get_or_create(re_obj = re_obj)[0].get_total_score()
    re_list.sort(key = lambda x: x.score)
    if is_first_round:
        context = getContext(re_list, page, "item", 0)
        html = render_to_string("expert/widgets/first_round_project_table.html", context)
        message = "first round"
    else:
        context = getContext(re_list, page, "item2", 0)
        html = render_to_string("expert/widgets/second_round_project_table.html", context)
        message = "second round"
    return simplejson.dumps({"message": message, "html": html, })
Example #6
0
def noticeMessageSettingBase(request,userauth):
    notice_choice=NOTICE_CHOICE
    template_notice_message=TemplateNoticeMessage.objects.all()
    template_notice_message_form = TemplateNoticeMessageForm()
    template_notice_message_group=[]
    cnt=1
    for item in template_notice_message:
        nv={
            "id":item.id,
            "iid":cnt,
            "title":item.title,
            "message":item.message,
        }
        cnt+=1
        template_notice_message_group.append(nv)



    


    notice_form=NoticeForm(request=request)
    context=getContext(template_notice_message_group,1,"item",0)
    context.update({
        "template_notice_message_form":template_notice_message_form,
        "notice_choice":notice_choice,
        "notice_form":notice_form,
        "userauth":userauth,
        # "college_list":college_list_choice,
        
    })
    context.update(getContext(getCollegeListForHtml(), 1, "item2", 0))

    return render(request, userauth['role'] + "/notice_message_setting.html", context)
Example #7
0
def allocView(request):
    expert_list = ExpertProfile.objects.all()
    unalloc_project_list = get_project_list(request).filter(
        project_status__status=PROJECT_STATUS_APPLICATION_SCHOOL_OVER)
    alloc_project_list = get_project_list(request).filter(
        project_status__status=PROJECT_STATUS_APPLICATION_EXPERT_SUBJECT)
    form = FilterForm(request=request)
    expert_form = FilterForm()

    context = {
        "form": form,
        "expert_form": expert_form,
        "page_info": "alloc",
    }
    context.update(getContext(unalloc_project_list, 1, "item", 0))
    context.update(getContext(alloc_project_list, 1, "item2", 0))
    context.update(getContext(expert_list, 1, "item3", 0))

    for expert in context['item3_list']:
        expert.alloc_num = Re_Project_Expert.objects.filter(
            Q(expert=expert) & Q(is_first_round=True)
            & Q(project__project_status__status=
                PROJECT_STATUS_APPLICATION_EXPERT_SUBJECT)).count()

    for project in context['item2_list']:
        project.review_status = getProjectReviewStatus(project)

    return render(request, "school/alloc.html", context)
def homeView(request, is_submited=False):
    is_first_round = request.GET.get("is_first_round", "1")
    page = int(request.GET.get("page", "1"))
    page2 = int(request.GET.get("page2", "1"))
    expert = ExpertProfile.objects.get(userid = request.user)
    re_list_1 = list(Re_Project_Expert.objects.filter(Q(expert = expert) & \
                                                      Q(is_first_round = True) & \
                                                      Q(project__project_status__status = PROJECT_STATUS_APPLICATION_EXPERT_SUBJECT) & \
                                                      Q(project__project_special__alloc_status = True)))
    for re_obj in re_list_1:
        loginfo(re_obj.project)
        re_obj.score = getScoreTable(re_obj.project).objects.get_or_create(re_obj = re_obj)[0].get_total_score()
    
    re_list_2 = list(Re_Project_Expert.objects.filter(Q(expert = expert) & \
                                                      Q(is_first_round = False) & \
                                                      Q(project__project_status__status = PROJECT_STATUS_FINAL_EXPERT_SUBJECT) & \
                                                      Q(project__project_special__final_alloc_status = True)))
    for re_obj in re_list_2:
        loginfo(re_obj.project)
        re_obj.score = getFinalScoreTable(re_obj.project).objects.get_or_create(re_obj = re_obj)[0].get_total_score()
    context = {"is_first_round": is_first_round,}
    re_list_1.sort(key = lambda x: x.score)
    re_list_2.sort(key = lambda x: x.score)

    form = ScheduleBaseForm()
    context.update(getContext(re_list_1, page, "item", 0))
    context.update(getContext(re_list_2, page2, "item2", 0))
    context.update({"form": form, })
    return render(request,"expert/home.html", context)
def getProjectList(request, college_id, special_id, path):
    if path == FIRST_ROUND_PATH:
        alloc_project_list = get_project_list(request).filter(project_status__status = PROJECT_STATUS_APPLICATION_EXPERT_SUBJECT)
    else:
        alloc_project_list = get_project_list(request).filter(project_status__status = PROJECT_STATUS_FINAL_EXPERT_SUBJECT)

    if college_id != "-1":
        alloc_project_list = alloc_project_list.filter(teacher__college = college_id)
    if special_id != "-1":
        alloc_project_list = alloc_project_list.filter(project_special = special_id)
    if path == FIRST_ROUND_PATH:
        unalloc_project_list = get_project_list(request).filter(project_status__status = PROJECT_STATUS_APPLICATION_SCHOOL_OVER)
    else:
        unalloc_project_list = get_project_list(request).filter(project_status__status = PROJECT_STATUS_FINAL_SCHOOL_OVER)
    if college_id != "-1":
        unalloc_project_list = unalloc_project_list.filter(teacher__college = college_id)
    if special_id != "-1":
        unalloc_project_list = unalloc_project_list.filter(project_special = special_id)


    for project in alloc_project_list:
        project.review_status = getProjectReviewStatus(project)


    context = getContext(unalloc_project_list, 1, "item", 0)
    context2 = getContext(alloc_project_list, 1, "item2", 0)
    html_alloc = render_to_string("school/widgets/alloc_project_table.html", context2)
    html_unalloc = render_to_string("school/widgets/unalloc_project_table.html", context)
    return simplejson.dumps({"html_alloc": html_alloc, "html_unalloc": html_unalloc, })
def noticeMessageSettingBase(request, userauth):
    notice_choice = NOTICE_CHOICE
    template_notice_message = TemplateNoticeMessage.objects.all()
    template_notice_message_form = TemplateNoticeMessageForm()
    template_notice_message_group = []
    cnt = 1
    for item in template_notice_message:
        nv = {
            "id": item.id,
            "iid": cnt,
            "title": item.title,
            "message": item.message,
        }
        cnt += 1
        template_notice_message_group.append(nv)

    notice_form = NoticeForm(request=request)
    context = getContext(template_notice_message_group, 1, "item", 0)
    context.update({
        "template_notice_message_form": template_notice_message_form,
        "notice_choice": notice_choice,
        "notice_form": notice_form,
        "userauth": userauth,
        # "college_list":college_list_choice,
    })
    context.update(getContext(getCollegeListForHtml(), 1, "item2", 0))

    return render(request, userauth['role'] + "/notice_message_setting.html",
                  context)
Example #11
0
def refresh_user_table(request, identity, search_form="", page=1):
    try:
        form = SearchForm(deserialize_form(search_form))
        if form.is_valid():
            name = form.cleaned_data['name']
    except:
        name = ""

    if identity == SCHOOL_USER:
        school_users = SchoolProfile.objects.filter(
            Q(userid__first_name__contains=name))
        context = getContext(school_users, page, "item")
        return render_to_string("widgets/dispatch/school_user_table.html",
                                context)
    elif identity == COLLEGE_USER:
        college_users = CollegeProfile.objects.filter(
            Q(userid__first_name__contains=name))
        context = getContext(college_users, page, "item2")
        return render_to_string("widgets/dispatch/college_user_table.html",
                                context)
    elif identity == TEACHER_USER:
        colleges = getCollege(request)
        qset = reduce(lambda x, y: x | y,
                      [Q(college=_college) for _college in colleges])
        users = TeacherProfile.objects.filter(qset).filter(
            Q(userid__first_name__contains=name)).order_by('college')
        context = getContext(users, page, "item")
        return render_to_string("widgets/dispatch/teacher_user_table.html",
                                context)
    elif identity == EXPERT_USER:
        users = ExpertProfile.objects.filter(
            Q(userid__first_name__contains=name)).order_by('college')
        context = getContext(users, page, "item3")
        return render_to_string("widgets/dispatch/expert_user_table.html",
                                context)
Example #12
0
File: views.py Project: MHGERP/ERP
def index_context(request):
	news_company_news = News.objects.filter(news_category__category = NEWS_CATEGORY_COMPANYNEWS).order_by('-news_date')
	news_import_info = News.objects.filter(news_category__category = NEWS_CATEGORY_IMPORTINFO).order_by('-news_date')
	homepage_docs = DocumentFile.objects.filter(news__isnull = False).order_by('-news__news_date')
	context = getContext(news_company_news, 1, "news_company_news")
	context.update(getContext(news_import_info, 1 , "news_import_info"))
	context.update(getContext(homepage_docs, 1, "homepage_docs"))
	return context
Example #13
0
def list_news(request):
    news_list = News.objects.order_by('-news_date')
    news_page = request.GET.get('news_page')

    docs_list = news_list.exclude(news_document=u'')
    docs_page = request.GET.get('docs_page')

    context = getContext(news_list, news_page, 'news')
    context.update(getContext(docs_list, docs_page, 'docs'))
    return render(request, 'home/news-list.html', \
                  Context(context))
def list_news(request):
    news_list = News.objects.order_by('-news_date')
    news_page = request.GET.get('news_page')

    docs_list = news_list.exclude(news_document=u'')
    docs_page = request.GET.get('docs_page')

    context = getContext(news_list, news_page, 'news')
    context.update(getContext(docs_list, docs_page, 'docs'))
    return render(request, 'home/news-list.html', \
                  Context(context))
Example #15
0
def index_context(request):
    news_company_news = News.objects.filter(
        news_category__category=NEWS_CATEGORY_COMPANYNEWS).order_by(
            '-news_date')
    news_import_info = News.objects.filter(
        news_category__category=NEWS_CATEGORY_IMPORTINFO).order_by(
            '-news_date')
    homepage_docs = DocumentFile.objects.filter(
        news__isnull=False).order_by('-news__news_date')
    context = getContext(news_company_news, 1, "news_company_news")
    context.update(getContext(news_import_info, 1, "news_import_info"))
    context.update(getContext(homepage_docs, 1, "homepage_docs"))
    return context
Example #16
0
def dispatchView(request):
    dispatch_form = DispatchForm()
    dispatchAddCollege_form = DispatchAddCollegeForm()
    college_users = CollegeProfile.objects.all()
    expert_users = ExpertProfile.objects.all().order_by('college')
    school_users = SchoolProfile.objects.all()
    context = {
        "dispatch_form": dispatch_form,
        "dispatchAddCollege_form": dispatchAddCollege_form,
        "search_form": SearchForm(),
    }
    context.update(getContext(school_users, 1, "item"))
    context.update(getContext(college_users, 1, "item2"))
    context.update(getContext(expert_users, 1, "item3"))
    return render(request, "adminStaff/dispatch.html", context)
def index(request):
    '''
    for index_new
    '''
    news_announcement = News.objects.filter(news_category__category=NEWS_CATEGORY_ANNOUNCEMENT).order_by('-news_date')
    # news_policy = News.objects.filter(news_category__category=NEWS_CATEGORY_POLICY).order_by('-news_date')
    news_dynamic = News.objects.filter(news_category__category=NEWS_CATEGORY_DYNAMIC).order_by('-news_date')
    news_outstanding = News.objects.filter(news_category__category=NEWS_CATEGORY_OUTSTANDING).order_by('-news_date')
    news_others = News.objects.filter(news_category__category=NEWS_CATEGORY_OTHERS).order_by('-news_date')
    context = getContext(news_announcement, 1, "news_announcement", page_elems=8)
    # context.update(getContext(news_policy, 1, "news_policy", page_elems=8))
    context.update(getContext(news_dynamic, 1, "news_dynamic", page_elems=8))
    context.update(getContext(news_outstanding, 1, "news_outstanding", page_elems=8))
    context.update(getContext(news_others, 1, "news_others", page_elems=8))
    return context
Example #18
0
def dispatchView(request):
    dispatch_form = DispatchForm()
    dispatchAddCollege_form=DispatchAddCollegeForm()
    college_users = CollegeProfile.objects.all()
    expert_users = ExpertProfile.objects.all().order_by('college')
    school_users = SchoolProfile.objects.all()
    context = {
               "dispatch_form":dispatch_form,
               "dispatchAddCollege_form":dispatchAddCollege_form,
               "search_form": SearchForm(),
    }
    context.update(getContext(school_users, 1, "item"))
    context.update(getContext(college_users, 1, "item2"))
    context.update(getContext(expert_users, 1, "item3"))
    return render(request, "adminStaff/dispatch.html", context)
Example #19
0
def getAllocProjectPagination(request, page, college_id, special_id, path):
    message = ""
    page = int(page)
    if path == FIRST_ROUND_PATH:
        project_list = get_project_list(request).filter(
            project_status__status=PROJECT_STATUS_APPLICATION_EXPERT_SUBJECT)
    else:
        project_list = get_project_list(request).filter(
            project_status__status=PROJECT_STATUS_FINAL_EXPERT_SUBJECT)

    if college_id != "-1":
        project_list = project_list.filter(teacher__college=college_id)
    if special_id != "-1":
        project_list = project_list.filter(project_special=special_id)

    context = getContext(project_list, page, "item2", 0)

    for project in context["item2_list"]:
        project.review_status = getProjectReviewStatus(project)

    html = render_to_string("school/widgets/alloc_project_table.html", context)
    return simplejson.dumps({
        "message": message,
        "html": html,
    })
Example #20
0
def getNewsReleasePagination(request,page):
    message=""
    page =int(page)
    newsList = News.objects.all()
    context = getContext(newsList,page,"item",page_elems=7)
    html = render_to_string("adminStaff/widgets/newslist.html",context)
    return simplejson.dumps({"message":message,"html":html})
Example #21
0
def getApplys(request, page):
    page = int(page)
    applys = ApplyInfo.objects.filter(
        innovation_grade=datetime.datetime.today().year)
    practice = PracticeProfile.objects.get(userid=request.user)
    applys = applys.filter(
        Q(wish_first=practice.id) | Q(wish_second=practice.id))

    for apply in applys:
        apply.is_first_wish = "是" if apply.wish_first == practice else "否"
        try:
            apply.small_class = "已录入(%s)" % StudentProfile.objects.get(
                baseinfo_studentid=apply.student_id).small_class
        except:
            apply.small_class = "未录入"
    number, first_number = applys.count(), applys.filter(
        wish_first=practice.id).count()
    applys = sorted(list(applys), key=lambda x: x.is_first_wish, reverse=True)
    context = getContext(applys, page, "item", 0)

    context.update({
        "number": number,
        "first_number": first_number,
        "practice": practice,
    })

    return render_to_string("practice/widgets/applys.html", context)
Example #22
0
def refresh_alloc_table(request, insitute):
    subject_list = get_current_project_query_set().filter(insitute_id=insitute)
    page = request.GET.get("page")
    context = getContext(subject_list, page, 'subject', 0)
    table_html = render_to_string("adminStaff/widgets/subjectalloc_table.html",
                                  context)
    return simplejson.dumps({"table": table_html})
Example #23
0
def show_index_get_search_context(request, project_page, new_show=False):
    search_school = request.GET.get('search_school') or ""
    search_year = request.GET.get('search_year') or ""
    search_grade = request.GET.get('search_grade') or ""
    search_keywords = request.GET.get('search_keywords') or ""
    pro_type = ShowProjectSingle if new_show else ProjectSingle

    q1 = (search_year and Q(year=search_year)) or None
    q2 = (search_school and Q(school=search_school)) or None
    q3 = (search_grade and Q(project_grade=search_grade)) or None
    q4 = (search_keywords and  (Q(keywords__icontains=search_keywords) | \
            Q(title__icontains=search_keywords) | Q(background__icontains=search_keywords) \
            | Q(result_overview__icontains=search_keywords))) or None
    qset = filter(lambda x: x != None, [q1, q2, q3, q4])
    loginfo(p=q4, label="in q4")
    loginfo(p=qset, label="in qset")
    if qset:
        qset = reduce(lambda x, y: x & y, qset)
        project_list = pro_type.objects.filter(qset)
    else:
        project_list = pro_type.objects.all()

    context = getContext(project_list, project_page, 'project', page_elems=9)
    context["search_school"] = search_school
    context["search_year"] = search_year
    context["search_grade"] = search_grade

    return context
def show_index_get_search_context(request, project_page,new_show = False):
    search_school = request.GET.get('search_school') or ""
    search_year = request.GET.get('search_year') or ""
    search_grade = request.GET.get('search_grade') or ""
    search_keywords=request.GET.get('search_keywords') or ""
    pro_type = ShowProjectSingle if new_show else ProjectSingle
    
    q1 = (search_year and Q(year=search_year)) or None
    q2 = (search_school and Q(school=search_school)) or None
    q3 = (search_grade and Q(project_grade=search_grade)) or None
    q4 = (search_keywords and  (Q(keywords__icontains=search_keywords) | \
            Q(title__icontains=search_keywords) | Q(background__icontains=search_keywords) \
            | Q(result_overview__icontains=search_keywords))) or None
    qset = filter(lambda x: x != None, [q1, q2, q3,q4])
    loginfo(p=q4, label="in q4")
    loginfo(p=qset, label="in qset")
    if qset:
        qset = reduce(lambda x, y: x & y, qset)
        project_list = pro_type.objects.filter(qset)
    else:
        project_list = pro_type.objects.all()

    context = getContext(project_list, project_page, 'project', page_elems=9)
    context["search_school"] = search_school
    context["search_year"] = search_year
    context["search_grade"] = search_grade

    return context
def searchStudent(request, search_value):
    students = StudentProfile.objects.filter(Q(baseinfo_name = search_value) | Q(baseinfo_studentid = search_value))
    if check_auth(request.user, TEACHER_USER):
        teacher = TeacherProfile.objects.get(userid = request.user)
        students = students.filter(small_class = teacher.small_class)
    context = getContext(students, 1, "item", 0)
    return render_to_string("teacher/widgets/student_set_table.html", context)
Example #26
0
def getNewsReleasePagination(request, page):
    message = ""
    page = int(page)
    newsList = News.objects.all()
    context = getContext(newsList, page, "item", page_elems=7)
    html = render_to_string("adminStaff/widgets/newslist.html", context)
    return simplejson.dumps({"message": message, "html": html})
def getCourseMembers(request, course_id, page):
    page = int(page)
    selects = SelectCourse.objects.filter(course__id = course_id)
    context = getContext(selects, page, "item2", 1)
    context.update({"course_id": course_id, })
    html = render_to_string("teacher/widgets/course_info_table.html", context)
    return simplejson.dumps({"html": html, })
Example #28
0
def refresh_to_table(page, school_name):
    if school_name == "None": school_name = None
    # subject_list = AdminStaffService.GetSubject_list(school = school_name)
    subject_list = get_current_project_query_set().filter(school=school_name)
    context = getContext(subject_list, page, 'item', 0)
    context.update({"school_name": school_name})
    return render_to_string("adminStaff/widgets/subjectrating_table.html",
                            context)
Example #29
0
def getUserListPagination(request, page, user):
    page = int(page)
    html = ""
    if user == "college":
        user_list = getCollegeListForHtml()
        context = getContext(user_list, page, "item2", 0)
        html = render_to_string("widgets/notice_message_setting_select_college_table.html", context)
    elif user == "teacher":
        user_list = cnt_teacher_list
        context = getContext(user_list, page, "item3", 0)
        html = render_to_string("widgets/notice_message_setting_select_teacher_table.html", context)
    else:
        user_list = cnt_expert_list
        context = getContext(user_list, page, "item4", 0)
        html = render_to_string("widgets/notice_message_setting_select_expert_table.html", context)

    return simplejson.dumps({"status":1, "html":html,})
Example #30
0
def searchStudent(request, search_value):
    students = StudentProfile.objects.filter(
        Q(baseinfo_name=search_value) | Q(baseinfo_studentid=search_value))
    if check_auth(request.user, TEACHER_USER):
        teacher = TeacherProfile.objects.get(userid=request.user)
        students = students.filter(small_class=teacher.small_class)
    context = getContext(students, 1, "item", 0)
    return render_to_string("teacher/widgets/student_set_table.html", context)
Example #31
0
    def ShowManage(request):
        show_list = ShowProjectSingle.objects.all()
        page = request.GET.get('page')
        context = getContext(show_list, page, 'show', 0)
        for show in context['show_list']:
            show.filenumber = ShowFiles.objects.filter(project_id = show).count()

        return render(request, "adminStaff/show_manage.html", context)
def getSearchStudentPagination(request,page,searchform):
    message = ""
    role = request.session.get('auth_role',"")
    searchform = StudentSearchForm(deserialize_form(searchform),request = request)
    stu_set = stuFilterList(request,searchform).order_by("small_class","innovation_grade")
    context = getContext(stu_set,page,"item",0)
    context.update({"role":role})
    html = render_to_string("common/student/student_search_table.html",context)
    return simplejson.dumps({"message":message,"html":html})
Example #33
0
def docs_search_page(request, docs_input):
    docs_list = News.objects.exclude(news_document=u""). \
        filter(Q(news_document__icontains=docs_input)\
                                        & Q(news_date__gte=datetime.date.today()-datetime.timedelta(365)))
    context = getContext(docs_list, 1, 'docs')
    html = render_to_string('home/ajax/_docs_list.html',
                            context,
                            context_instance=RequestContext(request))
    return simplejson.dumps({'html': html})
def docs_search_page(request, docs_input):
    docs_list = News.objects.exclude(news_document=u""). \
        filter(Q(news_document__icontains=docs_input)\
                                        & Q(news_date__gte=datetime.date.today()-datetime.timedelta(365)))
    context = getContext(docs_list, 1, 'docs')
    html = render_to_string('home/ajax/_docs_list.html',
                            context,
                            context_instance=RequestContext(request))
    return simplejson.dumps({'html':html})
Example #35
0
def getParam(pro_list, userauth,flag,page,page2):
    (pending_q,default_q,search_q)=get_qset(userauth)
    not_pass_apply_project_group=pro_list.filter(pending_q)
    if flag:
        pass_apply_project_group=pro_list.filter(default_q)
    else:
        pass_apply_project_group=pro_list.filter(search_q)
    if userauth['role']==FINANCE_USER:
        if userauth['status']=="budget":
            pass_apply_project_group = pass_apply_project_group.order_by('projectfundbudget__serial_number')
        else:
            pass_apply_project_group = pass_apply_project_group.order_by('projectfundsummary__serial_number')
    pass_apply_project_group=addURL(pass_apply_project_group)
    not_pass_apply_project_group=addURL(not_pass_apply_project_group)
    param={}
    param.update(getContext(pass_apply_project_group,page2,"item2",0,page_elems=10))
    param.update(getContext(not_pass_apply_project_group,page,"item",0,page_elems=10))
    param.update({"pro_count":len(pass_apply_project_group)})
    return param
Example #36
0
def finalAllocView(request):
    expert_list = ExpertProfile.objects.all()
    unalloc_project_list = get_project_list(request).filter(project_status__status = PROJECT_STATUS_FINAL_SCHOOL_OVER)
    alloc_project_list = get_project_list(request).filter(project_status__status = PROJECT_STATUS_FINAL_EXPERT_SUBJECT)
    form = FilterForm(request = request)
    expert_form = FilterForm()
    context = {"form": form,
               "expert_form": expert_form,
               "page_info": "finalalloc",}
 
    context.update(getContext(unalloc_project_list, 1, "item", 0))
    context.update(getContext(alloc_project_list, 1, "item2", 0))
    context.update(getContext(expert_list, 1, "item3", 0))
    for expert in context['item3_list']:
        expert.alloc_num = Re_Project_Expert.objects.filter(Q(expert = expert) & Q(is_first_round = True) & Q(project__project_status__status = PROJECT_STATUS_APPLICATION_EXPERT_SUBJECT)).count()

    for project in context['item2_list']:
        project.review_status = getProjectReviewStatus(project)

    return render(request, "school/alloc.html", context)
Example #37
0
def news_search_page(request, news_input, news_cate):
    news_list = News.objects. \
        filter(news_date__gte=datetime.date.today()-datetime.timedelta(365)). \
        filter(news_category__category=news_cate). \
        filter(Q(news_title__icontains=news_input) |
               Q(news_content__icontains=news_input))
    context = getContext(news_list, 1, 'news')
    html = render_to_string('home/ajax/_news_list.html',
                            context,
                            context_instance=RequestContext(request))
    return simplejson.dumps({'html': html})
def news_search_page(request, news_input, news_cate):
    news_list = News.objects. \
        filter(news_date__gte=datetime.date.today()-datetime.timedelta(365)). \
        filter(news_category__category=news_cate). \
        filter(Q(news_title__icontains=news_input) |
               Q(news_content__icontains=news_input))
    context = getContext(news_list, 1, 'news')
    html = render_to_string('home/ajax/_news_list.html',
                            context,
                            context_instance=RequestContext(request))
    return simplejson.dumps({'html':html})
Example #39
0
    def ImportExpert(request):
        """
        """
        if request.method == "GET":
            expert_form = forms.ExpertDispatchForm()
            email_list = AdminStaffService.GetRegisterExpertList()

            page = request.GET.get('page')
            context = getContext(email_list, page, 'item', 0)
            context.update({'expert_form': expert_form})
            return render(request, "adminStaff/ImportExpert.html", context)
Example #40
0
def courseViews(request):
    filterForm = CourseFilterForm()
    courseForm = CourseForm()
    importDataForm = ImportDataForm()
    course_list = Course.objects.all()
    context = getContext(course_list, 1, "item")
    context['course_form'] = courseForm
    context['importDataForm'] = importDataForm
    context["show_delete"] = True
    context["filter_form"] = filterForm
    return render(request, "adminStaff/course/course_info.html", context)
def index(request):
    news_announcement = News.objects.filter(news_category__category=NEWS_CATEGORY_ANNOUNCEMENT).order_by('-news_date')
    news_docs = News.objects.exclude(news_document=u'').order_by('-news_date')
    context = getContext(news_announcement, 1, "news_announcement",page_elems=7)
    context.update(getContext(news_docs,1,"news_docs",page_elems = 7))
    def convert_url(raw_url):
        return MEDIA_URL + raw_url[raw_url.find(MEDIA_URL)+len(MEDIA_URL):]
    homepage_pic = HomePagePic.objects.all()
    flag = True
    for pic in homepage_pic:
        pic.url = convert_url(pic.pic_obj.url)
        print pic.url
        if flag:
            pic.active = True
            flag = False
        else: pic.active = False
    context.update({
        'homepage_pic': homepage_pic,
    })
    return render(request,"home/home.html",context)
Example #42
0
def getCourseMembers(request, course_id, page):
    page = int(page)
    selects = SelectCourse.objects.filter(course__id=course_id)
    context = getContext(selects, page, "item2", 1)
    context.update({
        "course_id": course_id,
    })
    html = render_to_string("teacher/widgets/course_info_table.html", context)
    return simplejson.dumps({
        "html": html,
    })
Example #43
0
def dispatchView(request):
    dispatchAddCollege_form=DispatchAddCollegeForm()
    try:
        teacher_users = TeacherProfile.objects.all().order_by('college')
    except:
        teacher_users = TeacherProfile.objects.none()
    context = {
               "dispatchAddCollege_form":dispatchAddCollege_form,
               "search_form": SearchForm(),
    }
    context.update(getContext(teacher_users, 1, "item"))
    return render(request, "school/dispatch.html", context)
Example #44
0
def dispatchView(request):
    dispatchAddCollege_form = DispatchAddCollegeForm()
    try:
        teacher_users = TeacherProfile.objects.all().order_by('college')
    except:
        teacher_users = TeacherProfile.objects.none()
    context = {
        "dispatchAddCollege_form": dispatchAddCollege_form,
        "search_form": SearchForm(),
    }
    context.update(getContext(teacher_users, 1, "item"))
    return render(request, "school/dispatch.html", context)
Example #45
0
def newsRelease(request):
    if request.method == "GET":
        form = NewsForm()
    else:
        form = NewsForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
    newsList = News.objects.all().order_by('-news_date')
    context = getContext(newsList,1,"item",page_elems=7)
    context.update({"newsform":NewsForm,
                  })
    return render(request,"adminStaff/news_release.html",context)
def getExpertList(request, id, path):
    message = ""
    is_first_round = (path == FIRST_ROUND_PATH)
    status = PROJECT_STATUS_APPLICATION_EXPERT_SUBJECT if is_first_round else PROJECT_STATUS_FINAL_EXPERT_SUBJECT

    if id == '-1': expert_list = ExpertProfile.objects.all()
    else: expert_list = ExpertProfile.objects.filter(college__id = id)
    context = getContext(expert_list, 1, "item3", 0)
    for expert in context['item3_list']:
        expert.alloc_num = Re_Project_Expert.objects.filter(Q(expert = expert) & Q(is_first_round = is_first_round) & Q(project__project_status__status = status)).count()
    html = render_to_string("school/widgets/alloc_expert_table.html", context)
    return simplejson.dumps({"message": message, "html": html, })
def getStudentList(request, year, page_numbers, cls, page):
    page = int(page)
    page_numbers = int(page_numbers)
    students = StudentProfile.objects.all()
    if year != "-1": students = students.filter(innovation_grade = year)
    if check_auth(request.user, TEACHER_USER):
        teacher = TeacherProfile.objects.get(userid = request.user)
        students = students.filter(small_class = teacher.small_class)
    elif cls != "-1":
        students = students.filter(small_class__practice_class__userid__username = cls)

    context = getContext(students, page, "item", 0, page_numbers)
    return render_to_string("teacher/widgets/student_set_table.html", context)
Example #48
0
def getSearchStudentPagination(request, page, searchform):
    message = ""
    role = request.session.get('auth_role', "")
    searchform = StudentSearchForm(deserialize_form(searchform),
                                   request=request)
    stu_set = stuFilterList(request,
                            searchform).order_by("small_class",
                                                 "innovation_grade")
    context = getContext(stu_set, page, "item", 0)
    context.update({"role": role})
    html = render_to_string("common/student/student_search_table.html",
                            context)
    return simplejson.dumps({"message": message, "html": html})
Example #49
0
File: ajax.py Project: MHGERP/ERP
def getNewsList(request, news_cate, page=1):
    """
    mxl
    """
    try:
        page = int(page)
    except:
        page = 1
    news_list = News.objects.filter(news_category__category=news_cate).order_by('-news_date')
    context = getContext(news_list, page, "item", 0)
    html = render_to_string("management/widgets/news_table.html", context)
    # return html
    return simplejson.dumps({'html': html})
Example #50
0
def dispatchView(request):
    dispatchAddCollege_form=DispatchAddCollegeForm(user=request.user)
    colleges = getCollege(request)
    try:
        qset = reduce(lambda x,y:x|y,[Q(college = _college) for _college in colleges])
        teacher_users = TeacherProfile.objects.filter(qset)
    except:
        teacher_users = TeacherProfile.objects.none()
    context = {
               "dispatchAddCollege_form":dispatchAddCollege_form,
    }
    context.update(getContext(teacher_users, 1, "item"))
    return render(request, "college/dispatch.html", context)
def newsListByCate(request, news_cate):
    try:
        if news_cate == NEWS_CATEGORY_DOCUMENTS:
            news_list = News.objects.exclude(news_document=u'').order_by('-news_date')
        else:
            news_list = News.objects.filter(news_category__category=news_cate).order_by('-news_date')
    except:
        raise Http404
    context = getContext(news_list,1, 'item')
    context["news_cate"] = news_cate
    context['%s_active' % news_cate] = 'active'
    return render(request, 'home/newsContentByCate.html', \
                  context)
def docs_turn_page(request, docs_page, docs_search):
    try:
        docs_page = int(docs_page)
    except:
        docs_page = 1
    docs_list = (docs_search and \
                     News.objects.filter(news_document__icontains=docs_search)) \
                     or News.objects.exclude(news_document=u'')
    context = getContext(docs_list, docs_page, 'docs')
    html = render_to_string('home/ajax/_docs_list.html',
                            context,
                            context_instance=RequestContext(request))
    return simplejson.dumps({'html':html})
def getCourseScores(request, course_id, page):
    page = int(page)
    selects = SelectCourse.objects.filter(course__id = course_id)
    for select in selects:
        tmp_score = Score.objects.filter(select_obj = select)
        if tmp_score:
            select.score = tmp_score[0]
        else :
            continue
        # select.score = Score.objects.get(select_obj = select)
    context = getContext(selects, page, "item2", 1)
    context.update({"course_id": course_id, })
    html = render_to_string("teacher/widgets/score_info_table.html", context)
    return simplejson.dumps({"html": html, })
def common_studentsearchViews(request):
    role = request.session.get('auth_role', "")
    stu_set = ""
    if request.method == 'POST':
        searchform = StudentSearchForm(request.POST,request = request)
        stu_set = stuFilterList(request,searchform).order_by("small_class","innovation_grade")
    else:
        searchform = StudentSearchForm(request = request)
    context = getContext(stu_set,1,"item",0)
    context.update({
        'searchform':searchform,
        'role':role,
    })
    return context
def news_turn_page(request, news_page, news_search, news_cate):
    try:
        news_page = int(news_page)
    except:
        news_page = 1
    news_list = (news_search and \
                 News.objects.filter(news_category__category=news_cate).filter(news_title__icontains=news_search)) \
        or News.objects.filter(news_category__category=news_cate).order_by('-news_date')
    context = getContext(news_list, news_page, 'news')
    context["news_cate"] = NewsCategory.objects.get(category=news_cate)
    html = render_to_string('home/ajax/_news_list.html',
                            context,
                            context_instance=RequestContext(request))
    return simplejson.dumps({'html':html})