def delete_division(id): errors = [] division = Division.find_by_id(id) Division.delete(id) success = "データベースから部署(" + division.name + ")を削除しました。" return render_template('result.html', success=success, errors=errors)
def parseSeason(name, seasonUrl): data = urllib2.urlopen(seasonUrl) soup = BeautifulSoup(data.read()) teams = [] divisions = [] divisionSet = set() currentDivision = None divisionLevels = dict() seasonId = None divisionLevel = 1 season = Season() season.name = name season.url = seasonUrl teamId = 1 divisionId = 1 for link in soup.find_all('a'): hrefVal = link.get('href') if hrefVal and hrefVal.startswith('display-schedule.php'): #print 'Team name is: ' + link.string + ' : ' + hrefVal if seasonId is None: seasonId = getSeason(hrefVal) team = Team() team.url = hrefVal team.name = link.string team.teamId = teamId teamId += 1 team.players = parseTeam(baseUrl + hrefVal) if (currentDivision) : currentDivision.teams.append(team) elif not hrefVal : test = link.string.split() division = test[1] #print 'Division: ' + division # Only process if division not in divisionSet: divisionSet.add(division) divisions.append(division) divisionLevels[division] = divisionLevel divisionLevel += 1 currentDivision = Division() currentDivision.level = divisionLevel divisionId += 1 currentDivision.divisionId =divisionId currentDivision.name = link.string season.divisions.append(currentDivision ) season.seasonId = seasonId return season
def create_division(): errors = [] if not request.form['name']: errors.append('部署名は必須です。') cmd_type = request.form['cmd-type'] if cmd_type == 'cancel': return render_template('new_division.html') if not errors: name = request.form['name'] Division.insert(name) success = "部署の登録に成功しました。" return render_template('result.html', success=success, errors=errors)
def create_division(self, initial_division, parent_id): url = f'{appUrl}/idm/api/division/card/new' headers = {"Accept-Encoding": "gzip, deflate", "Accept-Language": "ru"} params = {"sort": ""} json = None initial_division_object = initial_division.return_division_data_as_json( ) # division_json = initial_division_object.return_division_data_as_json() parent_orgs_object = self.generate_parent_org_object( parentId=parent_id) initial_division_object.update({'parentOrgs': parent_orgs_object}) # print(division_json) json = initial_division_object response = self.rest.call_request(request_type="POST", url=url, json=json, headers=headers, params=params) json_response = response.json() # initial_division_object = self.fill_division_data_from_response(division_object=initial_division_object, json_response=json_response) created_division = Division() self.fill_division_data_from_response(created_division, json_response) setattr(initial_division, 'oid', created_division.oid) assert initial_division.__eq__(created_division) #print(initial_division) print(created_division) return created_division
def update_division(id): errors = [] if not request.form['name']: errors.append('部署名は必須です。') cmd_type = request.form['cmd-type'] if cmd_type == 'cancel': division = Division.find_by_id(id) return render_template('edit_division.html', division=division) if not errors: name = request.form['name'] division = Division.update(id, name) success = "データベースへの登録に成功しました。" return render_template('result.html', success=success, errors=errors)
def edit_employee(id): employee = Employee.find_by_id(id) divisions = Division.find_all() prefectures = Prefecture.find_all() return render_template('edit_employee.html', employee=employee, divisions=divisions, prefectures=prefectures)
def generate_parent_org_object(self, parentId): parent_orgs_object = {} url = f'{appUrl}/idm/api/division/card/{parentId}' headers = {"Accept-Encoding": "gzip, deflate", "Accept-Language": "ru"} params = {"sort": ""} json = None response = self.rest.call_request(request_type="GET", url=url, json=json, headers=headers, params=params) json_reponse = response.json() if response.status_code == 200: division_object = Division() parent_division_object_filled = self.fill_division_data_from_response( division_object=division_object, json_response=json_reponse) parent_orgs = parent_division_object_filled.parentOrgs parent_orgs_object.update({ 'id': parentId, 'ids': parent_orgs['ids'] + [parent_division_object_filled.oid], 'name': parent_orgs['name'] + [parent_division_object_filled.shortName], 'paths': parent_orgs['name'] + [parent_division_object_filled.shortName], 'type': 'org' }) # print(parent_orgs_object) return parent_orgs_object elif response.status_code == 500: parent_company_filled = self.get_company_by_oid( company_oid=parentId) # print(parent_company_filled) parent_orgs = parent_company_filled.parentCompanyRef parent_orgs_object.update({ 'id': parentId, 'ids': [parent_orgs['id']] + [parent_company_filled.oid], 'name': [parent_orgs['name']] + [parent_company_filled.shortName], 'paths': [parent_orgs['name']] + [parent_company_filled.shortName], 'type': 'org' }) # print(parent_orgs_object) return parent_orgs_object else: print(f'Что то пошло не так, код ответа: {response.status_code}')
def get_division_by_oid(self, division_oid): url = f'{appUrl}/idm/api/division/card/{division_oid}' headers = {"Accept-Encoding": "gzip, deflate", "Accept-Language": "ru"} params = {"sort": ""} json = None division_got_by_oid = Division() response = self.rest.call_request(request_type="GET", url=url, json=json, headers=headers, params=params) json_response = response.json() self.fill_division_data_from_response( division_object=division_got_by_oid, json_response=json_response) # print(division_got_by_oid) return division_got_by_oid
children_list = self._get_all_children_for_node( node_oid=parent_oid) for child in children_list: # print(child) if child['id'] == position_oid: print(parent_oid) return parent_oid break else: self._find_parent_for_position(position_oid=position_oid, parent_oid=parent_oid) a = OrgHelper() # # # a.get_company_by_oid(company_oid='876412c3-4fab-4c12-b42f-7a40a1b38267') division = Division() # company = Company() # position = Position() # new_pos = Position() # # a.generate_parent_org_object(parentId='efb6f40a-c391-44e2-aeb0-6675cb321151') # #a.generate_parent_org_object(parentId='58fe98de-27cd-4205-8df8-d1071c4eb2bf') #a.create_division(division, parent_id='3252e137-98db-47a5-bae7-6cf947ddfdaf') # # a.make_position_path(parentId='b5a1f64f-d75c-4230-bd51-672bfc01c489') # # a.create_position(parentId='b5a1f64f-d75c-4230-bd51-672bfc01c489') # a.delete_position(positionId='f1b823ec-4442-4d56-baa9-c39152e5c404') #a.create_company_type(initial_company=company, parent_company_oid='876412c3-4fab-4c12-b42f-7a40a1b38267') #a._generate_company_parent_value(parent_company_oid='876412c3-4fab-4c12-b42f-7a40a1b38267') # json_response = a.get_children_by_parent_node_oid(parent_oid='3252e137-98db-47a5-bae7-6cf947ddfdaf', child_oid='585060c4-267f-40cd-99bc-f0b7f8668c0b') # position_object = a.fill_position_data_from_response(position_object=position, json_response=json_response) # print(position_object) # a.compare_position_data(created_position=position_object, position_get_by_oid=position_object)
def edit_division(id): division = Division.find_by_id(id) return render_template('edit_division.html', division=division)
def new_employee(): divisions = Division.find_all() prefectures = Prefecture.find_all() return render_template('new_employee.html', divisions=divisions, prefectures=prefectures)
def divisions(): divisions = Division.find_all() return render_template('division_list.html', divisions=divisions)
def search_employees(): divisions = Division.find_all() divisions.insert(0, Division(0, '未指定')) return render_template('search_employee.html', divisions=divisions)