Django

Code

Ticket #6185: frecomment_removed_auto_add_now.diff

File frecomment_removed_auto_add_now.diff, 1.1 kB (added by Øyvind Saltvik <oyvind@saltvik.no>, 1 year ago)

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

  • django/contrib/comments/models.py

    old new  
    159159    object_id = models.IntegerField(_('object ID')) 
    160160    comment = models.TextField(_('comment'), max_length=3000) 
    161161    person_name = models.CharField(_("person's name"), max_length=50) 
    162     submit_date = models.DateTimeField(_('date/time submitted'), auto_now_add=True
     162    submit_date = models.DateTimeField(_('date/time submitted')
    163163    is_public = models.BooleanField(_('is public')) 
    164164    ip_address = models.IPAddressField(_('ip address')) 
    165165    # TODO: Change this to is_removed, like Comment 
     
    193193 
    194194    get_content_object.short_description = _('Content object') 
    195195 
     196    def save(self): 
     197        if not self.pk: 
     198            self.submit_date = datetime.datetime.now()     
     199        super(FreeComment, self).save() 
     200 
    196201class KarmaScoreManager(models.Manager): 
    197202    def vote(self, user_id, comment_id, score): 
    198203        try: