def customerMeetsRequirement(self, customer, danceRole=None, registration=None):
cust_reqs = self.customerrequirement_set.filter(customer=customer,met=True)<EOL>if customer:<EOL><INDENT>cust_priors = customer.eventregistration_set.filter(event__series__isnull=False)<EOL><DEDENT>else:<EOL><INDENT>cust_priors = EventRegistration.objects.none()<EOL><DEDENT>if self.roleEnforced and danceRole and cust_reqs.filter(role=danceRole).exists():<EOL><INDENT>return True<EOL><DEDENT>elif not self.roleEnforced and cust_reqs.exists():<EOL><INDENT>return True<EOL><DEDENT>elif self.roleEnforced and not danceRole:<EOL><INDENT>return False<EOL><DEDENT>for item in self.requirementitem_set.all():<EOL><INDENT>filter_dict = {}<EOL>if item.requiredLevel:<EOL><INDENT>filter_dict['<STR_LIT>'] = item.requiredLevel<EOL><DEDENT>if item.requiredClass:<EOL><INDENT>filter_dict['<STR_LIT>'] = item.requiredClass<EOL><DEDENT>if self.roleEnforced:<EOL><INDENT>filter_dict['<STR_LIT>'] = danceRole<EOL><DEDENT>current_matches = <NUM_LIT:0><EOL>overlap_matches = <NUM_LIT:0><EOL>nonconcurrent_filter = {'<STR_LIT>': timezone.now()}<EOL>if registration:<EOL><INDENT>if isinstance(registration,Registration):<EOL><INDENT>current_matches = registration.eventregistration_set.filter(**filter_dict).count()<EOL><DEDENT>elif isinstance(registration,TemporaryRegistration):<EOL><INDENT>current_matches = registration.temporaryeventregistration_set.filter(**filter_dict).count()<EOL><DEDENT>nonconcurrent_filter = {'<STR_LIT>': registration.firstSeriesStartTime}<EOL>overlap_matches = cust_priors.filter(**filter_dict).exclude(**nonconcurrent_filter).filter(<EOL>event__startTime__lte=registration.lastSeriesEndTime,<EOL>).count()<EOL><DEDENT>priors_matches = cust_priors.filter(**filter_dict).filter(**nonconcurrent_filter).count()<EOL>if item.concurrentRule == item.ConcurrencyRule.prohibited:<EOL><INDENT>matches = priors_matches<EOL><DEDENT>elif item.concurrentRule == item.ConcurrencyRule.allowOneOverlapClass:<EOL><INDENT>matches = priors_matches +cust_priors.filter(**filter_dict).exclude(**nonconcurrent_filter).filter(<EOL>event__startTime__lte=registration.getTimeOfClassesRemaining(<NUM_LIT:1>)<EOL>).count()<EOL><DEDENT>elif item.concurrentRule == item.ConcurrencyRule.allowTwoOverlapClasses:<EOL><INDENT>matches = priors_matches +cust_priors.filter(**filter_dict).exclude(**nonconcurrent_filter).filter(<EOL>event__startTime__lte=registration.getTimeOfClassesRemaining(<NUM_LIT:2>)<EOL>).count()<EOL><DEDENT>elif item.concurrentRule == item.ConcurrencyRule.allowed:<EOL><INDENT>matches = priors_matches + overlap_matches +(current_matches if isinstance(registration,TemporaryRegistration) else <NUM_LIT:0>)<EOL><DEDENT>elif item.concurrentRule == item.ConcurrencyRule.required:<EOL><INDENT>matches = overlap_matches + current_matches<EOL><DEDENT>if matches >= item.quantity:<EOL><INDENT>if self.booleanRule == self.BooleanChoice.booleanOr:<EOL><INDENT>return True<EOL><DEDENT>if self.booleanRule == self.BooleanChoice.booleanNot:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if self.booleanRule == self.BooleanChoice.booleanAnd:<EOL><INDENT>return False<EOL><DEDENT><DEDENT><DEDENT>if self.booleanRule == self.BooleanChoice.booleanOr or self.requirementitem_set.count() == <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT>return True<EOL>
This method checks whether a given customer meets a given set of requirements.