def load(self, request):
        '''Loads new Assignments.'''
        assignments = request.FILES
        reader = csv.reader(assignments['csv'])

        def get_model(model, name, cache):
            if not cache in name:
                cache[name] = model.objects.get(name=name)
            return cache[name]

        def generate_assigments(reader):
            committees = {}
            countries = {}
            schools = {}
            for row in reader:
                if (row[0]=='School' and row[1]=='Committee' and row[2]=='Country'):
                    continue # skip the first row if it is a header
                committee = get_model(Committee, row[1], committees)
                country = get_model(Country, row[2], countries)
                school = get_model(School, row[0], schools)
                if len(row) < 4:
                    rejected = False # allow for the rejected field to be null
                else:
                    rejected = (row[3].lower() == 'true') # use the provided value if admin provides it
                yield (committee.id, country.id, school.id, rejected)

        Assignment.update_assignments(generate_assigments(reader))
        return HttpResponseRedirect(reverse('admin:core_assignment_changelist'))
dataset/ETHPy150Open bmun/huxley/huxley/core/admin/assignment.py/AssignmentAdmin.load/swapped operands of `in`