<s> from __future__ import unicode_literals <EOL> from django . db import models <EOL> from django . db . models import Q <EOL> class CategoryQuerySet ( models . QuerySet ) : <EOL> def unremoved ( self ) : <EOL> return self . filter ( Q ( parent = None ) | Q ( parent__is_removed = False ) , <EOL> is_removed = False ) <EOL> def public ( self ) : <EOL> return self . filter ( is_private = False ) <EOL> def visible ( self ) : <EOL> return self . unremoved ( ) . public ( ) <EOL> def opened ( self ) : <EOL> return self . filter ( Q ( parent = None ) | Q ( parent__is_closed = False ) , <EOL> is_closed = False ) <EOL> def parents ( self ) : <EOL> return self . filter ( parent = None ) <EOL> def children ( self , parent ) : <EOL> if parent . is_subcategory : <EOL> return self . none ( ) <EOL> return self . filter ( parent = parent ) </s>
