#NEWLINE# def __init__( self , project , language_code = None , * args , **kwargs ) : #NEWLINE# #INDENT# super ( TeamSimpleForm , self ) . __init__ ( * args , ** kwargs ) #NEWLINE# self . fields [ 'project' ] . widget = forms . HiddenInput ( ) #NEWLINE# self . fields [ 'project' ] . initial = kwargs . pk #NEWLINE# self . fields [ 'creator' ] . widget = forms . HiddenInput ( ) #NEWLINE# instance = kwargs . get ( 'instance' , None ) #NEWLINE# if instance : #NEWLINE# #INDENT# general_code = instance . language . code . split ( '_' ) [ 0 ] #NEWLINE# self . disabled_langs = Language . objects . exclude ( ( Q ( code = instance . language . code ) | ( ~ Q ( teams__project = project ) ) ) , Q ( code__startswith = general_code ) ) . values_list ( 'pk' , flat = True ) #NEWLINE# self . fields [ 'language' ] . empty_label = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . disabled_langs = Team . objects . filter ( project = project ) . exclude ( language__code = language_code ) . values_list ( 'language__pk' , flat = True ) #NEWLINE# #UNINDENT# self . fields [ 'language' ] . widget = SelectWithDisabledOptions ( choices = [ ( l . pk , l ) for l in Language . objects . all ( ) ] , disabled_choices = self . disabled_langs )