<s> from django . db import models <EOL> from django . db . models . query import Q <EOL> from biblion . exceptions import InvalidSection <EOL> from biblion . settings import ALL_SECTION_NAME <EOL> class PostManager ( models . Manager ) : <EOL> def published ( self ) : <EOL> return self . exclude ( published = None ) <EOL> def current ( self ) : <EOL> return self . published ( ) . order_by ( "<STR_LIT>" ) <EOL> def section ( self , value , queryset = None ) : <EOL> if queryset is None : <EOL> queryset = self . published ( ) <EOL> if not value : <EOL> return queryset <EOL> else : <EOL> try : <EOL> section_idx = self . model . section_idx ( value ) <EOL> except KeyError : <EOL> raise InvalidSection <EOL> all_sections = Q ( section = self . model . section_idx ( ALL_SECTION_NAME ) ) <EOL> return queryset . filter ( all_sections | Q ( section = section_idx ) ) </s>
