Izantal, Here is the rough code that connects to the GiftCertificate.post_save() signal to fire off an email at creation. It is just a very simple and rudimentary listener.
*************
from django.conf import settings
from django.core.mail import send_mail
from django.db.models import signals
from payment.modules.giftcertificate.models import GiftCertificate
# Listener function to send email at GiftCertificate creation
def notify_gift_cert_owner(sender, instance, created, **kwargs):
print "***GIFT CERTIFICATE LISTENER****"
if created:
# Here is where we send an email to instance.recipient_email
recipient = instance.recipient_email
buyer = '%s %s' % (instance.purchased_by.first_name,
instance.purchased_by.last_name)
subject = "New Gift Certificate for you."
msg = "A Gift Certificate has been purchased for you at %s by %s in
the amount of $%s.\r\nUse the following code when making purchases:\r\n%s" %
(instance.site.name, buyer, instance.start_balance, instance.code)
sender = settings.DEFAULT_FROM_EMAIL
send_mail(subject, msg, sender, [recipient], fail_silently=False)
else:
pass
signals.post_save.connect(notify_gift_cert_owner, sender=GiftCertificate)
******************
On Thu, Jan 7, 2010 at 1:46 PM, lzantal <[email protected]> wrote:
> Hi Bob,
>
> On Nov 29 2009, 11:43 pm, Bob Waycott <[email protected]> wrote:
> > I am finishing up the code on this. It's not difficult.
> >
> > I'd be willing to contribute the code back to Satchmo (it's nothing more
> > than a simple listener), but I'm not sure what kind of implementation is
> > desired (you know, plain text email vs html email vs template-based
> email,
> > etc.).
> Have you had a chance to finish the code?
> Would love to integrate it into my project.
>
> Thank you
>
> lzantal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Satchmo users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<satchmo-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/satchmo-users?hl=en.
>
>
>
>
-- You received this message because you are subscribed to the Google Groups "Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/satchmo-users?hl=en.
