#NEWLINE# def __init__( self , instance = None , * args , **kwargs ) : #NEWLINE# #INDENT# self . instance = instance #NEWLINE# super ( BaseCMSPageForm , self ) . __init__ ( * args , ** kwargs ) #NEWLINE# if self . page : #NEWLINE# #INDENT# site = self . page . site_id #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# site = Site . objects . get_current ( ) #NEWLINE# #UNINDENT# if ( 'page_type' in self . fields ) : #NEWLINE# #INDENT# root = Page . objects . filter ( publisher_is_draft = True , reverse_id = PAGE_TYPES_ID , site = site ) . first ( ) #NEWLINE# if root : #NEWLINE# #INDENT# page_types = root . get_descendants ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# page_types = Page . objects . none ( ) #NEWLINE# #UNINDENT# if ( root and page_types ) : #NEWLINE# #INDENT# language = get_language ( ) #NEWLINE# type_ids = page_types . values_list ( 'pk' , flat = True ) #NEWLINE# titles = Title . objects . filter ( page__in = type_ids , language = language ) #NEWLINE# choices = [ ( '' , '---------' ) ] #NEWLINE# for title in titles : #NEWLINE# #INDENT# choices . append ( ( kwargs . page_id , title . title ) ) #NEWLINE# #UNINDENT# self . fields [ 'page_type' ] . choices = choices #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# del self . fields [ 'page_type' ]