IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » patrickbeeson's snipts » email The latest email snipts from patrickbeeson.

showing 1-1 of 1 snipts for email
  • Code to use Akismet in Django blog that also emails the comment to the admin if it's set to is_public.
    from django.contrib.comments.signals import comment_was_posted
    from django.utils.encoding import smart_str
    from django.core.mail import mail_managers
    import akismet
    from django.conf import settings
    from django.contrib.sites.models import Site
    
    ...
    
    def moderate_comment(sender, comment, request, **kwargs):
    	ak = akismet.Akismet(
    		key = settings.AKISMET_API_KEY,
    		blog_url = 'http://%s/' % Site.objects.get_current().domain
    	)
    	data = {
    		'user_ip': request.META.get('REMOTE_ADDR', ''),
    		'user_agent': request.META.get('HTTP_USER_AGENT', ''),
    		'referrer': request.META.get('HTTP_REFERRER', ''),
    		'comment_type': 'comment',
    		'comment_author': smart_str(comment.user_name),
    	}
    	if ak.comment_check(smart_str(comment.comment), data=data, build_data=True):
    		comment.is_public = False
    		comment.save()
    	
    	if comment.is_public:	
    		email_body = "%s"
    		mail_managers ("New comment posted", email_body % (comment.get_as_text()))
        
    comment_was_posted.connect(moderate_comment)
    

    copy | embed

    2 comments - tagged in  posted by patrickbeeson on Feb 21, 2009 at 11:02 a.m. EST
Sign up to create your own snipts, or login.