def clean(self):
super(SubstituteReportingForm,self).clean()<EOL>occurrences = self.cleaned_data.get('<STR_LIT>',[])<EOL>staffMember = self.cleaned_data.get('<STR_LIT>')<EOL>replacementFor = self.cleaned_data.get('<STR_LIT>',[])<EOL>event = self.cleaned_data.get('<STR_LIT>')<EOL>for occ in occurrences:<EOL><INDENT>for this_sub in occ.eventstaffmember_set.all():<EOL><INDENT>if this_sub.replacedStaffMember == replacementFor:<EOL><INDENT>self.add_error('<STR_LIT>',ValidationError(_('<STR_LIT>'),code='<STR_LIT>'))<EOL><DEDENT><DEDENT><DEDENT>if event and staffMember:<EOL><INDENT>if staffMember in [x.staffMember for x in event.eventstaffmember_set.filter(category__in=[getConstant('<STR_LIT>'),getConstant('<STR_LIT>')])]:<EOL><INDENT>self.add_error('<STR_LIT>',ValidationError(_('<STR_LIT>'),code='<STR_LIT>'))<EOL><DEDENT><DEDENT>
This code prevents multiple individuals from substituting for the
same class and class teacher.  It also prevents an individual from
substituting for a class in which they are a teacher.