it/itf/erang_organised/models.py

60 lines
1.6 KiB
Python
Raw Normal View History

2010-08-02 03:20:16 +05:30
from django.db import models
2010-11-20 19:43:49 +05:30
from django.contrib.comments.signals import comment_was_posted
from django.core.mail import send_mail
2011-04-10 07:30:43 +05:30
from app.models import ItfModel
2010-08-02 03:20:16 +05:30
2011-04-10 07:30:43 +05:30
class Issue(ItfModel):
2010-08-02 03:20:16 +05:30
title = models.CharField(max_length=255)
2010-10-21 18:51:01 +02:00
summary = models.TextField(blank=True, null=True)
2010-08-02 03:20:16 +05:30
date = models.DateField()
html = models.TextField(blank=True)
2011-04-10 07:30:43 +05:30
fts_fields = ['title', 'summary']
fk_filters = []
def preview_dict(self):
return {
'id': self.id,
'title': self.title,
'summary': self.summary,
}
def info_dict(self):
d = self.preview_dict()
d['html'] = self.html
return d
2010-08-02 03:20:16 +05:30
2011-04-10 07:30:43 +05:30
def list_dict(self):
return {
'id': self.id,
'title': self.title
}
2010-11-10 01:22:52 +05:30
def __unicode__(self):
return self.title
2010-08-02 03:20:16 +05:30
2010-11-10 01:22:52 +05:30
def get_dict(self):
#FIXME: return self.date in JSON-friendly way
return {
'id': self.id,
'title': self.title,
'summary': self.summary,
}
2010-08-02 03:20:16 +05:30
# Create your models here.
2010-11-20 19:43:49 +05:30
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 18:05:55 +05:30
# url = "http://theatreforum.in/erang/?issue_id=%d" % (erang_id)
2010-11-20 19:43:49 +05:30
admin_url = "http://theatreforum.in/admin/comments/comment/%d/" % (comment_id)
2011-03-06 18:05:55 +05:30
message = "Name: %s \n Email: %s \n Comment: %s\n\n Moderate: %s" % (name, email, content, admin_url)
2011-07-24 12:02:20 +05:30
send_mail("New comment on Theatreforum.in", message, "do_not_reply@theatreforum.in", ["sanjaybhangar@gmail.com"])
2010-11-20 19:43:49 +05:30
return True
comment_was_posted.connect(comments_notify)