def track_download(self, attachment, from_preview, **kwargs): if from_preview or not self.settings.get('enabled_for_downloads'): return if attachment.type == AttachmentType.link: resource_url = attachment.link_url resource_title = u'Link - {0.title}'.format(attachment) else: resource_url = request.base_url resource_title = u'Download - {0.title}'.format(attachment) track_download_request.delay(resource_url, resource_title)