<s> from django . views . generic . detail import DetailView <EOL> from django . contrib . sites . models import get_current_site <EOL> from django . db . models import Q <EOL> from django . utils import timezone <EOL> from . models import FlatPage <EOL> class PageDetail ( DetailView ) : <EOL> model = FlatPage <EOL> context_object_name = "<STR_LIT>" <EOL> type = '<STR_LIT>' <EOL> def get_template_names ( self ) : <EOL> _template_names = super ( PageDetail , self ) . get_template_names ( ) <EOL> template_names = [ ] <EOL> base_path = '<STR_LIT>' . format ( self . type , self . page . get ( ) . slug ) <EOL> if self . site . id > <NUM_LIT:1> : <EOL> template_names . append ( '<STR_LIT>' . format ( self . site , base_path ) ) <EOL> template_names . append ( base_path ) <EOL> return template_names + _template_names <EOL> def get_queryset ( self ) : <EOL> self . site = get_current_site ( self . request ) <EOL> self . slug = self . kwargs . get ( '<STR_LIT>' ) <EOL> self . page = self . model . objects . filter ( <EOL> Q ( global_page = True ) | Q ( site = self . site ) , <EOL> slug = self . slug , <EOL> date_available__lte = timezone . now ( ) , <EOL> published = True ) <EOL> return self . page </s>
