Example #1
0
def Password_verifiy(request):
    if request.method == 'POST':
        jsondata = json.loads(request.body.decode('utf-8'))
        cust_code = jsondata.get('params').get('emp_code')
        old_pwd = jsondata.get('params').get('old_pswd')
        oldpswd_verify = class1.get_login(cust_code, old_pwd)
        if (oldpswd_verify[1][0] == 'SUCCESS'):
            obj_pwd_set = muser.user_model()
            obj_pwd_set.employee_gid = request.session['Emp_gid']
            new_password = jsondata.get('params').get('new_pswd')
            obj_pwd_set.new_password = class1.converttoascii(new_password)
            dtpassword = obj_pwd_set.get_password()
            dt_pawword = pd.DataFrame(dtpassword)
            for index, row in dt_pawword.iterrows():
                password1 = str(row['employee_pwd1'])
                password2 = str(row['employee_pwd2'])
                password3 = str(row['employee_pwd3'])
            if password1 == obj_pwd_set.new_password:
                jdata = 'password dont not match previews 3 password'
                return JsonResponse(json.dumps(jdata), safe=False)
            elif password2 == obj_pwd_set.new_password:
                jdata = 'password dont not match previews 3 password'
                return JsonResponse(json.dumps(jdata), safe=False)
            elif password3 == obj_pwd_set.new_password:
                jdata = 'password dont not match previews 3 password'
                return JsonResponse(json.dumps(jdata), safe=False)
            else:
                df_changepwd_view = obj_pwd_set.set_password()
            return JsonResponse(json.dumps(df_changepwd_view), safe=False)
        elif (oldpswd_verify[1][0] == 'FAIL'):
            jdata = 'Wrong old password'
            return JsonResponse(json.dumps(jdata), safe=False)
Example #2
0
def setEmployeeRole(request):
    if request.method == 'POST':
        result = 'false'
        obj_emproledtl = muser.user_model()
        jsondata = json.loads(request.body.decode('utf-8')).get('parms')
        obj_emproledtl.employee_gid = jsondata.get('user_gid')
        obj_emproledtl.created_by = request.session['Emp_gid']
        obj_emproledtl.entity_gid = request.session['Entity_gid']

        role = jsondata.get('user_role')

        # add user
        for u in filter(
                lambda p: p['STATUS'] == True and p['employee_gid'] == None,
                role):
            obj_emproledtl.role_gid = u['role_gid']
            obj_emproledtl.is_removed = ''
            result = outputReturn(obj_emproledtl.setusersvsMenu(), 1)

        # Remove user
        for u in filter(
                lambda p: p['STATUS'] == False and p['employee_gid'] != None,
                role):
            obj_emproledtl.role_gid = u['role_gid']
            obj_emproledtl.is_removed = 'Y'
            result = outputReturn(obj_emproledtl.setusersvsMenu(), 1)

        if (result == 'UPDATE_SUCCESS' or result == 'SUCCESS'):
            return JsonResponse('true', safe=False)
        else:
            return JsonResponse('false', safe=False)
Example #3
0
def getClustGroup(request):
    if request.method == 'GET':
        obj_empList = muser.user_model()
        obj_empList.entity_gid = request.session['Entity_gid']
        df_empList = obj_empList.get_clustgroupList()
        jdata = df_empList.to_json(orient='records')
        return JsonResponse(json.loads(jdata), safe=False)
Example #4
0
def get_rollgroup(request):
    if request.method == 'GET':
        obj_rollgroup = muser.user_model()
        obj_rollgroup.employee_gid = '1'
        df_rolegroup = obj_rollgroup.get_roleGroup()
        jdata = df_rolegroup.to_json(orient='records')
        return JsonResponse(json.loads(jdata), safe=False)
Example #5
0
def get_password(request):
    if request.method == 'GET':
        obj_change_pwd = muser.user_model()
        obj_change_pwd.employee_gid = request.session['Emp_gid']
        obj_change_pwd.employee_name = ''
        df_changepwd_view = obj_change_pwd.get_password()
        jdata = df_changepwd_view.to_json(orient='records')
        return JsonResponse(json.loads(jdata), safe=False)
Example #6
0
def Set_Password(request):
    if request.method == 'POST':
        jsondata = json.loads(request.body.decode('utf-8'))
        obj_pwd_set = muser.user_model()
        obj_pwd_set.employee_gid = jsondata.get('params').get('emp_gid')
        new_password = jsondata.get('params').get('pswd')
        obj_pwd_set.new_password = class1.converttoascii(new_password)
        df_changepwd_view = obj_pwd_set.set_password()
        return JsonResponse(json.dumps(df_changepwd_view), safe=False)
Example #7
0
def get_roleList(request):
    if request.method == 'GET':
        obj_roleList = muser.user_model()
        obj_roleList.role_code = request.GET['role_code']
        obj_roleList.role_name = request.GET['role_name']
        obj_roleList.rolegroup_gid = request.GET['rGroup_gid']
        obj_roleList.entity_gid = json.dumps(
            {"Entity_Gid": request.session['Entity_gid']})
        df_rolegroup = obj_roleList.get_roleList()
        jdata = df_rolegroup.to_json(orient='records')
        return JsonResponse(json.loads(jdata), safe=False)
Example #8
0
def Employee_detail(request):
    obj_change_pwd = muser.user_model()
    obj_change_pwd.employee_gid = request.session['Emp_gid']
    obj_change_pwd.employee_name = ''
    obj_change_pwd.cluster_gid = '0'
    obj_change_pwd.jsonData = json.dumps({
        "entity_gid": [request.session['Entity_gid']],
        "client_gid": []
    })
    df_changepwd_view = obj_change_pwd.get_employee()
    jdata = df_changepwd_view.to_json(orient='records')
    return JsonResponse(json.loads(jdata), safe=False)
Example #9
0
def get_userList(request):
    if request.method == 'GET':
        obj_userList = muser.user_model()
        obj_userList.role_gid = request.GET['role_gid']
        obj_userList.employee_gid = request.GET['user_gid']
        obj_userList.entity_gid = request.session['Entity_gid']
        obj_userList.type = request.GET['gettype']
        obj_userList.json_data = json.dumps(
            {"Entity_Gid": request.session['Entity_gid']})
        df_rolegroup = obj_userList.get_userList()
        df_rolegroup['STATUS'] = df_rolegroup['STATUS'].astype('bool')
        jdata = df_rolegroup.to_json(orient='records')
        return JsonResponse(json.loads(jdata), safe=False)
Example #10
0
def getEmployeeDtl(request):
    if request.method == 'GET':
        obj_empList = muser.user_model()
        obj_empList.employee_gid = 0
        obj_empList.employee_name = ''
        obj_empList.cluster_gid = request.GET['clust_gid']
        obj_empList.jsonData = json.dumps({
            "entity_gid": [request.session['Entity_gid']],
            "client_gid": []
        })
        df_empList = obj_empList.get_employee()
        jdata = df_empList.to_json(orient='records')
        return JsonResponse(json.loads(jdata), safe=False)
Example #11
0
def get_menuList(request):
    if request.method == 'GET':
        obj_menuList = muser.user_model()
        obj_menuList.role_gid = request.GET['role_gid']
        obj_menuList.ismobile = request.GET['ismobile']
        df_menuList = obj_menuList.get_menuList()
        df_menuList['rolemenu_role_gid'] = df_menuList[
            'rolemenu_role_gid'].fillna(0)

        df = pd.DataFrame(
            {
                'menu_gid': ['N', 'Y'],
                'menu_name': ['Web', 'Andriod']
            },
            index=[0, 1])
        mainlist = []
    for xy, main in df.iterrows():
        maindis = {}
        maindis['menu_gid'] = main['menu_gid']
        maindis['menu_name'] = main['menu_name']
        maindis['rVSMenu_isAssign'] = bool(1)
        df_parant = df_menuList[(df_menuList['menu_parent_gid'] == 0) & (
            df_menuList['menu_mobile'] == main['menu_gid'])]
        menulist = []
        for x, menu in df_parant.iterrows():
            menudis = {}
            menudis['menu_gid'] = menu['menu_gid']
            menudis['menu_name'] = menu['menu_name']
            menudis['role_gid'] = menu['rolemenu_role_gid']
            menudis['menu_displayorder'] = menu['menu_displayorder']
            menudis['rVSMenu_isAssign'] = bool(menu['Rights'])
            menudis['ismobile'] = menu['menu_mobile']
            df_child = df_menuList[df_menuList['menu_parent_gid'] ==
                                   menu['menu_gid']]
            childlist = []
            for y, child in df_child.iterrows():
                childdid = {}
                childdid['menu_gid'] = child['menu_gid']
                childdid['menu_name'] = child['menu_name']
                childdid['role_gid'] = child['rolemenu_role_gid']
                childdid['menu_displayorder'] = child['menu_displayorder']
                childdid['rVSMenu_isAssign'] = bool(child['Rights'])
                childdid['ismobile'] = child['menu_mobile']
                subchildlist = []
                df_subchild = df_menuList[df_menuList['menu_parent_gid'] ==
                                          child['menu_gid']]
                for z, subchild in df_subchild.iterrows():
                    subdis = {}
                    subdis['menu_gid'] = subchild['menu_gid']
                    subdis['menu_name'] = subchild['menu_name']
                    subdis['role_gid'] = subchild['rolemenu_role_gid']
                    subdis['menu_displayorder'] = subchild['menu_displayorder']
                    subdis['rVSMenu_isAssign'] = bool(subchild['Rights'])
                    subdis['ismobile'] = subchild['menu_mobile']
                    subchildlist.append(subdis)
                childdid['subchild'] = subchildlist
                childlist.append(childdid)
            menudis['menu_children'] = childlist
            menulist.append(menudis)
        # jdata = menulist.to_json(orient='records')
        maindis['main_children'] = menulist
        mainlist.append(maindis)
    return JsonResponse(json.dumps(mainlist), safe=False)
Example #12
0
def setRoleDetails(request):
    if request.method == 'POST':
        result = 'false'
        obj_roledtl = muser.user_model()
        jsondata = json.loads(request.body.decode('utf-8')).get('parms')
        obj_roledtl.role_gid = jsondata.get('role_gid')
        obj_roledtl.role_code = jsondata.get('role_code')
        obj_roledtl.role_name = jsondata.get('role_name')
        obj_roledtl.rolegroup_gid = jsondata.get('group_gid')
        obj_roledtl.created_by = request.session['Emp_gid']
        obj_roledtl.entity_gid = request.session['Entity_gid']

        user = []
        user = jsondata.get('user_roles')
        menu = []
        menu = jsondata.get('role_menu')

        if (jsondata.get('role_gid') == 0):
            temp = obj_roledtl.setroles()[0].split(',')
            if (len(temp) > 1):
                obj_roledtl.role_gid = int(temp[0])
            else:
                return JsonResponse(json.dumps(temp[0]), safe=False)

        if (type(obj_roledtl.role_gid) == int):
            menudtl = getmenudtlList(menu)
            # add
            jsondate = {'role_gid': obj_roledtl.role_gid}
            jsondate['menu'] = list(
                filter(
                    lambda p: p['rVSMenu_isAssign'] == True and p['role_gid']
                    == 0, menudtl))
            if (len(jsondate['menu']) > 0):
                obj_roledtl.menu_gid = 0
                obj_roledtl.json_data = json.dumps(jsondate)
                result = outputReturn(obj_roledtl.setrolevsMenu(), 1)
            # remove  unchecked menu details
            for m in filter(
                    lambda p: p['rVSMenu_isAssign'] == False and p['role_gid']
                    != 0, menudtl):
                obj_roledtl.menu_gid = m['menu_gid']
                obj_roledtl.json_data = '0'
                result = outputReturn(obj_roledtl.setrolevsMenu(), 1)

            # user
            # add user
            for u in filter(
                    lambda p: p['STATUS'] == True and p['role_gid'] == None,
                    user):
                obj_roledtl.employee_gid = u['employee_gid']
                obj_roledtl.is_removed = ''
                result = outputReturn(obj_roledtl.setusersvsMenu(), 1)

            # Remove user
            for u in filter(
                    lambda p: p['STATUS'] == False and p['role_gid'] != None,
                    user):
                obj_roledtl.employee_gid = u['employee_gid']
                obj_roledtl.role_gid = u['role_gid']
                obj_roledtl.is_removed = 'Y'
                result = outputReturn(obj_roledtl.setusersvsMenu(), 1)

            if (result == 'UPDATE_SUCCESS' or result == 'SUCCESS'):
                return JsonResponse('true', safe=False)
            else:
                return JsonResponse('false', safe=False)
        else:
            return JsonResponse('false', safe=False)