コード例 #1
0
    def load_related_objects(self, context):
        """Load objects related to the contact and append them into the context."""
        descriptions = self._get_status_descriptions(
            "contact", WHOIS.get_contact_status_descriptions)
        data = context[self._registry_objects_key][
            "contact"]  # detail, type, label, href
        registry_object = data["detail"]

        ver_status = [{
            "code":
            key,
            "label":
            descriptions[key],
            "icon":
            self.VERIFICATION_STATUS_ICON.get(
                key, self.VERIFICATION_STATUS_ICON["DEFAULT"])
        } for key in registry_object.statuses
                      if key in self.CONTACT_VERIFICATION_STATUS]
        data.update({
            "status_descriptions": [
                descriptions[key] for key in registry_object.statuses
                if key not in self.CONTACT_VERIFICATION_STATUS
            ],
            "verification_status":
            ver_status,
            "is_linked":
            STATUS_LINKED in registry_object.statuses
        })
        if registry_object.creating_registrar_handle:
            data["creating_registrar"] = WHOIS.get_registrar_by_handle(
                registry_object.creating_registrar_handle)
        if registry_object.sponsoring_registrar_handle:
            data["sponsoring_registrar"] = WHOIS.get_registrar_by_handle(
                registry_object.sponsoring_registrar_handle)
コード例 #2
0
 def _get_object(self, handle: str) -> Any:
     objects = {}
     with suppress(OBJECT_NOT_FOUND, INVALID_HANDLE):
         objects['contact'] = WHOIS.get_contact_by_handle(handle)
     with suppress(OBJECT_NOT_FOUND, INVALID_HANDLE):
         objects['nsset'] = WHOIS.get_nsset_by_handle(handle)
     with suppress(OBJECT_NOT_FOUND, INVALID_HANDLE):
         objects['keyset'] = WHOIS.get_keyset_by_handle(handle)
     with suppress(OBJECT_NOT_FOUND, INVALID_HANDLE):
         objects['registrar'] = WHOIS.get_registrar_by_handle(handle)
     if not handle.startswith("."):
         with suppress(OBJECT_NOT_FOUND, UNMANAGED_ZONE, INVALID_LABEL,
                       TOO_MANY_LABELS, idna.IDNAError):
             idna_handle = idna.encode(handle).decode()
             try:
                 objects['domain'] = WHOIS.get_domain_by_handle(idna_handle)
             except OBJECT_DELETE_CANDIDATE:
                 objects['domain'] = None
     if not objects:
         raise WebwhoisError(
             code="OBJECT_NOT_FOUND",
             title=_("Record not found"),
             message=self.message_with_handle_in_html(
                 _("%s does not match any record."), handle),
             object_not_found=True,
         )
     return objects
コード例 #3
0
ファイル: registrar.py プロジェクト: CZ-NIC/fred-webwhois
 def _get_object(self, handle: str) -> Any:
     try:
         return WHOIS.get_registrar_by_handle(handle)
     except OBJECT_NOT_FOUND as error:
         raise WebwhoisError(
             'OBJECT_NOT_FOUND',
             title=_("Registrar not found"),
             message=self.message_with_handle_in_html(
                 _("No registrar matches %s handle."), handle),
         ) from error
     except INVALID_HANDLE as error:
         raise WebwhoisError(
             **self.message_invalid_handle(handle)) from error
コード例 #4
0
 def append_nsset_related(cls, data):
     """Load objects related to the nsset and append them into the data context."""
     descriptions = cls._get_status_descriptions(
         "nsset", WHOIS.get_nsset_status_descriptions)
     registry_object = data["detail"]
     data.update({
         "admins": [
             WHOIS.get_contact_by_handle(handle)
             for handle in registry_object.tech_contact_handles
         ],
         "registrar":
         WHOIS.get_registrar_by_handle(registry_object.registrar_handle),
         "status_descriptions":
         [descriptions[key] for key in registry_object.statuses],
     })
コード例 #5
0
 def load_registry_object(cls, context, handle):
     """Load registrar of the handle and append it into the context."""
     try:
         context[cls._registry_objects_key]["registrar"] = {
             "detail": WHOIS.get_registrar_by_handle(handle),
             "label": _("Registrar"),
         }
     except OBJECT_NOT_FOUND:
         context["server_exception"] = {
             "title":
             _("Registrar not found"),
             "message":
             cls.message_with_handle_in_html(
                 _("No registrar matches %s handle."), handle),
         }
     except INVALID_HANDLE:
         context["server_exception"] = cls.message_invalid_handle(handle)
コード例 #6
0
ファイル: registrar.py プロジェクト: CZ-NIC/fred-webwhois
 def load_registry_object(cls, context, handle):
     """Load registrar of the handle and append it into the context."""
     try:
         context[cls._registry_objects_key]["registrar"] = {
             "detail": WHOIS.get_registrar_by_handle(handle),
             "label": _("Registrar"),
         }
     except OBJECT_NOT_FOUND as error:
         raise WebwhoisError(
             'OBJECT_NOT_FOUND',
             title=_("Registrar not found"),
             message=cls.message_with_handle_in_html(
                 _("No registrar matches %s handle."), handle),
         ) from error
     except INVALID_HANDLE as error:
         raise WebwhoisError(
             **cls.message_invalid_handle(handle)) from error
コード例 #7
0
ファイル: detail_domain.py プロジェクト: CZ-NIC/fred-webwhois
 def load_related_objects(self, context):
     """Load objects related to the domain and append them into the context."""
     descriptions = self._get_status_descriptions(
         "domain", WHOIS.get_domain_status_descriptions)
     data = context[self._registry_objects_key][
         "domain"]  # detail, type, label, href
     if data is None:
         # Domain is a delete candidate
         return
     registry_object = data["detail"]
     data["status_descriptions"] = [
         descriptions[key] for key in registry_object.statuses
     ]
     if STATUS_DELETE_CANDIDATE in registry_object.statuses:
         return
     data.update({
         "registrant":
         WHOIS.get_contact_by_handle(registry_object.registrant_handle),
         "registrar":
         WHOIS.get_registrar_by_handle(registry_object.registrar_handle),
         "admins": [
             WHOIS.get_contact_by_handle(handle)
             for handle in registry_object.admin_contact_handles
         ],
     })
     if registry_object.nsset_handle:
         data["nsset"] = {
             "detail":
             WHOIS.get_nsset_by_handle(registry_object.nsset_handle)
         }
         NssetDetailMixin.append_nsset_related(data["nsset"])
     if registry_object.keyset_handle:
         data["keyset"] = {
             "detail":
             WHOIS.get_keyset_by_handle(registry_object.keyset_handle)
         }
         KeysetDetailMixin.append_keyset_related(data["keyset"])