コード例 #1
0
ファイル: anc.py プロジェクト: siteslave/iCare
def anc_get_list_map_total(request):
    if 'logged' not in request.session:
        return {'ok': 0, 'msg': 'Please login.'}
    else:
        csrf_token = request.params['csrf_token']
        is_token = (csrf_token == unicode(request.session.get_csrf_token()))

        if is_token:

            anc = AncModel(request)

            by = request.params['by']
            vid = request.params['vid'] if 'vid' in request.params else False

            try:
                if vid:
                    home = HomeModel(request)
                    hids = home.get_hid_from_village(
                        request.session['hospcode'], vid)
                    total = anc.get_list_map_anc_total_by_vid(
                        request.session['hospcode'], hids, int(by))
                else:
                    total = anc.get_list_map_anc_total(
                        request.session['hospcode'], int(by))
                return {'ok': 1, 'total': total}
            except Exception as e:
                return {'ok': 0, 'msg': e.message}
        else:
            return {'ok': 0, 'msg': 'Not ajax request'}
コード例 #2
0
ファイル: anc.py プロジェクト: siteslave/iCare
def anc_get_list_map_total(request):
    if "logged" not in request.session:
        return {"ok": 0, "msg": "Please login."}
    else:
        csrf_token = request.params["csrf_token"]
        is_token = csrf_token == unicode(request.session.get_csrf_token())

        if is_token:

            anc = AncModel(request)

            by = request.params["by"]
            vid = request.params["vid"] if "vid" in request.params else False

            try:
                if vid:
                    home = HomeModel(request)
                    hids = home.get_hid_from_village(request.session["hospcode"], vid)
                    total = anc.get_list_map_anc_total_by_vid(request.session["hospcode"], hids, int(by))
                else:
                    total = anc.get_list_map_anc_total(request.session["hospcode"], int(by))
                return {"ok": 1, "total": total}
            except Exception as e:
                return {"ok": 0, "msg": e.message}
        else:
            return {"ok": 0, "msg": "Not ajax request"}