#NEWLINE# def clean( self ) : #NEWLINE# #INDENT# volume = self . cleaned_data . get ( 'volume' , '' ) #NEWLINE# number = self . cleaned_data . get ( 'number' , '' ) #NEWLINE# suppl_type = self . cleaned_data . get ( 'suppl_type' ) #NEWLINE# publication_year = self . cleaned_data . get ( 'publication_year' ) #NEWLINE# suppl_text = self . cleaned_data . get ( 'suppl_text' ) #NEWLINE# if ( ( suppl_type == 'volume' ) and ( ( volume == '' ) or ( number != '' ) ) ) : #NEWLINE# #INDENT# raise forms . ValidationError ( _ ( 'You must complete the volume filed. Number field must be empty.' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( suppl_type == 'number' ) and ( number == '' ) ) : #NEWLINE# #INDENT# raise forms . ValidationError ( _ ( 'You must complete the number filed. Volume field must be empty.' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# issue = models . Issue . objects . get ( volume = volume , number = number , publication_year = publication_year , suppl_text = suppl_text , journal = self . journal ) #NEWLINE# #UNINDENT# except models . Issue . DoesNotExist : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# except MultipleObjectsReturned as e : #NEWLINE# #INDENT# logger . error ( ( '\n                    Multiple issues returned for the same number, volume and year for one journal.\n                    Traceback: %s' . strip ( ) % e . message ) ) #NEWLINE# raise forms . ValidationError ( { #NEWLINE# #INDENT# NON_FIELD_ERRORS : _ ( 'Issue with this Year and (Volume or Number) already exists for this Journal.' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( self . instance is None ) or ( volume . instance . pk != issue . pk ) ) : #NEWLINE# #INDENT# raise forms . ValidationError ( { #NEWLINE# #INDENT# NON_FIELD_ERRORS : _ ( 'Issue with this Year and (Volume or Number) already exists for this Journal.' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return self . cleaned_data