def add_link(self, link, identifier=''):
        if identifier != '':
            try:
                return self.links.get(identifier=identifier)
            except self.links.model.DoesNotExist:
                return self.links.create(link_target='', identifier=identifier)
        # clean link from htmlentities
        for old, new in (('&amp;','&'),('&lt;','<'),('&gt;','>'),('&quot;','"')):
            link = link.replace(old, new)
        link = self.links.create(link_target=link)
        link.save()
        return '{{base_url}}' + reverse('pennyblack.redirect_link', kwargs={'mail_hash':'{{mail.mail_hash}}','link_hash':link.link_hash}).replace('%7B','{').replace('%7D','}')
Adds a link and returns a replacement link
dataset/ETHPy150Open allink/pennyblack/pennyblack/models/job.py/Job.add_link