示例#1
0
 def transfer(self, domain: Domain):
     if domain.epp_code is None:
         raise RegistrarConnectorException('EPP Code is missing')
     contact = domain.contact or domain.service.client
     owner_handle = self.find_or_create_customer(client=contact)
     nameserver_list = self._get_domain_nameservers_as_xml(domain)
     if not nameserver_list:
         raise RegistrarConnectorException(
             _('Nameservers for domain are required'))
     dom_req = E.createDomainRequest(
         self._xml_domain(domain), E.period(domain.registration_period),
         E.authCode(DomainUtils.decode_epp_code(domain.epp_code)),
         E.ownerHandle(owner_handle), E.adminHandle(owner_handle),
         E.techHandle(owner_handle), E.billingHandle(owner_handle),
         E.resellerHandle(''), E.nameServers(E.array(*nameserver_list)))
     response = self.api_request(data=dom_req)
     if response.data.status == 'ACT':
         domain.status = DomainStatus.active
         domain.registration_date = datetime.strptime(
             str(response.data.activationDate), '%Y-%m-%d %H:%M:%S').date()
         domain.expiry_date = datetime.strptime(
             str(response.data.expirationDate), '%Y-%m-%d %H:%M:%S').date()
         domain.epp_code = DomainUtils.encode_epp_code(
             str(response.data.authCode))
         domain.save(update_fields=[
             'status', 'registration_date', 'expiry_date', 'epp_code'
         ])
         return _('Domain transfered')
     elif response.data.status == 'REQ':
         domain.status = DomainStatus.pending
         domain.save(update_fields=['status'])
         return _('Domain pending registration')
     else:
         raise RegistrarConnectorException(_('Domain registration unknown'))
示例#2
0
 def get_epp_code(self, domain: Domain):
     response = self._retrieve_domain(domain)
     auth_code = str(response.data.authCode)
     domain.epp_code = DomainUtils.encode_epp_code(auth_code)
     domain.save(update_fields=['epp_code'])
     return auth_code