<s> from __future__ import unicode_literals <EOL> from django . db import models <EOL> from django . db . models import Q <EOL> class TopicNotificationQuerySet ( models . QuerySet ) : <EOL> def unremoved ( self ) : <EOL> return self . filter ( Q ( topic__category__parent = None ) | Q ( topic__category__parent__is_removed = False ) , <EOL> topic__category__is_removed = False , <EOL> topic__is_removed = False ) <EOL> def unread ( self ) : <EOL> return self . filter ( is_read = False ) <EOL> def _access ( self , user ) : <EOL> return self . filter ( Q ( topic__category__is_private = False ) | Q ( topic__topics_private__user = user ) , <EOL> user = user ) <EOL> def for_access ( self , user ) : <EOL> return self . unremoved ( ) . _access ( user = user ) . exclude ( action = <NUM_LIT:0> ) <EOL> def read ( self , user ) : <EOL> return self . filter ( user = user ) . update ( is_read = True ) </s>
