Great Migration: spline.plugins => splinext
[zzz-spline-forum.git] / splinext / forum / controllers / forum.py
1 import logging
2
3 from pylons import config, request, response, session, tmpl_context as c, url
4 from pylons.controllers.util import abort, redirect_to
5 from routes import request_config
6 from sqlalchemy.orm.exc import NoResultFound
7
8 from spline import model
9 from spline.model import meta
10 from spline.lib import helpers as h
11 from spline.lib.base import BaseController, render
12
13 log = logging.getLogger(__name__)
14
15 class ForumController(BaseController):
16
17 def forums(self):
18 c.forums = meta.Session.query(model.Forum).order_by(model.Forum.id.asc())
19 return render('/forum/forums.mako')
20
21 def threads(self, forum_id):
22 try:
23 c.forum = meta.Session.query(model.Forum).get(forum_id)
24 except NoResultFound:
25 abort(404)
26
27 return render('/forum/threads.mako')
28
29 def posts(self, forum_id, thread_id):
30 try:
31 c.thread = meta.Session.query(model.Thread) \
32 .filter_by(id=thread_id, forum_id=forum_id).one()
33 except NoResultFound:
34 abort(404)
35
36 return render('/forum/threads.mako')