Example #1
0
 def __init__(self, sign_order=1, viewer=False, author=False,
              invitation_delivery_method=IDM.email,
              confirmation_delivery_method=CDM.email,
              authentication_method=AM.standard,
              sign_success_redirect_url=None,
              rejection_redirect_url=None):
     super(Signatory, self).__init__()
     self._id = None
     self._current = None
     self._sign_order = sign_order
     self._undelivered_invitation = None
     self._undelivered_email_invitation = None
     self._undelivered_sms_invitation = None
     self._delivered_invitation = None
     self._has_account = None
     self._invitation_delivery_method = invitation_delivery_method
     self._confirmation_delivery_method = confirmation_delivery_method
     self._viewer = viewer
     self._author = author
     self._eleg_mismatch_message = None
     self._sign_time = None
     self._view_time = None
     self._invitation_view_time = None
     self._rejection_time = None
     self._rejection_message = None
     self._sign_success_redirect_url = sign_success_redirect_url
     self._rejection_redirect_url = rejection_redirect_url
     self._authentication_method = authentication_method
     self._sign_url = None
     self._fields = _set.ScriveSet()
     self._fields._elem_validator = tvu.instance(_field.Field)
     self._attachments = _set.ScriveSet()
     self._attachments._elem_validator = tvu.instance(SignatoryAttachment)
Example #2
0
    def test___ixor__(self):
        s = S([1, 2, 3])
        s ^= S([2, 4])
        self.assertEqual(3, len(s))
        self.assertTrue(1 in s)
        self.assertTrue(3 in s)
        self.assertTrue(4 in s)

        s._set_read_only()
        with self.assertRaises(RO):
            s ^= S()
        s._set_invalid()
        with self.assertRaises(INV):
            s ^= S()

        s = S()
        s._elem_validator = tvu.instance(int)
        err_msg = u'other\[\d\] must be int, not None'
        with self.assertRaises(TypeError, err_msg, regex=True):
            s ^= S([2, 3, None])

        s = S()
        with self.assertRaises(TypeError,
                               u'other must be set, not None'):
            s ^= None
Example #3
0
    def test_add(self):
        s = S([1])
        self.assertEqual(1, len(s))
        self.assertTrue(1 in s)
        self.assertFalse(2 in s)
        self.assertFalse(3 in s)

        s.add(2)
        self.assertEqual(2, len(s))
        self.assertTrue(1 in s)
        self.assertTrue(2 in s)
        self.assertFalse(3 in s)

        s._set_read_only()
        with self.assertRaises(RO):
            s.add(3)
        s._set_invalid()
        with self.assertRaises(INV):
            s.add(3)

        s = S()
        s._elem_validator = tvu.instance(int)
        err_msg = u'elem must be int, not []'
        with self.assertRaises(TypeError, err_msg):
            s.add([])
Example #4
0
    def test_update(self):
        s = S([1, 2, 3])
        s.update([2, 4], [1, 5], [6])
        self.assertEqual(6, len(s))
        self.assertTrue(1 in s)
        self.assertTrue(2 in s)
        self.assertTrue(3 in s)
        self.assertTrue(4 in s)
        self.assertTrue(5 in s)
        self.assertTrue(6 in s)

        s._set_read_only()
        with self.assertRaises(RO):
            s.update()
        s._set_invalid()
        with self.assertRaises(INV):
            s.update()

        s = S()
        s._elem_validator = tvu.instance(int)
        err_msg = u'iterables[1][2] must be int, not {}'
        with self.assertRaises(TypeError, err_msg):
            s.update([1], [2, 3, {}])

        with self.assertRaises(TypeError,
                               u'iterables[3] must be iterable, not 2'):
            s.update([], set(), S(), 2)
Example #5
0
    def test_symmetric_difference_update(self):
        s = S([1, 2, 3])
        s.symmetric_difference_update([2, 4])
        self.assertEqual(3, len(s))
        self.assertTrue(1 in s)
        self.assertTrue(3 in s)
        self.assertTrue(4 in s)

        s._set_read_only()
        with self.assertRaises(RO):
            s.symmetric_difference_update([])
        s._set_invalid()
        with self.assertRaises(INV):
            s.symmetric_difference_update([])

        s = S()
        s._elem_validator = tvu.instance(int)
        err_msg = u'iterable[2] must be int, not {}'
        with self.assertRaises(TypeError, err_msg):
            s.symmetric_difference_update([2, 3, {}])

        s = S()
        with self.assertRaises(TypeError,
                               u'iterable must be iterable, not None'):
            s.symmetric_difference_update(None)
Example #6
0
 def __init__(self, title=u'', number_of_days_to_sign=14,
              number_of_days_to_remind=None,
              show_header=True, show_pdf_download=True,
              show_reject_option=True, show_footer=True,
              invitation_message=None, confirmation_message=None,
              api_callback_url=None, language=Language.swedish,
              is_template=False, saved_as_draft=False,
              timezone=u'Europe/Stockholm'):
     super(Document, self).__init__()
     self._id = None
     self._title = title
     self._number_of_days_to_sign = number_of_days_to_sign
     self._number_of_days_to_remind = number_of_days_to_remind
     self._status = None
     self._modification_time = None
     self._creation_time = None
     self._signing_deadline = None
     self._autoremind_time = None
     self._current_sign_order = None
     self._is_template = is_template
     self._show_header = show_header
     self._show_pdf_download = show_pdf_download
     self._show_reject_option = show_reject_option
     self._show_footer = show_footer
     self.invitation_message = invitation_message  # setter has better logic
     self.confirmation_message = \
         confirmation_message  # setter has better logic
     self._api_callback_url = api_callback_url
     self._language = language
     self._tags = _unicode_dict.UnicodeDict()
     self._saved_as_draft = saved_as_draft
     self._deletion_status = DeletionStatus.not_deleted
     self._signing_possible = None
     self._object_version = None
     self._timezone = timezone
     self._viewed_by_author = None
     self._access_token = None
     self._signatories = _set.ScriveSet()
     self._signatories._elem_validator = tvu.instance(_signatory.Signatory)
     self._original_file = None
     self._sealed_document = None
     self._author_attachments = _set.ScriveSet()
     self._author_attachments._elem_validator = tvu.instance(_file.LocalFile)
Example #7
0
 def __init__(self, value=u'', obligatory=True,
              should_be_filled_by_sender=False):
     super(Field, self).__init__()
     self._value = value
     self._closed = None
     self._obligatory = obligatory
     self._should_be_filled_by_sender = should_be_filled_by_sender
     self._placements = ScriveSet()
     self._placements._elem_validator = \
         tvu.instance(_field_placement.FieldPlacement)
Example #8
0
    @description.setter
    @tvu.validate_and_unify(description=tvu.NonEmptyUnicode)
    def description(self, description):
        self._description = description

    @scrive_property
    def file(self):
        return self._file


IDM = InvitationDeliveryMethod
CDM = ConfirmationDeliveryMethod
AM = AuthenticationMethod

MaybeUnicode = tvu.nullable(tvu.instance(unicode))


class Signatory(_object.ScriveObject):

    @tvu.validate_and_unify(sign_order=tvu.PositiveInt,
                            invitation_delivery_method=
                            tvu.instance(IDM, enum=True),
                            confirmation_delivery_method=
                            tvu.instance(CDM, enum=True),
                            authentication_method=
                            tvu.instance(AM, enum=True),
                            viewer=tvu.instance(bool),
                            author=tvu.instance(bool),
                            sign_success_redirect_url=MaybeUnicode,
                            rejection_redirect_url=MaybeUnicode)
Example #9
0
    def _from_json_obj(cls, json):
        try:
            signatories = [_signatory.Signatory._from_json_obj(signatory_json)
                           for signatory_json in json[u'signatories']]
            lang_code = json[u'lang']
            if lang_code == u'gb':
                lang_code = u'en'
            document = Document(title=json[u'title'],
                                number_of_days_to_sign=json[u'daystosign'],
                                number_of_days_to_remind=json[u'daystoremind'],
                                is_template=json[u'template'],
                                show_header=json[u'showheader'],
                                show_pdf_download=json[u'showpdfdownload'],
                                show_reject_option=json[u'showrejectoption'],
                                show_footer=json[u'showfooter'],
                                invitation_message=json[u'invitationmessage'],
                                confirmation_message=
                                json[u'confirmationmessage'],
                                api_callback_url=json[u'apicallbackurl'],
                                language=Language(lang_code),
                                saved_as_draft=json[u'saved'],
                                timezone=json[u'timezone'])
            document.signatories.update(signatories)
            document.tags.update({elem[u'name']: elem[u'value']
                                  for elem in json[u'tags']})
            document._id = json[u'id']
            if json[u'time'] is not None:
                document._modification_time = dateparser.parse(json[u'time'])
            if json[u'ctime'] is not None:
                document._creation_time = dateparser.parse(json[u'ctime'])
            if json[u'timeouttime'] is not None:
                document._signing_deadline = \
                    dateparser.parse(json[u'timeouttime'])
            if json[u'autoremindtime'] is not None:
                document._autoremind_time = \
                    dateparser.parse(json[u'autoremindtime'])
            document._status = DocumentStatus(json[u'status'])
            document._current_sign_order = json[u'signorder']
            deleted = json[u'deleted']
            really_deleted = json[u'reallydeleted']
            if deleted and really_deleted:
                document._deletion_status = DeletionStatus.deleted
            elif deleted:
                document._deletion_status = DeletionStatus.in_trash
            document._signing_possible = json[u'canperformsigning']
            document._object_version = json[u'objectversion']
            document._viewed_by_author = json[u'isviewedbyauthor']
            document._access_token = json[u'accesstoken']
            file_json = json.get(u'file')
            if file_json is not None:
                file_ = _file.RemoteFile(id_=file_json[u'id'],
                                         name=file_json[u'name'])
                document._original_file = file_
            sealed_file_json = json.get(u'sealedfile')
            if sealed_file_json is not None:
                sealed_file = _file.RemoteFile(id_=sealed_file_json[u'id'],
                                               name=sealed_file_json[u'name'])
                document._sealed_document = sealed_file
            author_attachments = \
                _set.ScriveSet([_file.RemoteFile(id_=att_json[u'id'],
                                                 name=att_json[u'name'])
                                for att_json in json[u'authorattachments']])
            author_attachments._elem_validator = tvu.instance(_file.LocalFile)
            document._author_attachments = author_attachments

            if document.status is not DocumentStatus.preparation:
                document._set_read_only()

            return document
        except (KeyError, TypeError, ValueError) as e:
            raise _exceptions.InvalidResponse(e)