(self)
return self.post
Edit an existing post.
Edit an existing post.
Edit an existing post .
def edit(self):
        """
        Edit an existing post.
        """
        if self.user != self.post.author and not self.user.profile.is_moderator:
            raise forms.ValidationError("Only the author or a moderator can edit a post.")
        data = self.cleaned_data

        self.post.title = data.get('title')
        content = data.get('content', self.post.content)

        log_edits(user=self.user, post=self.post)
        self.post.content = content

        self.post.type = data.get('post_type')
        self.post.tag_val = data.get('tag_val')
        self.post.lastedit_date = util.now()
        self.post.lastedit_user = self.user
        self.post.save()
        return self.post
def edit ( self ) : if self . user != self . post . author and not self . user . profile . is_moderator : raise forms . ValidationError ( "Only the author or a moderator can edit a post." ) data = self . cleaned_data self . post . title = data . get ( 'title' ) content = data . get ( 'content' , self . post . content ) log_edits ( user = self . user , post = self . post ) self . post . content = content self . post . type = data . get ( 'post_type' ) self . post . tag_val = data . get ( 'tag_val' ) self . post . lastedit_date = util . now ( ) self . post . lastedit_user = self . user self . post . save ( ) return self . post