<s> from __future__ import unicode_literals <EOL> from django . db import models <EOL> class ForumReadTrackManager ( models . Manager ) : <EOL> def get_unread_forums_from_list ( self , forums , user ) : <EOL> """<STR_LIT>""" <EOL> unread_forums = [ ] <EOL> tracks = super ( ForumReadTrackManager , self ) . get_queryset ( ) . select_related ( '<STR_LIT>' ) . filter ( <EOL> user = user , <EOL> forum__in = forums ) <EOL> tracked_forums = [ ] <EOL> for track in tracks : <EOL> if ( track . forum . last_post_on and track . mark_time < track . forum . last_post_on ) and track . forum not in unread_forums : <EOL> unread_forums . extend ( track . forum . get_ancestors ( include_self = True ) ) <EOL> tracked_forums . append ( track . forum ) <EOL> for forum in forums : <EOL> if forum not in tracked_forums and forum not in unread_forums and forum . topics . filter ( approved = True ) . count ( ) > <NUM_LIT:0> : <EOL> unread_forums . extend ( forum . get_ancestors ( include_self = True ) ) <EOL> return list ( set ( unread_forums ) ) </s>
