def create_reply(self, parts): """creates a reply to the post which was emailed to the user """ result = None #todo: delete stored files if this function fails content, stored_files = mail.process_parts(parts) if self.post.post_type == 'answer': result = self.user.post_comment(self.post, content, by_email=True) elif self.post.post_type == 'question': wordcount = len(content) / 6 #this is a simplistic hack if wordcount > askbot_settings.MIN_WORDS_FOR_ANSWER_BY_EMAIL: result = self.user.post_answer(self.post, content, by_email=True) else: result = self.user.post_comment(self.post, content, by_email=True) elif self.post.post_type == 'comment': result = self.user.post_comment(self.post.parent, content, by_email=True) result.thread.invalidate_cached_data() self.response_post = result self.used_at = datetime.now() self.save() return result
def edit_post(self, parts): """edits the created post upon repeated response to the same address""" assert self.was_used == True content, stored_files = mail.process_parts(parts) self.user.edit_post(post=self.response_post, body_text=content, revision_comment=_('edited by email'), by_email=True) self.response_post.thread.invalidate_cached_data()
def edit_post(self, parts): """edits the created post upon repeated response to the same address""" assert self.was_used == True content, stored_files = mail.process_parts(parts) self.user.edit_post( post = self.response_post, body_text = content, revision_comment = _('edited by email'), by_email = True ) self.response_post.thread.invalidate_cached_data()
def create_reply(self, parts): """creates a reply to the post which was emailed to the user """ result = None #todo: delete stored files if this function fails content, stored_files = mail.process_parts(parts) if self.post.post_type == 'answer': result = self.user.post_comment( self.post, content, by_email = True ) elif self.post.post_type == 'question': wordcount = len(content)/6#this is a simplistic hack if wordcount > askbot_settings.MIN_WORDS_FOR_ANSWER_BY_EMAIL: result = self.user.post_answer( self.post, content, by_email = True ) else: result = self.user.post_comment( self.post, content, by_email = True ) elif self.post.post_type == 'comment': result = self.user.post_comment( self.post.parent, content, by_email = True ) result.thread.invalidate_cached_data() self.response_post = result self.used_at = datetime.now() self.save() return result