2010-08-01 21:50:16 +00:00
from django . db import models
2010-11-20 14:13:49 +00:00
from django . contrib . comments . signals import comment_was_posted
2010-11-20 14:34:09 +00:00
from django . core . mail import send_mail
2010-08-01 21:50:16 +00:00
class Issue ( models . Model ) :
title = models . CharField ( max_length = 255 )
2010-10-21 16:51:01 +00:00
summary = models . TextField ( blank = True , null = True )
2010-08-01 21:50:16 +00:00
date = models . DateField ( )
html = models . TextField ( blank = True )
2010-11-09 19:52:52 +00:00
def __unicode__ ( self ) :
return self . title
2010-08-01 21:50:16 +00:00
2010-11-09 19:52:52 +00:00
def get_dict ( self ) :
#FIXME: return self.date in JSON-friendly way
return {
' id ' : self . id ,
' title ' : self . title ,
' summary ' : self . summary ,
}
2010-08-01 21:50:16 +00:00
# Create your models here.
2010-11-20 14:13:49 +00:00
def comments_notify ( sender , * * kwargs ) :
comment = kwargs [ ' comment ' ]
name = comment . name
email = comment . email
content = comment . comment
erang_id = comment . content_object . id
comment_id = comment . id
2011-03-06 12:35:55 +00:00
# url = "http://theatreforum.in/erang/?issue_id=%d" % (erang_id)
2010-11-20 14:13:49 +00:00
admin_url = " http://theatreforum.in/admin/comments/comment/ %d / " % ( comment_id )
2011-03-06 12:35:55 +00:00
message = " Name: %s \n Email: %s \n Comment: %s \n \n Moderate: %s " % ( name , email , content , admin_url )
send_mail ( " New comment on Theatreforum.in " , message , " do_not_reply@theatreforum.in " , [ " erang@theatreforum.in " , " sanjaybhangar@gmail.com " , " sharvari@theatreforum.in " ] )
2010-11-20 14:13:49 +00:00
return True
comment_was_posted . connect ( comments_notify )