示例#1
0
 def update_signer(self, signer_id, status, status_datetime=None,
                   message=u''):
     signer = django_anysign.get_signer_model().objects.get(pk=signer_id)
     signer.status = status
     signer.status_datetime = status_datetime or now()
     signer.status_details = message
     signer.save()
示例#2
0
    def test_get(self):
        """GET "anysign:signer" URL returns HTTP 200."""
        # Create a signature.
        SignatureType = django_anysign.get_signature_type_model()
        Signature = django_anysign.get_signature_model()
        Signer = django_anysign.get_signer_model()
        signature_type, created = SignatureType.objects.get_or_create(
            signature_backend_code='dummysign')
        signature = Signature.objects.create(signature_type=signature_type)
        signer = Signer()
        signature.signers.add(signer)

        url = reverse('anysign:signer', args=[signer.pk])
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
示例#3
0
    def test_get(self):
        """GET "anysign:signer" URL returns HTTP 200."""
        # Create a signature.
        SignatureType = django_anysign.get_signature_type_model()
        Signature = django_anysign.get_signature_model()
        Signer = django_anysign.get_signer_model()
        signature_type, created = SignatureType.objects.get_or_create(
            signature_backend_code='dummysign')
        signature = Signature.objects.create(signature_type=signature_type)
        signer = Signer()
        signature.signers.add(signer)

        url = reverse('anysign:signer', args=[signer.pk])
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
示例#4
0
 def form_valid(self, form):
     # Create signature instance in local DB.
     SignatureType = django_anysign.get_signature_type_model()
     Signature = django_anysign.get_signature_model()
     Signer = django_anysign.get_signer_model()
     signature_type, created = SignatureType.objects.get_or_create(
         signature_backend_code='dummysign')
     signature = Signature.objects.create(signature_type=signature_type)
     signer = Signer()
     signature.signers.add(signer)
     logger.debug(
         '[django_anysign_demo] Signature ID={id} created in local DB'
         .format(id=signature.id))
     # Register signature in backend's DB.
     signature.signature_backend.create_signature(signature)
     # Remember the signature object for later use (:meth:`get_success_url`)
     self.signature = signature
     # Handle the form as always.
     return FormView.form_valid(self, form)
示例#5
0
    def test_post(self):
        """POST "anysign:signer" URL redirects to "signer return"."""
        # Create a signature.
        SignatureType = django_anysign.get_signature_type_model()
        Signature = django_anysign.get_signature_model()
        Signer = django_anysign.get_signer_model()
        signature_type, created = SignatureType.objects.get_or_create(
            signature_backend_code='dummysign')
        signature = Signature.objects.create(signature_type=signature_type)
        signer = Signer()
        signature.signers.add(signer)

        url = reverse('anysign:signer', args=[signer.pk])
        response = self.client.post(url, follow=True)
        signer_return_url = signature.signature_backend.get_signer_return_url(
            signer)
        self.assertEqual(signer_return_url,
                         reverse('anysign:signer_return', args=[signer.pk]))
        self.assertRedirects(response, signer_return_url)
        self.assertEqual(response.status_code, 200)
示例#6
0
    def test_post(self):
        """POST "anysign:signer" URL redirects to "signer return"."""
        # Create a signature.
        SignatureType = django_anysign.get_signature_type_model()
        Signature = django_anysign.get_signature_model()
        Signer = django_anysign.get_signer_model()
        signature_type, created = SignatureType.objects.get_or_create(
            signature_backend_code='dummysign')
        signature = Signature.objects.create(signature_type=signature_type)
        signer = Signer()
        signature.signers.add(signer)

        url = reverse('anysign:signer', args=[signer.pk])
        response = self.client.post(url, follow=True)
        signer_return_url = signature.signature_backend.get_signer_return_url(
            signer)
        self.assertEqual(
            signer_return_url,
            reverse('anysign:signer_return', args=[signer.pk])
        )
        self.assertRedirects(response, signer_return_url)
        self.assertEqual(response.status_code, 200)
示例#7
0
 def get_queryset(self):
     Signer = django_anysign.get_signer_model()
     return Signer.objects.all()