No problem. You can extend it further than that to send out something better than a text email, but that shows you how to hook into the right spot at the right moment and take it from there.
Best, Bob On Thu, Jan 7, 2010 at 4:35 PM, lzantal <[email protected]> wrote: > Hi Bob, > > Thank you very much! > It does look simple although I have to admit I could not come up with > a working solution on my own without editing satchmo core. > Yet again I see a big need for me to learn signals even more. I did > not know I can use signals like that. > > Thank you very much again > > lzantal > > On Jan 7, 11:01 am, Bob Waycott <[email protected]> wrote: > > 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]> > <satchmo-users%[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]<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.
