def render(self, context): try: linkid = self.linkid.resolve(context) urlpart = urlex.create_hashedurl(linkid, self.trailpath) urlbase = self.urlbase.resolve(context) return '{base}{p}'.format(base=urlbase, p=urlpart) except Exception: return ''
def test_basic(self): # Create recipient, then create and send the email v = self.new_visitor('visitor') d = self.new_draftemail(subject='X', message='My message.', pixelimage=True, recipients=[v]) e = d.send() # Get the TrackedInstance corresponding to the Email and Visitor i = TrackedInstance.objects.get(visitor=v, tracker=e.tracker) # Compute the URL used to acknowledge receipt of the email urltail = urlreverse('targetview-email-acknowledge', urlconf=app_settings.TARGETS_URLCONF) url = urlex.create_hashedurl(i.uuid, urltail) # Haven't accessed it yet self.assertEquals(i.was_accessed(), False) # Try the URL computed above response = self.client.get(url) self.assertEquals(response.status_code, 200) # Now we've accessed it self.assertEquals(i.was_accessed(), True)
def generate_hashedurl(self, urltail): """Creates a hashed url appropriate for this TrackedInstance. The urltail is the portion of the url that will appear after the uuid. """ return urlex.create_hashedurl(self.uuid, urltail)