def run(self): #Return All the users in the User table log = Logger('RolesGetHandler') tag = 'run' final_dict = {} role = RoleDBHelper() team = TeamDBHelper() user = UserDBHelper() role_name = self.request.get_argument('role', None) offset = self.request.get_argument('offset', None) count = self.request.get_argument('count', None) name_query = self.request.get_argument('name', None) team_query = self.request.get_argument('team', None) device_query = self.request.get_argument('device_id', None) sort_by = self.request.get_argument('sort_by', True)#Intentionally done sort_order = self.request.get_argument('sort', None) filter_key = str(self.request.get_argument('filter_key', None)) filter_value = self.request.get_argument('filter_value', None) print role_name print "\nUI sorting order \n", sort_order ## Find all the roles in the Roles Table # outer_array = [] if name_query: query = name_query query_type = 'name' elif team_query: query = team_query query_type = 'team' elif device_query: query = device_query query_type = 'device' else: query = None query_type = None if filter_key == 'team': team_name = filter_value team_id = team.get_team_by_name(str(team_name), self.company_id) else: team_name = None team_id=None print "printing team id here ..", team_id if role_name: role_id = role.get_role_by_name(str(role_name), self.company_id) else: roles_list = role.get_roles(self.company_id, [c.ROLE_TABLE_NAME, c.ROLE_TABLE_ID]) role_id = None if role_id: result_list, total_count = user.get_users_for_role( role_name=role_name, role_id=role_id, team_name=team_name, team_id=team_id, offset=offset, count=count, sort_by=sort_by, query=query, query_type=query_type, sort_order=sort_order) elif roles_list: for _role in roles_list: _role['role_type'] = _role.get('name') _role['role_name'] = _role.get('name') _role['role_id'] = _role.get('id') del _role['name'] del _role['id'] result_list = roles_list total_count = len(result_list) else: result_list = None if result_list: final_dict['data'] = result_list final_dict['count'] = total_count final_dict['pass'] = True final_dict['message'] = 'Seems like things are working ...' else: final_dict['data'] = [] final_dict['pass'] = True log.e(tag,'No Role in Role Table') final_dict['message'] = 'Seems like things are not working ...' final_dict['count'] = 0 opJson = json.dumps(final_dict) self.request.write(opJson) tornado.ioloop.IOLoop.instance().add_callback(self.callback)
def run(self): # Return All the users in the User table log = Logger('TeamsGetHandlerThread') tag = 'run' print 'In TeamsGetHandlerThread' final_dict = {} role = RoleDBHelper() team = TeamDBHelper() user = UserDBHelper() team_name = self.request.get_argument('team', None) offset = self.request.get_argument('offset', None) count = self.request.get_argument('count', None) sort_by = self.request.get_argument( 'sort_by', True) # Intentionally done name_query = self.request.get_argument('name', None) role_query = self.request.get_argument('role', None) device_query = self.request.get_argument('device_id', None) sort_order = self.request.get_argument('sort', None) filter_key = str(self.request.get_argument('filter_key', None)) filter_value = self.request.get_argument('filter_value', None) # Find all the roles in the Roles Table if filter_key == 'role': role_name = filter_value role_id = role.get_role_by_name(str(role_name), self.company_id) else: role_name = None role_id = None if name_query: query = name_query query_type = 'name' elif role_query: query = role_query query_type = 'role' elif device_query: query = device_query query_type = 'device' else: query = None query_type = None if team_name: team_id = team.get_team_by_name(str(team_name), self.company_id) else: team_id = None teams_list = team.get_teams(self.company_id, [c.TEAM_TABLE_NAME, c.TEAM_TABLE_ID]) if team_id: result_list, total_count = user.get_users_for_team( team_name=team_name, team_id=team_id, role_name=role_name, role_id=role_id, offset=offset, count=count, sort_by=sort_by, query=query, query_type=query_type, sort_order=sort_order) elif teams_list: for _team in teams_list: _team['team_type'] = _team.get('name') _team['team_name'] = _team.get('name') _team['team_id'] = _team.get('id') del _team['name'] del _team['id'] result_list = teams_list total_count = len(result_list) else: result_list = None if result_list: print "\n total", total_count final_dict['data'] = result_list final_dict['count'] = total_count final_dict['pass'] = True final_dict['message'] = 'Success ...' else: final_dict['pass'] = True final_dict['data'] = [] log.e(tag, 'No Team in Team Table') final_dict['message'] = 'Failed ...' final_dict['count'] = 0 opJson = json.dumps(final_dict) self.request.write(opJson) tornado.ioloop.IOLoop.instance().add_callback(self.callback)
def run(self): #Return All the users in the User table log = Logger('UsersGetHandlerThreadWithPage') tag = 'run' company_id = self.company_id final_dict = {} user = UserDBHelper() team = TeamDBHelper() role = RoleDBHelper() violation = ViolationsDBHelper() device = DeviceDBHelper() offset = self.request.get_argument('offset', None) count = self.request.get_argument('count', None) name_query = self.request.get_argument('name', None) team_query = self.request.get_argument('team', None) role_query = self.request.get_argument('role', None) device_query = self.request.get_argument('device_id', None) sort_by = self.request.get_argument('sort_by', True)#Intentionally done sort_order = self.request.get_argument('sort', None) filter_key = self.request.get_argument('filter_key', None) filter_value = self.request.get_argument('filter_value', None) if filter_key == 'role': role_name = filter_value role_id = role.get_role_by_name(str(role_name), company_id) else: role_name = None role_id = None if filter_key == 'team': team_name = filter_value team_id = team.get_team_by_name(str(team_name), company_id) else: team_name = None team_id = None if filter_key == 'os': os_mapper = {'Android': 'samsung', 'iOS': 'ios'} os_type = os_mapper.get(str(filter_value)) else: os_type = None if name_query: query = name_query query_type = 'name' elif role_query: query = role_query query_type = 'role' elif device_query: query = device_query query_type = 'device' elif team_query: query = team_query query_type = 'team' else: query = None query_type = None if offset: result_list, total_count = user.get_users_for_user( company_id=company_id, offset=offset, count=count, role_id=role_id, team_id=team_id, query=query, query_type=query_type, os_type=os_type, sort_by=sort_by, sort_order=sort_order, filter_key=filter_key, filter_value=filter_value) else: result_list, total_count = user.get_users( {c.USER_TABLE_COMPANY: company_id}) if result_list: for user_dict in result_list: device_deleted = False device_info = device.get_device_with_udid(user_dict.get( 'user_device')) if not device_info: device_info = device.get_device_with_udid(user_dict.get( 'user_device'), status=True) device_deleted = True if device_info: device_id = device_info[0].get(c.DEVICE_TABLE_ID) else: device_id = None if device_deleted: user_dict['user_device'] = None user_dict['user_device_os'] = None if device_id: print "printing \n device id", device_id violation_count = violation.get_violation_count( company_id=company_id, device_id=str(device_id)) else: violation_count = 0 user_dict['user_violation'] = violation_count final_dict['data'] = result_list final_dict['count'] = total_count final_dict['pass'] = True final_dict['message'] = 'Seems like things are working ...' else: final_dict['pass'] = True log.e(tag,'No User in User Table') final_dict['message'] = 'Seems like things are not working ...' final_dict['count'] = 0 ## add all the data into dictionary and create output json opJson = json.dumps(final_dict) self.request.write(opJson) tornado.ioloop.IOLoop.instance().add_callback(self.callback)
def run(self): # Return All the users in the User table log = Logger('UsersGetHandlerThreadWithPage') tag = 'run' company_id = self.company_id final_dict = {} user = UserDBHelper() team = TeamDBHelper() role = RoleDBHelper() violation = ViolationsDBHelper() device = DeviceDBHelper() offset = self.request.get_argument('offset', None) count = self.request.get_argument('count', None) name_query = self.request.get_argument('name', None) team_query = self.request.get_argument('team', None) role_query = self.request.get_argument('role', None) device_query = self.request.get_argument('device_id', None) sort_by = self.request.get_argument('sort_by', True) # Intentionally done sort_order = self.request.get_argument('sort', None) filter_key = self.request.get_argument('filter_key', None) filter_value = self.request.get_argument('filter_value', None) if filter_key == 'role': role_name = filter_value role_id = role.get_role_by_name(str(role_name), company_id) else: role_name = None role_id = None if filter_key == 'team': team_name = filter_value team_id = team.get_team_by_name(str(team_name), company_id) else: team_name = None team_id = None if filter_key == 'os': os_mapper = {'Android': 'samsung', 'iOS': 'ios'} os_type = os_mapper.get(str(filter_value)) else: os_type = None if name_query: query = name_query query_type = 'name' elif role_query: query = role_query query_type = 'role' elif device_query: query = device_query query_type = 'device' elif team_query: query = team_query query_type = 'team' else: query = None query_type = None if offset: result_list, total_count = user.get_users_for_user( company_id=company_id, offset=offset, count=count, role_id=role_id, team_id=team_id, query=query, query_type=query_type, os_type=os_type, sort_by=sort_by, sort_order=sort_order, filter_key=filter_key, filter_value=filter_value) else: result_list, total_count = user.get_users( {c.USER_TABLE_COMPANY: company_id}) if result_list: for user_dict in result_list: device_deleted = False device_info = device.get_device_with_udid( user_dict.get('user_device')) if not device_info: device_info = device.get_device_with_udid( user_dict.get('user_device'), status=True) device_deleted = True if device_info: device_id = device_info[0].get(c.DEVICE_TABLE_ID) else: device_id = None if device_deleted: user_dict['user_device'] = None user_dict['user_device_os'] = None if device_id: print "printing \n device id", device_id violation_count = violation.get_violation_count( company_id=company_id, device_id=str(device_id)) else: violation_count = 0 user_dict['user_violation'] = violation_count final_dict['data'] = result_list final_dict['count'] = total_count final_dict['pass'] = True final_dict['message'] = 'Seems like things are working ...' else: final_dict['pass'] = True log.e(tag, 'No User in User Table') final_dict['message'] = 'Seems like things are not working ...' final_dict['count'] = 0 # add all the data into dictionary and create output json opJson = json.dumps(final_dict) self.request.write(opJson) tornado.ioloop.IOLoop.instance().add_callback(self.callback)
def run(self): # Return All the users in the User table log = Logger('TeamsGetHandlerThread') tag = 'run' print 'In TeamsGetHandlerThread' final_dict = {} role = RoleDBHelper() team = TeamDBHelper() user = UserDBHelper() team_name = self.request.get_argument('team', None) offset = self.request.get_argument('offset', None) count = self.request.get_argument('count', None) sort_by = self.request.get_argument('sort_by', True) # Intentionally done name_query = self.request.get_argument('name', None) role_query = self.request.get_argument('role', None) device_query = self.request.get_argument('device_id', None) sort_order = self.request.get_argument('sort', None) filter_key = str(self.request.get_argument('filter_key', None)) filter_value = self.request.get_argument('filter_value', None) # Find all the roles in the Roles Table if filter_key == 'role': role_name = filter_value role_id = role.get_role_by_name(str(role_name), self.company_id) else: role_name = None role_id = None if name_query: query = name_query query_type = 'name' elif role_query: query = role_query query_type = 'role' elif device_query: query = device_query query_type = 'device' else: query = None query_type = None if team_name: team_id = team.get_team_by_name(str(team_name), self.company_id) else: team_id = None teams_list = team.get_teams(self.company_id, [c.TEAM_TABLE_NAME, c.TEAM_TABLE_ID]) if team_id: result_list, total_count = user.get_users_for_team( team_name=team_name, team_id=team_id, role_name=role_name, role_id=role_id, offset=offset, count=count, sort_by=sort_by, query=query, query_type=query_type, sort_order=sort_order) elif teams_list: for _team in teams_list: _team['team_type'] = _team.get('name') _team['team_name'] = _team.get('name') _team['team_id'] = _team.get('id') del _team['name'] del _team['id'] result_list = teams_list total_count = len(result_list) else: result_list = None if result_list: print "\n total", total_count final_dict['data'] = result_list final_dict['count'] = total_count final_dict['pass'] = True final_dict['message'] = 'Success ...' else: final_dict['pass'] = True final_dict['data'] = [] log.e(tag, 'No Team in Team Table') final_dict['message'] = 'Failed ...' final_dict['count'] = 0 opJson = json.dumps(final_dict) self.request.write(opJson) tornado.ioloop.IOLoop.instance().add_callback(self.callback)
def run(self): # Return All the users in the User table log = Logger('RolesGetHandler') tag = 'run' final_dict = {} role = RoleDBHelper() team = TeamDBHelper() user = UserDBHelper() role_name = self.request.get_argument('role', None) offset = self.request.get_argument('offset', None) count = self.request.get_argument('count', None) name_query = self.request.get_argument('name', None) team_query = self.request.get_argument('team', None) device_query = self.request.get_argument('device_id', None) sort_by = self.request.get_argument( 'sort_by', True) # Intentionally done sort_order = self.request.get_argument('sort', None) filter_key = str(self.request.get_argument('filter_key', None)) filter_value = self.request.get_argument('filter_value', None) print role_name print "\nUI sorting order \n", sort_order # Find all the roles in the Roles Table # outer_array = [] if name_query: query = name_query query_type = 'name' elif team_query: query = team_query query_type = 'team' elif device_query: query = device_query query_type = 'device' else: query = None query_type = None if filter_key == 'team': team_name = filter_value team_id = team.get_team_by_name(str(team_name), self.company_id) else: team_name = None team_id = None print "printing team id here ..", team_id if role_name: role_id = role.get_role_by_name(str(role_name), self.company_id) else: roles_list = role.get_roles(self.company_id, [c.ROLE_TABLE_NAME, c.ROLE_TABLE_ID]) role_id = None if role_id: result_list, total_count = user.get_users_for_role( role_name=role_name, role_id=role_id, team_name=team_name, team_id=team_id, offset=offset, count=count, sort_by=sort_by, query=query, query_type=query_type, sort_order=sort_order) elif roles_list: for _role in roles_list: _role['role_type'] = _role.get('name') _role['role_name'] = _role.get('name') _role['role_id'] = _role.get('id') del _role['name'] del _role['id'] result_list = roles_list total_count = len(result_list) else: result_list = None if result_list: final_dict['data'] = result_list final_dict['count'] = total_count final_dict['pass'] = True final_dict['message'] = 'Seems like things are working ...' else: final_dict['data'] = [] final_dict['pass'] = True log.e(tag, 'No Role in Role Table') final_dict['message'] = 'Seems like things are not working ...' final_dict['count'] = 0 opJson = json.dumps(final_dict) self.request.write(opJson) tornado.ioloop.IOLoop.instance().add_callback(self.callback)