Code

Ticket #6185: frecomment_removed_auto_add_now.diff

File frecomment_removed_auto_add_now.diff, 1.1 KB (added by Øyvind Saltvik <oyvind@…>, 7 years ago)

auto add now sets editable=False removed it and set the submit_date in save

Line 
1Index: django/contrib/comments/models.py
2===================================================================
3--- django/contrib/comments/models.py   (revision 6917)
4+++ django/contrib/comments/models.py   (working copy)
5@@ -159,7 +159,7 @@
6     object_id = models.IntegerField(_('object ID'))
7     comment = models.TextField(_('comment'), max_length=3000)
8     person_name = models.CharField(_("person's name"), max_length=50)
9-    submit_date = models.DateTimeField(_('date/time submitted'), auto_now_add=True)
10+    submit_date = models.DateTimeField(_('date/time submitted'))
11     is_public = models.BooleanField(_('is public'))
12     ip_address = models.IPAddressField(_('ip address'))
13     # TODO: Change this to is_removed, like Comment
14@@ -193,6 +193,11 @@
15 
16     get_content_object.short_description = _('Content object')
17 
18+    def save(self):
19+        if not self.pk:
20+            self.submit_date = datetime.datetime.now()   
21+        super(FreeComment, self).save()
22+
23 class KarmaScoreManager(models.Manager):
24     def vote(self, user_id, comment_id, score):
25         try: