def email_tracking(request, emailing_id, contact_uuid):
"""handle download of email opening tracking image"""
emailing = get_object_or_404(models.Emailing, id=emailing_id)
contact = get_object_or_404(Contact, uuid=contact_uuid)
emailing.opened_emails.add(contact)
emailing.save()
dir_name = os.path.dirname(os.path.abspath(__file__))
file_name = os.path.join(dir_name, "email-tracking.png")
response = HttpResponse(FileWrapper(open(file_name, 'r')), content_type='image/png')
response['Content-Length'] = os.path.getsize(file_name)
return response
评论列表
文章目录