def reply(self, id, category_id, thread_id): make_forum_post(c.user, c.thread.title, self.form_result['message'], group_id=c.group_id, category_id=category_id, thread_id=thread_id, controller=c.controller) c.thread.mark_as_seen_by(c.user) meta.Session.commit() if request.params.has_key('js'): return _('Reply sent') redirect(url(controller=c.controller, action='thread', id=id, category_id=category_id, thread_id=thread_id))
def forum_reply(self, group_id, category_id, thread_id): try: group_id = int(group_id) group = Group.get(group_id) except ValueError: group = Group.get(group_id) try: thread_id = int(thread_id) category_id = int(category_id) except ValueError: abort(404) category = ForumCategory.get(category_id) thread = ForumPost.get(thread_id) if group is None or category is None or thread is None: abort(404) post = make_forum_post(c.user, thread.title, self.form_result['message'], group_id=group.group_id, category_id=category_id, thread_id=thread_id, controller='forum') thread.mark_as_seen_by(c.user) meta.Session.commit() if request.params.has_key('js'): return render_mako_def('/sections/wall_entries.mako', 'thread_reply', id=post.id, author_id=post.created.id, message=post.message, created_on=post.created_on, allow_comment_deletion=True) else: self._redirect()
def post(self, id, category_id): post = make_forum_post(user=c.user, title=self.form_result['title'], message=self.form_result['message'], group_id=c.group_id, category_id=c.category.id, controller=c.controller) redirect(url(controller=c.controller, action='thread', id=c.group_id, category_id=c.category.id, thread_id=post.id))
def index(self): md5_list = request.POST.getall("md5[]") mime_type_list = request.POST.getall("mime-type[]") file_name_list = request.POST.getall("filename[]") message_text = request.str_POST['Mail'] message = GroupMailingListMessage.parseMessage(message_text) group = message.getGroup() author = message.getAuthor() if group is None: return "Silent bounce!" if not group.mailinglist_enabled: if author is not None and group.is_member(author): meta.set_active_user(author.id) request.environ['repoze.who.identity'] = author.id if not group.forum_categories: return 'Ok!' post = make_forum_post(author, message.getSubject(), message.getBody(), group.id, category_id=group.forum_categories[0].id, thread_id=None, controller='forum') meta.Session.add(post) meta.Session.commit() return 'Ok!' return "Silent bounce!" try: message = GroupMailingListMessage.fromMessageText(message_text) except MessageAlreadyExists: return "Ok!" if message is None: return "Silent bounce!" if message.author is not None: meta.set_active_user(message.author.id) request.environ['repoze.who.identity'] = message.author.id else: meta.set_active_user('') meta.Session.add(message) meta.Session.commit() # to keep message and attachment ids stable attachments = [] for md5, mimetype, filename in zip(md5_list, mime_type_list, file_name_list): if message.author is not None: meta.set_active_user(message.author.id) request.environ['repoze.who.identity'] = message.author.id else: meta.set_active_user('') # XXX we are not filtering nonsense files like small # images, pgp signatures, vcards and html bodies yet. f = File(filename, filename, mimetype=mimetype, md5=md5) f.parent = message meta.Session.add(f) attachments.append(f) meta.Session.commit() # to keep attachment ids stable message.attachments.extend(attachments) if not message.in_moderation_queue: # only send emails for messages that don't have to be # moderated first self._queueMessage(message) meta.Session.commit() # Only send actual emails if commit succeeds self._sendQueuedMessages() return "Ok!"