Esempio n. 1
0
def show_contacts_list(request):
    if not request.session.get('is_login', None):
        return redirect("/show_login_page/")
    else:
        village_code = request.session.get('village_code')
        page = 1
        limit = 10
        if request.GET.get("page"):
            page = int(request.GET.get("page"))
        # users = dbop.get_close_contacts()
        total_counts, new_counts = dbop.get_statistic_info(village_code)
        new_contact_count = new_counts['1'] + new_counts['2'] + new_counts['3']
        new_help_count, new_report_count = new_counts['help_count'], new_counts['report_count']
        total_users = total_counts['1'] + total_counts['2'] + total_counts['3']
        new_users = new_counts['1'] + new_counts['2'] + new_counts['3']
        prev_enable, next_enable = 1, 1

        if request.GET.get("processed"):
            processed = request.GET.get("processed")
            users = dbop.get_users(village_code, query_statuses="123", processed=processed, limit=limit,
                                   offset_epoch=page - 1)
            if page == 1:
                prev_enable = 0
            if (page) * limit >= new_users:
                next_enable = 0
        else:
            users = dbop.get_users(village_code, query_statuses="123", limit=limit, offset_epoch=page - 1)
            if page == 1:
                prev_enable = 0
            if (page) * limit >= total_users:
                next_enable = 0
        # new_contact_count = dbop.get_new_close_contacts_count()
        return render(request, "admin/close_contacts_list.html", locals())
Esempio n. 2
0
def show_reports_list(request):
    if not request.session.get('is_login', None):
        return redirect("/show_login_page/")
    else:
        village_code = request.session.get("village_code")
        page = 1
        limit = 5
        if request.GET.get("page"):
            page = int(request.GET.get("page"))
        # helps, reports = dbop.get_all_helps_and_reports()
        total_counts, new_counts = dbop.get_statistic_info(village_code)
        print(total_counts, new_counts)
        new_contact_count = new_counts['1'] + new_counts['2'] + new_counts['3']
        new_help_count = new_counts['help_count']
        total_reports = total_counts['report_count']
        new_reports = new_counts['report_count']
        prev_enable, next_enable = 1, 1
        if request.GET.get("processed"):
            processed = request.GET.get("processed")
            reports = dbop.get_helps(village_code, processed=processed, limit=limit, offset_epoch=page - 1)
            if page == 1:
                prev_enable = 0
            if (page) * limit >= new_reports:
                next_enable = 0
        else:
            reports = dbop.get_reports(village_code, limit=limit, offset_epoch=page - 1)
            if page == 1:
                prev_enable = 0
            if (page) * limit >= total_reports:
                next_enable = 0
        return render(request, "admin/reports_list.html", locals())
Esempio n. 3
0
def show_new_helps_and_reports_list(request):
    if not request.session.get('is_login', None):
        return redirect("/show_login_page/")
    else:
        village_code = request.session.get("village_code")
        page = 1
        if request.GET.get("page"):
            page = int(request.GET.get("page"))
        helps, reports = dbop.get_helps_and_reports(village_code, processed='0', offset_epoch=page - 1)
        total_counts, new_counts = dbop.get_statistic_info(village_code)
        new_contact_count = new_counts['1'] + new_counts['2'] + new_counts['3']
        return render(request, "admin/helps_and_reports_list.html", locals())
Esempio n. 4
0
def delete_patient(request):
    if not request.session.get('is_login', None):
        return redirect("/show_login_page/")
    else:
        if request.GET:
            uid = request.GET.get("uid")
            success = dbop.delete_user(uid)
            if success:
                message = "编号" + uid + "的用户已删除成功。"
                message_type = 0

            else:
                message = "编号" + uid + "的用户未删除成功,请重新尝试!"
                message_type = 1
        else:
            message = "未找到需删除的用户编号,请重新尝试!"
            message_type = 1
        village_code = request.session.get('village_code')
        page = 1
        limit = 10
        if request.GET.get("page"):
            page = int(request.GET.get("page"))
        total_counts, new_counts = dbop.get_statistic_info(village_code)
        new_contact_count = new_counts['1'] + new_counts['2'] + new_counts['3']
        new_help_count, new_report_count = new_counts['help_count'], new_counts['report_count']
        print(new_contact_count, new_help_count, new_report_count)
        total_users = total_counts['4'] + total_counts['5'] + total_counts['6']
        new_users = new_counts['4'] + new_counts['5'] + new_counts['6']
        prev_enable, next_enable = 1, 1

        if request.GET.get("processed"):
            processed = request.GET.get("processed")
            users = dbop.get_users(village_code, query_statuses="456", processed=processed, limit=limit,
                                   offset_epoch=page - 1)
            if page == 1:
                prev_enable = 0
            if (page) * limit >= new_users:
                next_enable = 0
        else:
            users = dbop.get_users(village_code, query_statuses="456", limit=10, offset_epoch=page - 1)
            if page == 1:
                prev_enable = 0
            if (page) * limit >= total_users:
                next_enable = 0
        return render(request, "admin/patients_list.html", locals())
Esempio n. 5
0
def check_close_contact(request):
    if not request.session.get('is_login', None):
        return redirect("/show_login_page/")
    else:
        if request.GET:
            uid = request.GET.get("uid")
            success = dbop.check_user(uid, check_info=True)
            if success:
                message = "编号" + uid + "的密切接触者已核实成功。"
                message_type = 0

            else:
                message = "编号" + uid + "的密切接触者未核实成功,请重新尝试!"
                message_type = 1
        else:
            message = "未找到需核实的密切接触者编号,请重新尝试!"
            message_type = 1
        village_code = request.session.get('village_code')
        page = 1
        limit = 10
        if request.GET.get("page"):
            page = int(request.GET.get("page"))
        # users = dbop.get_close_contacts()
        total_counts, new_counts = dbop.get_statistic_info(village_code)
        new_contact_count = new_counts['1'] + new_counts['2'] + new_counts['3']
        new_help_count, new_report_count = new_counts['help_count'], new_counts['report_count']
        total_users = total_counts['1'] + total_counts['2'] + total_counts['3']
        new_users = new_counts['1'] + new_counts['2'] + new_counts['3']
        prev_enable, next_enable = 1, 1

        if request.GET.get("processed"):
            processed = request.GET.get("processed")
            users = dbop.get_users(village_code, query_statuses="123", processed=processed, limit=limit,
                                   offset_epoch=page - 1)
            if page == 1:
                prev_enable = 0
            if (page) * limit >= new_users:
                next_enable = 0
        else:
            users = dbop.get_users(village_code, query_statuses="123", limit=limit, offset_epoch=page - 1)
            if page == 1:
                prev_enable = 0
            if (page) * limit >= total_users:
                next_enable = 0
        return render(request, "admin/close_contacts_list.html", locals())
Esempio n. 6
0
def go_home(request):
    if not request.session.get('is_login', None):
        return redirect("/show_login_page/")
    else:
        village_code = request.session.get('village_code')
        disease_level = request.session.get('disease_level')
        administrative_name = request.session.get('administrative_name')
        # users = dbop.get_all_users()
        total_counts, new_counts = dbop.get_statistic_info(village_code)

        legend_data, series_data, color_data = toolbox.get_status_data_piechart(total_counts)
        _, total_data, new_data = toolbox.get_status_data_barchart(total_counts, new_counts)
        legend_data_hr, total_hr_data, new_hr_data = toolbox.get_help_and_report_data_barchart(total_counts, new_counts)
        new_contact_count = new_counts['1'] + new_counts['2'] + new_counts['3']
        new_help_count, new_report_count = new_counts['help_count'], new_counts['report_count']

        print(disease_level)
        print(new_contact_count, new_help_count, new_report_count)
        return render(request, "admin/admin_home.html", locals())