Ejemplo n.º 1
0
def show_user_list(request):
    user_obj = Candidate_user.objects(
        del_flag__ne=1).order_by('-role_name').as_pymongo()

    result_json = dumps(user_obj, ensure_ascii=False)
    print(result_json)

    result_count = user_obj.count()
    result_dict = {'result_count': result_count, 'result_json': result_json}
    return render(request, 'admin_html/user-list.html', result_dict)
Ejemplo n.º 2
0
def prompt_register_authorize(request):

    admin_login_name = request.session.get('login_name')

    if request.method == "POST":
        register_login_name = request.POST.get('register_login_name')
        register_obj = Candidate_user.objects(
            login_name=register_login_name).update_one(account_status=True)

        #         admin_obj = Candidate_user.objects(login_name=admin_login_name,prompt_message__S__login_name=register_login_name).update_one(set__prompt_message__S__read_status=1)
        admin_obj = Candidate_user.objects(
            login_name=admin_login_name,
            prompt_message__login_name=register_login_name).update_one(
                set__prompt_message__S__read_status=1)
#         admin_obj = Candidate_user.objects(login_name=admin_login_name).update_one({"$set":{'prompt_message.$.read_status':1}})

    status = 'success'

    return HttpResponse(status)
Ejemplo n.º 3
0
def show_prompt_message(request):

    login_name = request.session.get('login_name')

    #     user_obj = Candidate_user.objects.filter(login_name=login_name).as_pymongo()
    #     result_json = user_obj.to_json(ensure_ascii=False)
    #     print(result_json)

    prompt_message_obj = Candidate_user.objects(
        login_name=login_name).only('prompt_message').as_pymongo()

    #     print(prompt_message_obj)
    #     print(type(prompt_message_obj))
    #     print(prompt_message_obj.to_json(ensure_ascii=False))
    #     print(type(prompt_message_obj.to_json(ensure_ascii=False)))
    #     prompt_message_json = prompt_message_obj.to_json(ensure_ascii=False)

    prompt_message_dict = prompt_message_obj[0]
    prompt_message_list = prompt_message_dict.get('prompt_message')

    result_count = 0
    read_count = 0
    unread_count = 0
    for one_message in prompt_message_list:
        if one_message['del_flag'] != 1:
            result_count += 1

            if one_message['read_status'] == 1:
                read_count += 1
            else:
                unread_count += 1
        else:
            continue

#     result_count = len(prompt_message_list)
#     print(result_count)
#
#     unread_count = len(re.findall(r'"read_status": 0', result_json))
#     read_count = len(re.findall(r'"read_status": 1', result_json))

    result_json = dumps(prompt_message_list, ensure_ascii=False)
    print(result_json)

    result_dict = {
        'result_count': result_count,
        'read_count': read_count,
        'unread_count': unread_count,
        'result_json': result_json
    }

    return render(request, 'user_html/show-prompt-message.html', result_dict)
Ejemplo n.º 4
0
def user_del(request):

    delete_count = 0
    status = 'false'
    for real_name, value in request.POST.items():
        if real_name:
            user_obj = Candidate_user.objects(real_name=real_name).update_one(
                set__del_flag=1)
            delete_count += 1

    if (delete_count):
        status = 'success'

#     return HttpResponse(status)
    return JsonResponse({'status': status, 'del_count': delete_count})
Ejemplo n.º 5
0
def user_account_switch(request):

    real_name = request.POST.get('real_name')
    switch_flag = int(request.POST.get('switch_flag'))

    account_statu = False
    if switch_flag:
        account_statu = True

    if real_name:
        user_obj = Candidate_user.objects(real_name=real_name).update_one(
            set__account_status=account_statu)

    if (user_obj):
        status = 'success'

#     return HttpResponse(status)
    return JsonResponse({'status': status})
Ejemplo n.º 6
0
def prompt_message_del(request):

    admin_login_name = request.session.get('login_name')

    delete_count = 0
    status = 'false'
    for register_login_name, value in request.POST.items():
        if register_login_name:
            admin_obj = Candidate_user.objects(
                login_name=admin_login_name,
                prompt_message__login_name=register_login_name).update_one(
                    set__prompt_message__S__del_flag=1)
            delete_count += 1

    if (delete_count):
        status = 'success'

#     return HttpResponse(status)
    return JsonResponse({'status': status, 'del_count': delete_count})
Ejemplo n.º 7
0
def register_info(request):
    if request.method == "POST":
        update_params_dict = {}

        for key, value in request.POST.items():
            if key == 'telephone':
                value = int(value)
                update_params_dict.update({key: value})
            elif re.search(r'time$', key) or re.search(
                    r'day$', key) or re.search(r'date$', key):
                if value:
                    if isinstance(value, str):
                        #    鐢╰ime妯″潡    print (timeArray.tm_year)    #2018
                        #    print (timeArray )    #time.struct_time(tm_year=2018, tm_mon=12, tm_mday=3, tm_hour=20, tm_min=40, tm_sec=0, tm_wday=0, tm_yday=337, tm_isdst=-1)
                        time_array = time.strptime(value, "%Y-%m-%d")
                        time_strp = int(time.mktime(time_array))
                        time_iso_obj = date.fromtimestamp(time_strp)

                        #                         #    鐢╠atetime妯″潡    print (datetimeArray.year) #2018
                        #                         datetimeArray=datetime.datetime.strptime(time_str, "%Y-%m-%d %H:%M:%S")
                        #                         timeStamp1=time.mktime(datetimeArray.timetuple())
                        print(key)
                        print(value)
                        print(time_array)
                        print(time_strp)

                        #    闇�瑕佹妸鏃堕棿鎴宠浆鎹㈡垚date瀵硅薄锛屾墠鑳藉瓨鍏ongodb涓�
                        update_params_dict.update({key: time_iso_obj})
            else:
                if value:
                    update_params_dict.update({key: value})

        if update_params_dict:
            candidate_obj = Candidate_user(**update_params_dict)
            candidate_obj.save()

            #    鏃堕棿鎴�
            date_strf = time.time()
            #    鏍煎紡鍖栨椂闂�
            format_time_string = time.strftime('%Y-%m-%d %H:%M:%S',
                                               time.localtime())
            one_prompt = One_prompt(
                login_name=update_params_dict['login_name'],
                register_real_name=update_params_dict['real_name'],
                date_strf=date_strf,
                date_string=format_time_string)

            admin_prompt_update_obj = Candidate_user.objects(
                role_name__endswith="绠$悊鍛�").update(
                    upsert=True, push__prompt_message=one_prompt)
            #             super_prompt_update_obj = Candidate_user.objects(real_name="鐜嬩负鍐�").update(upsert= True, push__prompt_message=one_prompt)

            if admin_prompt_update_obj:
                print("success add a prompt message")
            else:
                print("failed add a prompt message")

            status = 'success'
            return HttpResponse(status)

    return render(request, 'register.html')