Esempio n. 1
0
def user_add(request):
    data_tuple = request.POST.lists()
    data_dic = {}
    login_user = request.user.username
    for i in data_tuple:
        data_dic[i[0]] = i[1][0]
    update_user = data_dic['useradd_name']
    update_passwd = data_dic['useradd_passwd']
    encrypt_passwd = encrypt.encrypt_mode_cbc(update_passwd,encrypt.keys).replace('\n','')

    update_current = passwd_current.objects.filter(user=update_user).all()
    if len(update_current) ==0:
        update_current = passwd_current()
        update_current.user = update_user
        update_current.passwd = encrypt_passwd
        update_current.author = login_user
        update_current.save()

        # update history data.
        update_list = passwd_list()
        update_list.user = update_user
        update_list.passwd = encrypt_passwd
        update_list.author = login_user
        update_list.save()
        prompt_data="<h4><b>操作提示:用户创建成功!这是系统最后一次显示所修改的明文口令,请牢记该口令,如需再次获取,请联系系统管理员!</b></h4><h4 style=\"color:red\"><b>用户:%s</b></h4><h4 style=\"color:red\"><b>口令:%s</b></h4>" %(update_user,update_passwd)
        return render_to_response('prompt.html',{'prompt_data':prompt_data})
    else:
        prompt_data="<h4><b>操作提示:用户%s已经存在,请确认后重新操作。</b></h4>" %update_user
        return render_to_response('prompt.html',{'prompt_data':prompt_data})
Esempio n. 2
0
def passwd_update(request):
    data_tuple = request.POST.lists()
    data_dic = {}
    login_user = request.user.username
    for i in data_tuple:
        data_dic[i[0]] = i[1][0]

    update_user = data_dic['select_user']
    update_passwd = data_dic['password']
    encrypt_passwd = encrypt.encrypt_mode_cbc(update_passwd,
                                              encrypt.keys).replace('\n', '')
    update_current = passwd_current.objects.filter(user=update_user).all()

    if len(update_current) == 1:
        update_current = passwd_current.objects.get(user=update_user)
        update_current.user = update_user
        update_current.passwd = encrypt_passwd
        update_current.author = login_user
        update_current.save()

        # update history data.
        update_list = passwd_list()
        update_list.user = update_user
        update_list.passwd = encrypt_passwd
        update_list.author = login_user
        update_list.save()
    else:
        return_data = '异常操作,请联系系统管理员!'
        return HttpResponse(return_data)

    update_list = passwd_list.objects.all()
    prompt_data = "<h4><b>操作提示:口令修改成功!这是系统最后一次显示所修改的明文口令,请牢记该口令,如需再次获取,请联系系统管理员!</b></h4><h4 style=\"color:red\"><b>用户:%s</b></h4><h4 style=\"color:red\"><b>口令:%s</b></h4>" % (
        update_user, update_passwd)
    return render_to_response('prompt.html', {'prompt_data': prompt_data})
Esempio n. 3
0
def passwd_update(request):
    data_tuple = request.POST.lists()
    data_dic = {}
    login_user = request.user.username
    for i in data_tuple:
        data_dic[i[0]] = i[1][0]

    update_user = data_dic['select_user']
    update_passwd = data_dic['password']
    encrypt_passwd = encrypt.encrypt_mode_cbc(update_passwd,encrypt.keys).replace('\n','')
    update_current = passwd_current.objects.filter(user=update_user).all()
		
    if len(update_current) ==1:
        update_current = passwd_current.objects.get(user=update_user)
        update_current.user = update_user
        update_current.passwd = encrypt_passwd
        update_current.author = login_user
        update_current.save()
		
        # update history data.
        update_list = passwd_list()
        update_list.user = update_user
        update_list.passwd = encrypt_passwd
        update_list.author = login_user
        update_list.save()
    else:
        return_data='异常操作,请联系系统管理员!'
        return HttpResponse(return_data)

    update_list = passwd_list.objects.all()
    prompt_data="<h4><b>操作提示:口令修改成功!这是系统最后一次显示所修改的明文口令,请牢记该口令,如需再次获取,请联系系统管理员!</b></h4><h4 style=\"color:red\"><b>用户:%s</b></h4><h4 style=\"color:red\"><b>口令:%s</b></h4>" %(update_user,update_passwd)
    return render_to_response('prompt.html',{'prompt_data':prompt_data})
Esempio n. 4
0
def user_add(request):
    data_tuple = request.POST.lists()
    data_dic = {}
    login_user = request.user.username
    for i in data_tuple:
        data_dic[i[0]] = i[1][0]
    update_user = data_dic['useradd_name']
    update_passwd = data_dic['useradd_passwd']
    encrypt_passwd = encrypt.encrypt_mode_cbc(update_passwd,
                                              encrypt.keys).replace('\n', '')

    update_current = passwd_current.objects.filter(user=update_user).all()
    if len(update_current) == 0:
        update_current = passwd_current()
        update_current.user = update_user
        update_current.passwd = encrypt_passwd
        update_current.author = login_user
        update_current.save()

        # update history data.
        update_list = passwd_list()
        update_list.user = update_user
        update_list.passwd = encrypt_passwd
        update_list.author = login_user
        update_list.save()
        prompt_data = "<h4><b>操作提示:用户创建成功!这是系统最后一次显示所修改的明文口令,请牢记该口令,如需再次获取,请联系系统管理员!</b></h4><h4 style=\"color:red\"><b>用户:%s</b></h4><h4 style=\"color:red\"><b>口令:%s</b></h4>" % (
            update_user, update_passwd)
        return render_to_response('prompt.html', {'prompt_data': prompt_data})
    else:
        prompt_data = "<h4><b>操作提示:用户%s已经存在,请确认后重新操作。</b></h4>" % update_user
        return render_to_response('prompt.html', {'prompt_data': prompt_data})