def body(self): if not self._body and self.drip_base.body_template: body = Template(self.drip_base.body_template).render(self.context) if self.drip_base.drip_model.marketing is True: c = Subscription.for_user(self.user).unsubscribe_code link = 'https://getsiphon.com/drip/unsubscribe/?code=%s' % c body += '<br /><br /><a href="%s">Unsubscribe from future emails</a>' % link self._body = body return self._body
def body(self): if not self._body: body = Template(self.drip_base.body_template).render(self.context) if self.drip_base.drip_model.marketing is True: body += '\n\n' body += '------------------------------' * 2 c = Subscription.for_user(self.user).unsubscribe_code link = 'https://getsiphon.com/drip/unsubscribe/?code=%s' % c body += '\n\n** Unsubscribe: %s' % link self._body = body return self._body
def plain(self): if not self._plain: plain = Template(self.drip_base.plain_template).render(self.context) if self.drip_base.drip_model.marketing is True: plain += '\n\n' plain += '-----------------------------' c = Subscription.for_user(self.user).unsubscribe_code link = 'https://getsiphon.com/drip/unsubscribe/?code=%s' % c plain += '\n\n** Unsubscribe: %s' % link self._plain = plain return self._plain
def get(self, request): c = request.GET.get('code') if not c: raise Http404('Sorry, this unsubscribe link is not valid.') sub = Subscription.for_unsubscribe_code(c) if sub is None: raise Http404('Unknown unsubscribe code.') sub.unsubscribed = True sub.save() return HttpResponse('Unsubscribed! You will no longer receive these ' \ 'emails from us.')
def plain(self): if not self._plain: plain = Template(self.drip_base.plain_template).render( self.context) if self.drip_base.drip_model.marketing is True: plain += '\n\n' plain += '-----------------------------' c = Subscription.for_user(self.user).unsubscribe_code link = 'https://getsiphon.com/drip/unsubscribe/?code=%s' % c plain += '\n\n** Unsubscribe: %s' % link self._plain = plain return self._plain