Beispiel #1
0
 def _call_registry_command(self, form, log_request_id):
     data = form.cleaned_data
     try:
         if data['send_to'].choice == 'custom_email':
             response_id = PUBLIC_REQUEST.create_authinfo_request_non_registry_email(
                 self._get_object_type(data['object_type']), data['handle'],
                 log_request_id,
                 CONFIRMATION_METHOD_IDL_MAP[data['confirmation_method']],
                 data['send_to'].custom_email)
         else:
             # confirm_type_name is 'signed_email'
             response_id = PUBLIC_REQUEST.create_authinfo_request_registry_email(
                 self._get_object_type(data['object_type']), data['handle'],
                 log_request_id)
     except OBJECT_NOT_FOUND as err:
         form.add_error(
             'handle',
             _('Object not found. Check that you have correctly entered the Object type and Handle.'
               ))
         raise PublicRequestKnownException(type(err).__name__)
     except OBJECT_TRANSFER_PROHIBITED as err:
         form.add_error(
             'handle',
             _('Transfer of object is prohibited. The request can not be accepted.'
               ))
         raise PublicRequestKnownException(type(err).__name__)
     except INVALID_EMAIL as err:
         form.add_error(
             'send_to',
             _('The email was not found or the address is not valid.'))
         raise PublicRequestKnownException(type(err).__name__)
     return response_id
Beispiel #2
0
    def get(self, request, public_key):
        public_response = cache.get(public_key)
        if public_response is None:
            raise Http404

        registry_lang_codes = {
            'en': Language.en,
            'cs': Language.cs,
        }
        lang_code = get_language()
        if lang_code not in registry_lang_codes:
            lang_code = 'en'
        language_code = registry_lang_codes[lang_code]

        data = {
            'lang_code': lang_code,
            'document_type': public_response.request_type,
            'handle': public_response.handle,
            'object_type': public_response.object_type,
        }
        if getattr(public_response, 'custom_email', None):
            data['custom_email'] = public_response.custom_email
        if LOGGER:
            log_request = self.prepare_logging_request(data)
            log_request_id = log_request.request_id
        else:
            log_request, log_request_id = None, None
        error_object = None  # type: Optional[BaseException]
        try:
            pdf_content = PUBLIC_REQUEST.create_public_request_pdf(
                public_response.public_request_id, language_code)
        except OBJECT_NOT_FOUND as err:
            WEBWHOIS_LOGGING.error(
                'Exception OBJECT_NOT_FOUND risen for public request id %s.' %
                log_request_id)
            error_object = PublicRequestKnownException(type(err).__name__)
            raise Http404
        except BaseException as err:
            error_object = err
            raise
        finally:
            self.finish_logging_request(log_request,
                                        public_response.public_request_id,
                                        error_object)

        response = HttpResponse(content_type='application/pdf')
        response[
            'Content-Disposition'] = 'attachment; filename="notarized-letter-{0}.pdf"'.format(
                lang_code)
        response.content = pdf_content

        return response
Beispiel #3
0
 def _call_registry_command(self, form, log_request_id):
     data = form.cleaned_data
     try:
         if data['send_to'].choice == SEND_TO_CUSTOM:
             response_id = PUBLIC_REQUEST.create_personal_info_request_non_registry_email(
                 data['handle'], log_request_id,
                 CONFIRMATION_METHOD_IDL_MAP[data['confirmation_method']],
                 data['send_to'].custom_email)
         else:
             assert data['send_to'].choice == SEND_TO_IN_REGISTRY
             response_id = PUBLIC_REQUEST.create_personal_info_request_registry_email(
                 data['handle'], log_request_id)
     except OBJECT_NOT_FOUND as err:
         form.add_error(
             'handle',
             _('Object not found. Check that you have correctly entered the contact handle.'
               ))
         raise PublicRequestKnownException(type(err).__name__)
     except INVALID_EMAIL as err:
         form.add_error(
             'send_to',
             _('The email was not found or the address is not valid.'))
         raise PublicRequestKnownException(type(err).__name__)
     return response_id
Beispiel #4
0
 def _call_registry_command(self, form, log_request_id):
     response_id = None
     try:
         response_id = PUBLIC_REQUEST.create_block_unblock_request(
             self._get_object_type(form.cleaned_data['object_type']),
             form.cleaned_data['handle'], log_request_id,
             CONFIRMATION_METHOD_IDL_MAP[
                 form.cleaned_data['confirmation_method']],
             self._get_lock_type(form.cleaned_data['lock_type']))
     except OBJECT_NOT_FOUND as err:
         form.add_error(
             'handle',
             _('Object not found. Check that you have correctly entered the Object type and '
               'Handle.'))
         raise PublicRequestKnownException(type(err).__name__)
     except OBJECT_ALREADY_BLOCKED as err:
         form.add_error(
             'handle',
             _('This object is already blocked. The request can not be accepted.'
               ))
         raise PublicRequestKnownException(type(err).__name__)
     except OBJECT_NOT_BLOCKED as err:
         form.add_error(
             'handle',
             _('This object is not blocked. The request can not be accepted.'
               ))
         raise PublicRequestKnownException(type(err).__name__)
     except HAS_DIFFERENT_BLOCK as err:
         form.add_error(
             'handle',
             _('This object has another active blocking. The request can not be accepted.'
               ))
         raise PublicRequestKnownException(type(err).__name__)
     except OPERATION_PROHIBITED as err:
         form.add_error(
             'handle',
             _('Operation for this object is prohibited. The request can not be accepted.'
               ))
         raise PublicRequestKnownException(type(err).__name__)
     return response_id