def login(self, username, password, profiles_cookie, language): """ Выполняет логин к rais и сохраняет полученные cooke :param username: :type username: :param password: :type password: :param profiles_cookie: :type profiles_cookie: :param language: :type language: :return: :rtype: """ response = cr.get(url=pi.get_url_host()+'/get_rsid') for cookie in response.cookies: if cookie.name in 'rsid': cookie_domain=cookie.domain break cookies_jar = response.cookies cookies_jar.set('profile', profiles_cookie, domain=cookie_domain) pi.set_cookies(cookies_jar) params = { "login": username, "pass" : password, "lang" : language } response_login = cr.post(url=pi.get_url_host() + '/interface/orange/user/login', params=params) return response_login
def person(self, type_person, prefix='_'): if type_person in ip.person(): ip_person = ip.person()[type_person] else: print("Нет такого типа Заинтересованной стороны >>" + type_person) assert False name_ip = pi.get_prefix() + prefix + ip_person["name_first"] c_a = self.check_availability(name_ip=name_ip) if c_a: response_person = self.get_contragent_id(c_a) else: params = { "type": ip_person["type"], "name_first": pi.get_prefix() + prefix + ip_person["name_first"], "name_last": pi.get_prefix() + prefix + ip_person["name_last"], "name_middle": pi.get_prefix() + prefix + ip_person["name_middle"], "ip_name_number": ip_person["ip_name_number"], "gender": ip_person["gender"], "date_start": ip_person["date_start"], "date_end": ip_person["date_end"], "date_not_protected": ip_person["date_not_protected"], "nationality": ip_person["nationality"], "note": ip_person["note"], "object_info": ip_person["object_info"] } cr.post(url=pi.get_url_host() + '/api/red/contragent/add', params=params) print('Создали заинтересованную сторону ' + pi.get_prefix() + prefix + ip_person["name_first"]) c_a = self.check_availability(name_ip=name_ip) response_person = self.get_contragent_id(c_a) for l_o_r in ip_person["documents"]: if self.check_availability_contract(name_contract=pi.get_prefix() + prefix + l_o_r["contract_num"]): print('name_contract=', pi.get_prefix() + prefix + l_o_r["contract_num"]) continue contragent_id = response_person.json()["data"]["item"]["id"] kind_id = self.document_kind_id(l_o_r["kind_name"]) rights = ip.rights_json() params = { "contract_num": pi.get_prefix() + prefix + l_o_r["contract_num"], "kind_id": kind_id, "contragent_id": contragent_id, "org_id": 1, "rao_departament": "f5d7fb63-7675-4f8f-a5c5-0776c83b96ce", "date_begin": l_o_r["date_begin"], "date_end": l_o_r["date_end"], "contract_date": l_o_r["contract_date"], "rights": rights, "comment": l_o_r["comment"] } response = cr.post(url=pi.get_url_host() + '/api/red/contract/add', data=params) print( 'Создали документ ' + pi.get_prefix() + prefix + l_o_r["contract_num"], response.ok) for l_o_r in ip_person["societys"]: contragent_id = response_person.json()["data"]["item"]["id"] if self.check_availability_foreign_control( name_foreign=l_o_r["society_name"], zs_id=contragent_id): continue kind_id = self.document_kind_id(l_o_r["society_name"]) parent_contragent_id = self.society_id(l_o_r["society_name"]) rights = ip.rights_json() params = { "contract_num": "", "kind_id": "5beaa959-0000-0000-0000-000081caa7a6", "contragent_id": contragent_id, "parent_contragent_id": parent_contragent_id, "date_begin": l_o_r["date_begin"], "date_end": "", "contract_date": l_o_r["date_begin"], "rights": rights, "comment": l_o_r["comment"] } response = cr.post(url=pi.get_url_host() + '/api/red/contract/add', data=params) print('Общество ' + l_o_r["society_name"], response.ok) return_response = { "id": response_person.json()["data"]["item"]["id"], "sys_id": response_person.json()["data"]["item"]["sys_id"], "type_code": response_person.json()["data"]["item"]["sys_id"], "type_text": response_person.json()["data"]["item"]["type_text"], "name": response_person.json()["data"]["item"]["name"], "name_first": response_person.json()["data"]["item"]["name_first"], "name_last": response_person.json()["data"]["item"]["name_last"], "name_middle": response_person.json()["data"]["item"]["name_last"], "aliases_id": response_person.json()["data"]["item"]["aliases"][0]["id"], "aliases_name": response_person.json()["data"]["item"]["aliases"][0]["name"] } return return_response