Exemplo n.º 1
0
def tracking_pixel(email, notification_id=None):
    """Returns a mailing tracking pixel"""
    data = {
        # Email Address
        'e': email,
        # Unique Key
        'k': generate_code(),
        # Current Time (Without microseconds, in ISOFormat)
        't': now().replace(microsecond=0).isoformat(),
    }
    # Add Notification ID (if available)
    if notification_id:
        data['n'] = notification_id

    encoded_data, verification_hash = url_representation_encode(data)
    gif_url = reverse(
        'email_open',
        kwargs={
            'encoded_data': encoded_data,
            'request_hash': verification_hash
        }
    )
    # Add our local tracking pixel
    local_tracking = ('<img src="{origin}{location}" width="1" height="1"'
                      ' border="0">').format(origin=settings.ORIGIN,
                                             location=gif_url)
    return local_tracking
Exemplo n.º 2
0
def tracking_pixel(email, notification_id=None):
    """Returns a mailing tracking pixel"""
    data = {
        # Email Address
        'e': email,
        # Unique Key
        'k': generate_code(),
        # Current Time (Without microseconds, in ISOFormat)
        't': now().replace(microsecond=0).isoformat(),
    }
    # Add Notification ID (if available)
    if notification_id:
        data['n'] = notification_id

    encoded_data, verification_hash = url_representation_encode(data)
    gif_url = reverse('email_open',
                      kwargs={
                          'encoded_data': encoded_data,
                          'request_hash': verification_hash
                      })
    # Add our local tracking pixel
    local_tracking = ('<img src="{origin}{location}" width="1" height="1"'
                      ' border="0">').format(origin=settings.ORIGIN,
                                             location=gif_url)
    return local_tracking
Exemplo n.º 3
0
 def test_generate_code_removes_special_characters(self, mock):
     """Test the generate code special character removal functionality."""
     mock.uuid4().hex.decode().encode.return_value = '1+2#3*4/5+6-7%8+90ABC'
     code = utils.generate_code()
     # Ensure that the result is the base64 code
     self.assertEqual(code, '1234567890')
Exemplo n.º 4
0
 def test_generate_code(self):
     """Test the generate_code function returns a 10 character string"""
     code = utils.generate_code()
     self.assertEqual(len(code), 10)
     self.assertIsInstance(code, str)
Exemplo n.º 5
0
 def test_generate_code_removes_special_characters(self, mock):
     """Test the generate code special character removal functionality."""
     mock.uuid4().hex.decode().encode.return_value = '1+2#3*4/5+6-7%8+90ABC'
     code = utils.generate_code()
     # Ensure that the result is the base64 code
     self.assertEqual(code, '1234567890')
Exemplo n.º 6
0
 def test_generate_code(self):
     """Test the generate_code function returns a 10 character string"""
     code = utils.generate_code()
     self.assertEqual(len(code), 10)
     self.assertIsInstance(code, str)