Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
def Dispatch(request, form, identity, page, search_form):
    if identity == SCHOOL_USER or identity == COLLEGE_USER:
        dispatchForm = DispatchForm(deserialize_form(form))
    elif identity == EXPERT_USER:
        dispatchForm = DispatchAddCollegeForm(deserialize_form(form))
    elif identity == TEACHER_USER:
        if request.session.get('auth_role', "") in (SCHOOL_USER):
            dispatchForm = DispatchAddCollegeForm(deserialize_form(form))
        elif request.session.get('auth_role', "") in (COLLEGE_USER):
            dispatchForm = DispatchAddCollegeForm(deserialize_form(form),
                                                  user=request.user)
    else:
        dispatchForm = DispatchForm(deserialize_form(form))
    if dispatchForm.is_valid():
        username = dispatchForm.cleaned_data["username"].strip()
        password = dispatchForm.cleaned_data["password"].strip()
        email = dispatchForm.cleaned_data["email"].strip()
        person_name = dispatchForm.cleaned_data["person_firstname"].strip()
        if request.session.get('auth_role', "") in (COLLEGE_USER):
            pass
            #error = checkIdcard(username)
            #if error[0]!=0:
            #    loginfo(error[1])
            #    message= error[1]
            #    return simplejson.dumps({'field':dispatchForm.data.keys(),'error_id':dispatchForm.errors.keys(),'message':message})
        if password == "":
            password = username[-6:]
        if identity == SCHOOL_USER or identity == COLLEGE_USER:
            flag = sendemail(request, username, password, email, identity,
                             person_name)
        elif identity == EXPERT_USER or identity == TEACHER_USER:
            college = dispatchForm.cleaned_data["college"]
            if identity == EXPERT_USER:
                send_email = False
            else:
                send_email = True
            flag = sendemail(request,
                             username,
                             password,
                             email,
                             identity,
                             person_name,
                             send_email,
                             college=college)
        if flag:
            if identity == EXPERT_USER:
                message = u"导入专家成功"
            else:
                message = u"发送邮件成功"
            table = refresh_user_table(request, identity, search_form, page)
            return simplejson.dumps({
                'field': dispatchForm.data.keys(),
                'status': '1',
                'message': message,
                'table': table
            })
        else:
            message = u"用户名已存在"
            return simplejson.dumps({
                'field': dispatchForm.data.keys(),
                'status': '1',
                'message': message
            })
    else:
        return simplejson.dumps({
            'field': dispatchForm.data.keys(),
            'error_id': dispatchForm.errors.keys(),
            'message': u"输入有误"
        })