Exemple #1
0
    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()
Exemple #2
0
    def set_up_context(self, id=None, category_id=None, thread_id=None):
        if id is not None:
            c.group = Group.get(id)
            if c.group is None:
                abort(404)
            c.group_id = c.group.group_id
            c.group_menu_items = group_menu_items()
            c.object_location = c.group.location
            c.security_context = c.group
            c.theme = c.group.location.get_theme()
            c.breadcrumbs.append({'title': c.group.title, 'link': c.group.url()})
        else:
            c.group = None
            c.group_id = None

        if category_id is not None:
            try:
                category_id = int(category_id)
            except ValueError:
                abort(404)
            c.category = ForumCategory.get(category_id)
            if c.category is None:
                abort(404)
            c.breadcrumbs.append({'title': c.category.title,
                                  'link': url(controller=c.controller,
                              action='index', id=id, category_id=category_id)})
        else:
            c.category = None

        if thread_id is not None:
            try:
                thread_id = int(thread_id)
            except ValueError:
                abort(404)
            c.thread = ForumPost.get(thread_id)
            if c.thread is None:
                abort(404)
            assert c.thread.category_id == int(c.category.id), repr(c.thread.category_id)
        else:
            c.thread = None