コード例 #1
0
ファイル: ajax.py プロジェクト: DutBright/scientificResearch
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)
コード例 #2
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)
コード例 #3
0
ファイル: test_search_form.py プロジェクト: reivaj05/Kabbage
 def test_form_with_invalid_data_provided(self):
     form_data = {
         'query': '',
         'search_criteria': ''
     }
     form = SearchForm(data=form_data)
     self.assertFalse(
         form.is_valid(),
         'Expected form to be invalid with incorrect data provided'
     )
コード例 #4
0
ファイル: test_search_form.py プロジェクト: reivaj05/Kabbage
 def test_form_with_valid_data_provided(self):
     form_data = {
         'query': 'test_query',
         'search_criteria': ['T', 'W']
     }
     form = SearchForm(data=form_data)
     self.assertTrue(
         form.is_valid(),
         'Expected form to be valid with correct data provided'
     )
コード例 #5
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)
コード例 #6
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)
コード例 #7
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,
        "search_form": SearchForm(),
    }
    context.update(getContext(teacher_users, 1, "item"))
    return render(request, "college/dispatch.html", context)