~sirn/fanboi2

ref: 834edf0edc5dd633c0ecea16231b6ed2d728476d fanboi2/fanboi2/services/board.py -rw-r--r-- 766 bytes
834edf0eKridsada Thanabulpong Massive cleanup in preparation for 0.30 (#25) 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from ..models import Board


class BoardQueryService(object):
    """Board query service provides a service for querying a board
    or a collection of boards from the database.
    """

    def __init__(self, dbsession):
        self.dbsession = dbsession

    def list_active(self):
        """Query all boards that are not archived."""
        return list(
            self.dbsession.query(Board).
            order_by(Board.title).
            filter(Board.status != 'archived'))

    def board_from_slug(self, board_slug):
        """Query a board from the given board slug.

        :param board_slug: The slug :type:`str` identifying a board.
        """
        return self.dbsession.query(Board).\
            filter_by(slug=board_slug).\
            one()